Improved www.ttss.krakow.pl
2 files modified
27 ■■■■■ changed files
common.js 6 ●●●● patch | view | raw | blame | history
index.js 21 ●●●●● patch | view | raw | blame | history
common.js
@@ -33,10 +33,10 @@
// Webservice-related functions
function parseVehicle(vehicleId) {
    if(!vehicleId) return;
    if(!vehicleId) return false;
    if(vehicleId.substr(0, 15) != '635218529567218') {
        console.log('Unknown vehicle, vehicleId=' + vehicleId);
        return;
        return false;
    }
    
    var id = parseInt(vehicleId.substr(15)) - 736;
@@ -122,7 +122,7 @@
        low = 1;
    } else {
        console.log('Unknown vehicle, vehicleId=' + vehicleId + ', id=' + id);
        return;
        return false;
    }
    
    return {
index.js
@@ -27,6 +27,7 @@
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');
@@ -159,7 +160,6 @@
    
    ignore_hashchange = true;
    window.location.hash = '#!' + language + stopId;
    ignore_hashchange = false;
    refresh_button.removeAttribute('disabled');
    
    loading_start();
@@ -245,7 +245,7 @@
    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;
@@ -364,8 +364,8 @@
}
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;
@@ -384,18 +384,25 @@
    
    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)));
        }
    }
}