| | |
| | | 'Zajezdnia Podgórze' : 'P', |
| | | }; |
| | | |
| | | var script_version; |
| | | var script_version_xhr; |
| | | |
| | | // Check for website updates |
| | | function checkVersion() { |
| | | if(script_version_xhr) script_version_xhr.abort(); |
| | | |
| | | script_version_xhr = $.get( |
| | | 'version.php' |
| | | ).done(function(data) { |
| | | if(!script_version) { |
| | | script_version = data; |
| | | return; |
| | | } |
| | | |
| | | if(script_version != data) { |
| | | fail(lang.error_new_version); |
| | | location.reload(true); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function checkVersionInit() { |
| | | checkVersion(); |
| | | setInterval(checkVersion, 3600000); |
| | | } |
| | | |
| | | // Webservice-related functions |
| | | function parseVehicle(vehicleId) { |
| | | if(!vehicleId) return; |
| | |
| | | type = 'GT8S'; |
| | | low = 0; |
| | | |
| | | if(id == 313) { |
| | | if(id == 313 || id == 323) { |
| | | type = 'GT8C' |
| | | low = 1; |
| | | } |
| | |
| | | type = 'N8S-NF'; |
| | | low = 0; |
| | | |
| | | if((451 <= id && id <= 453) || id == 462) { |
| | | if((451 <= id && id <= 455) || id == 462) { |
| | | type = 'N8C-NF'; |
| | | low = 1; |
| | | } |
| | |
| | | }; |
| | | } |
| | | |
| | | function tramIdToVehicleId(tramId) { |
| | | if(0 <= tramId && tramId <= 999) { |
| | | var vehicleId = '0000' + (tramId + 736); |
| | | vehicleId = vehicleId.substr(vehicleId.length - 4) |
| | | return '635218529567218' + vehicleId; |
| | | } |
| | | } |
| | | |
| | | // Element mangling |
| | | function deleteChildren(element) { |
| | | while(element.lastChild) element.removeChild(element.lastChild); |
| | |
| | | function setText(element, text) { |
| | | deleteChildren(element); |
| | | element.appendChild(document.createTextNode(text)); |
| | | } |
| | | |
| | | // Other functions |
| | | var decodeEntitiesTextArea = document.createElement('textarea'); |
| | | function decodeEntities(text) { |
| | | decodeEntitiesTextArea.innerHTML = text; |
| | | return decodeEntitiesTextArea.value; |
| | | } |