From 066ad2f15810e82056eee13b468b5816eec56722 Mon Sep 17 00:00:00 2001 From: rylon Date: Sat, 11 Apr 2015 17:54:28 +0200 Subject: [PATCH] up to 3 tries to load a page, delaying it 1 second, giving time for other ressources to load, fixed problem that sometimes not all stats are loaded --- files/sys/system.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/files/sys/system.js b/files/sys/system.js index 6d02b5b..9340ceb 100644 --- a/files/sys/system.js +++ b/files/sys/system.js @@ -27,13 +27,22 @@ SYSTEM.prototype.hashchange = function () { if(system.hash_change){ system.hash_change(system.cur_state().split(';')[0].split('(')[0]);} }; -SYSTEM.prototype.handle_call_pages_page = function (html,entry,id,forced,cached) { +SYSTEM.prototype.handle_call_pages_page = function (html,entry,id,forced,cached,trycount) { var url = entry['url']+(window.location.search.substr(1) ? '&'+window.location.search.substr(1) : '' ); + if(!trycount){ + trycount = 0;} + trycount++; if($(entry['div']).length){ $(entry['div']).html(html); - this.log_info('load page: '+id+entry['div']+' '+url+' - success'); + this.log_info('load page: '+id+entry['div']+' '+url+' - try '+trycount+' - success'); } else { - this.log_error('load page: '+id+entry['div']+' '+url+' - div not found'); + this.log_error('load page: '+id+entry['div']+' '+url+' - try '+trycount+' - div not found'); + //Try again + if(trycount < 3){ + var tc = trycount; + setTimeout(function() { system.handle_call_pages_page(html,entry,id,forced,cached,tc); },1000); + } + return; } //load css for(var i=0; i < entry['css'].length; i++){