-
- :
- %
-
+
@@ -29,16 +43,29 @@
$(document).ready(function () {
let reloadUrl = "
";
+ function updateBar(pct) {
+ $('#reload-progress-bar').css('width', pct + '%').attr('aria-valuenow', pct);
+ $('#reload-progress-label').text(pct + '%');
+ $('#show-reload-progress .progress').attr('title', pct + '%');
+ }
+
+ function showConnectionError() {
+ clearInterval(pollInterval);
+ $('#reload-progress-bar').removeClass('active');
+ $('#show-reload-progress .progress').removeClass('active');
+ $('#reload-connection-error').show();
+ }
+
function refreshProgress() {
+ $('#reload-spinner').show();
$.getJSON(reloadUrl, function (data) {
let progress = parseInt(data, 10);
-
if (!isNaN(progress)) {
if (progress === -1) {
- $('#show-reload-progress b').text('100%');
+ updateBar(100);
window.location.href = $('#link-reload-action').attr('href');
} else {
- $('#show-reload-progress b').text(progress + '%');
+ updateBar(progress);
}
} else {
console.warn('NaN, leaving...');
@@ -46,10 +73,13 @@
}
}).fail(function (jqxhr, textStatus, error) {
console.error('AJAX error:', textStatus, error);
+ showConnectionError();
+ }).always(function () {
+ $('#reload-spinner').hide();
});
}
refreshProgress();
- setInterval(refreshProgress, 2000);
+ let pollInterval = setInterval(refreshProgress, 2000);
});