| | |
| | | var route_line = document.getElementById('route-line'); |
| | | var route_table = document.getElementById('route-table'); |
| | | var route_vehicle = document.getElementById('route-vehicle'); |
| | | var route_vehicle_info; |
| | | |
| | | var refresh_button = document.getElementById('refresh'); |
| | | var refresh_text = document.getElementById('refresh-text'); |
| | |
| | | |
| | | ignore_hashchange = true; |
| | | window.location.hash = '#!' + language + stopId; |
| | | ignore_hashchange = false; |
| | | refresh_button.removeAttribute('disabled'); |
| | | |
| | | loading_start(); |
| | |
| | | var tr = document.createElement('tr'); |
| | | addCellWithText(tr, data.old[i].patternText); |
| | | var dir_cell = addCellWithText(tr, data.old[i].direction); |
| | | var vehicle = parseVehicle(data.actual[i].vehicleId); |
| | | var vehicle = parseVehicle(data.old[i].vehicleId); |
| | | dir_cell.appendChild(displayVehicle(vehicle)); |
| | | addCellWithText(tr, vehicle.num).className = 'vehicleData'; |
| | | addCellWithText(tr, (vehicle ? vehicle.num : '')).className = 'vehicleData'; |
| | | var status = parseStatus(data.old[i]); |
| | | addCellWithText(tr, status); |
| | | addCellWithText(tr, ''); |
| | |
| | | tr.className = 'active'; |
| | | tr.addEventListener('click', function(tripId, vehicleInfo) { |
| | | return function(){ loadRoute(tripId, vehicleInfo); } |
| | | }(data.actual[i].tripId, vehicle)); |
| | | }(data.old[i].tripId, vehicle)); |
| | | times_table.appendChild(tr); |
| | | } |
| | | |
| | |
| | | var dir_cell = addCellWithText(tr, data.actual[i].direction); |
| | | var vehicle = parseVehicle(data.actual[i].vehicleId); |
| | | dir_cell.appendChild(displayVehicle(vehicle)); |
| | | addCellWithText(tr, vehicle.num).className = 'vehicleData'; |
| | | addCellWithText(tr, (vehicle ? vehicle.num : '')).className = 'vehicleData'; |
| | | var status = parseStatus(data.actual[i]); |
| | | var status_cell = addCellWithText(tr, status); |
| | | var delay = parseDelay(data.actual[i]); |
| | |
| | | if(!tripId) tripId = route_id; |
| | | if(!tripId) return; |
| | | |
| | | if(!vehicleInfo) vehicleInfo = route_vehicle_info; |
| | | if(vehicleInfo === undefined) vehicleInfo = route_vehicle_info; |
| | | |
| | | console.log('loadRoute(' + tripId + ')'); |
| | | route_id = tripId; |
| | |
| | | deleteChildren(route_vehicle); |
| | | if(vehicleInfo) { |
| | | var span = displayVehicle(vehicleInfo); |
| | | setText(route_vehicle, span.title); |
| | | if(span) { |
| | | setText(route_vehicle, span.title); |
| | | } |
| | | route_vehicle.insertBefore(span, route_vehicle.firstChild); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | function change_language(lang) { |
| | | if(!lang || lang.length != 2) return; |
| | | if(lang == language) return; |
| | | if(!lang || lang.length != 2) return false; |
| | | if(lang == language) return false; |
| | | lang_select.value = lang; |
| | | if(!lang_select.value) { |
| | | lang_select.value = language; |
| | |
| | | |
| | | ignore_hashchange = true; |
| | | window.location.hash = '#!' + language + stop_id; |
| | | ignore_hashchange = false; |
| | | |
| | | return true; |
| | | } |
| | | |
| | | function hash() { |
| | | if(ignore_hashchange) return; |
| | | if(ignore_hashchange) { |
| | | ignore_hashchange = false; |
| | | return; |
| | | } |
| | | |
| | | if(window.location.hash.match(/^#![0-9]+$/)) { |
| | | loadTimes(parseInt(window.location.hash.substr(2))); |
| | | } else if(window.location.hash.match(/^#![a-z]{2}[0-9]*$/)) { |
| | | var stop = parseInt(window.location.hash.substr(4)); |
| | | if(stop) stop_id = stop; |
| | | change_language(window.location.hash.substr(2, 2)); |
| | | |
| | | if(!change_language(window.location.hash.substr(2, 2))) { |
| | | loadTimes(parseInt(window.location.hash.substr(2))); |
| | | } |
| | | } |
| | | } |
| | | |