fix table load with low-end backend servers

This commit is contained in:
Matteo Gheza 2020-11-06 14:22:37 +01:00
parent c4fa0600ca
commit 64eefb3f59
1 changed files with 24 additions and 17 deletions

View File

@ -112,7 +112,12 @@ function loadTable(table_page, set_interval=true, interval=10000){
$("#offline_alert").hide(400);
window.offline = false;
}
}).fail(function() {
}).fail(function(data, status) {
if(status == "parsererror"){
if($("#table_body").children().length == 0) {
loadTable(table_page, set_interval, interval);
} // else nothing
} else {
caches.open('tables-1').then(cache => {
cache.match("/table_"+table_page+".json").then(response => {
response.json().then(data => {
@ -126,6 +131,7 @@ function loadTable(table_page, set_interval=true, interval=10000){
$("#offline_alert").show(400);
window.offline = true;
}
}
});
if(set_interval){
window.loadTable_interval = setInterval(function() {
@ -133,6 +139,7 @@ function loadTable(table_page, set_interval=true, interval=10000){
}, interval);
}
}
window.loadTable_interval = loadTable_interval;
window.fillTable = fillTable;
window.loadTable = loadTable;