Improved www.ttss.krakow.pl
Jacek Kowalski
2016-12-08 ac721dc18e5bf997afc016a486fa4788f094b148
Add request in progress indicator
2 files modified
19 ■■■■■ changed files
index.html 6 ●●●●● patch | view | raw | blame | history
index.js 13 ●●●●● patch | view | raw | blame | history
index.html
@@ -72,6 +72,12 @@
            </div>
        </nav>
        <div class="container-fluid">
            <div id="progress" class="progress" style="display: none;">
                <div id="progress-bar" class="progress-bar progress-bar-striped active" style="width: 100%">
                    <span id="progress-text" class="sr-only">Refreshing data...</span>
                </div>
            </div>
            <div id="alert" class="alert alert-danger alert-dismissible" style="display:none">
                <a href="#" class="close" id="alert-close" aria-label="close">&times;</a>
                <strong>Error occured!</strong> <span id="alert-text"></span>
index.js
@@ -30,6 +30,8 @@
var alert_text = document.getElementById('alert-text');
var alert_close = document.getElementById('alert-close');
var progress = document.getElementById('progress');
var parseStatusBoarding = '>>>';
function parseStatus(status) {
    switch(status.status) {
@@ -127,6 +129,14 @@
    alert.style.display = 'none';
}
function loading_start() {
    progress.style.display = 'block';
}
function loading_end() {
    progress.style.display = 'none';
}
function loadTimes(stopId = null, clearRoute = false) {
    if(!stopId) stopId = stop_id;
    if(!stopId) return;
@@ -136,6 +146,7 @@
    
    refresh_button.removeAttribute('disabled');
    
    loading_start();
    times_xhr = $.get(
        ttss_base + '/passageInfo/stopPassages/stop' 
            + '?stop=' + encodeURIComponent(stopId)
@@ -238,7 +249,7 @@
        fail_hide();
        
        times_timer = setTimeout(function(){ loadTimes(); }, ttss_refresh);
    }).fail(fail_ajax);
    }).fail(fail_ajax).always(loading_end);
}
function declinate(num, singular, plural) {