From e1160f623f1fb93fba6dca4d7540e3f59f5d5e2f Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Tue, 26 Jul 2011 16:24:04 -0500 Subject: [PATCH] Add retry count to updates request - don't show red until 3rd miss --- web/js/map.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/web/js/map.js b/web/js/map.js index 1bced0fe..fbc17716 100644 --- a/web/js/map.js +++ b/web/js/map.js @@ -96,6 +96,7 @@ DynMap.prototype = { serverday: false, inittime: new Date().getTime(), followingPlayer: '', + missedupdates: 0, formatUrl: function(name, options) { var url = this.options.url[name]; $.each(options, function(n,v) { @@ -483,13 +484,16 @@ DynMap.prototype = { $(me).trigger('worldupdated', [ update ]); me.lasttimestamp = update.timestamp; - + me.missedupdates = 0; setTimeout(function() { me.update(); }, me.options.updaterate); }, function(status, statusText, request) { - me.alertbox - .text('Could not update map: ' + (statusText || 'Could not connect to server')) - .show(); - $(me).trigger('worldupdatefailed'); + me.missedupdates++; + if(me.missedupdates > 2) { + me.alertbox + .text('Could not update map: ' + (statusText || 'Could not connect to server')) + .show(); + $(me).trigger('worldupdatefailed'); + } setTimeout(function() { me.update(); }, me.options.updaterate); } );