| | |
| | | var stop_name_form = stop_name.form; |
| | | var stop_name_autocomplete = document.getElementById('stop-name-autocomplete'); |
| | | var stop_name_autocomplete_xhr; |
| | | var stop_name_autocomplete_timer; |
| | | |
| | | var times_xhr; |
| | | var times_timer; |
| | |
| | | var prefix; |
| | | var type; |
| | | var low; // low floor: 0 = no, 1 - semi, 2 - full |
| | | |
| | | // Single exception - old id used in one case |
| | | if(id == 831) { |
| | | id = 216; |
| | | } |
| | | |
| | | if(101 <= id && id <= 173) { |
| | | prefix = 'HW'; |
| | |
| | | nav.className = nav.className.replace(' loading', ''); |
| | | } |
| | | |
| | | function loadTimes(stopId = null, clearRoute = false) { |
| | | function loadTimes(stopId, clearRoute) { |
| | | if(!stopId) stopId = stop_id; |
| | | if(!stopId) return; |
| | | |
| | |
| | | */ |
| | | |
| | | for(var i = 0, il = data.generalAlerts.length; i < il; i++) { |
| | | addParaWithText(times_alerts, data.generalAlerts[i]); |
| | | addParaWithText(times_alerts, data.generalAlerts[i].title); |
| | | } |
| | | |
| | | for(var i = 0, il = data.old.length; i < il; i++) { |
| | |
| | | times_alerts, |
| | | lang.line_alert_pattern |
| | | .replace('$line', data.routes[i].name) |
| | | .replace('$alert', data.routes[i].alerts[j]) |
| | | .replace('$alert', data.routes[i].alerts[j].title) |
| | | ); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | function stop_autocomplete() { |
| | | if(stop_name_autocomplete_xhr) stop_name_autocomplete_xhr.abort(); |
| | | |
| | | stop_name_autocomplete_xhr = $.get( |
| | | 'stops.php?query=' + encodeURIComponent(stop_name.value) |
| | | ).done(function(data) { |
| | | deleteChildren(stop_name_autocomplete); |
| | | for(var i = 0, il = data.length; i < il; i++) { |
| | | if(data[i].type != 'stop') continue; |
| | | if(data[i].id > 6000) continue; |
| | | var opt = document.createElement('option'); |
| | | opt.value = data[i].id; |
| | | setText(opt, decodeEntities(data[i].name)); |
| | | stop_name_autocomplete.appendChild(opt); |
| | | } |
| | | |
| | | if(!stop_id) setText(refresh_text, lang.select_stop_click_go); |
| | | }).fail(fail_ajax); |
| | | } |
| | | |
| | | function init() { |
| | | if(!window.jQuery) { |
| | | fail(lang.jquery_not_loaded); |
| | |
| | | |
| | | stop_name.addEventListener('input', function(e) { |
| | | if(!stop_name.value) return; |
| | | if(stop_name_autocomplete_xhr) stop_name_autocomplete_xhr.abort(); |
| | | if(stop_name_autocomplete_timer) clearTimeout(stop_name_autocomplete_timer); |
| | | |
| | | stop_name_autocomplete_xhr = $.get( |
| | | ttss_base + '/lookup/autocomplete/json' |
| | | + '?query=' + encodeURIComponent(stop_name.value) |
| | | ).done(function(data) { |
| | | deleteChildren(stop_name_autocomplete); |
| | | for(var i = 1, il = data.length; i < il; i++) { |
| | | if(data[i].id > 6000) continue; |
| | | var opt = document.createElement('option'); |
| | | opt.value = data[i].id; |
| | | setText(opt, decodeEntities(data[i].name)); |
| | | stop_name_autocomplete.appendChild(opt); |
| | | } |
| | | |
| | | if(!stop_id) setText(refresh_text, lang.select_stop_click_go); |
| | | }).fail(fail_ajax); |
| | | stop_name_autocomplete_timer = setTimeout(stop_autocomplete, 100); |
| | | }); |
| | | |
| | | setText(refresh_text, lang.enter_stop_name_to_begin); |