From 39faef2c4c7ee93241b809241ddfea6fd3a6705e Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 27 Aug 2013 21:29:54 +0100 Subject: [PATCH] critical bugfix - don't assume jquery is available when initially processing JS - setupIdle function added - don't detect portals from a 'turret' entry - use 'portalV2' as the stock site does - don't try to display the field MU counts when not in the data --- code/boot.js | 1 + code/idle.js | 7 +++++-- code/map_data.js | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/boot.js b/code/boot.js index 69bd6f23..5fe59d8b 100644 --- a/code/boot.js +++ b/code/boot.js @@ -456,6 +456,7 @@ function boot() { shadowSize: new L.Point(41, 41) }}); + window.setupIdle(); window.setupTaphold(); window.setupStyles(); window.setupDialogs(); diff --git a/code/idle.js b/code/idle.js index bc21a378..41610775 100644 --- a/code/idle.js +++ b/code/idle.js @@ -44,8 +44,11 @@ var idleMouseMove = function(e) { } } -$('body').keypress(idleReset); -$('body').mousemove(idleMouseMove); +window.setupIdle = function() { + $('body').keypress(idleReset); + $('body').mousemove(idleMouseMove); +} + window.isIdle = function() { return window.idleTime >= window._idleTimeLimit; diff --git a/code/map_data.js b/code/map_data.js index 1216dae0..03db2aad 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -343,7 +343,7 @@ window.handleDataResponse = function(data, fromCache, tile_ids) { if(ent[0] in window._deletedEntityGuid) return true; - if(ent[2].turret !== undefined) { + if(ent[2].portalV2 !== undefined) { // TODO? remove any linkedEdges or linkedFields that have entries in window._deletedEntityGuid var latlng = [ent[2].locationE6.latE6/1E6, ent[2].locationE6.lngE6/1E6]; @@ -374,7 +374,7 @@ window.handleDataResponse = function(data, fromCache, tile_ids) { }); renderField(ent); } else { - throw('Unknown entity: ' + JSON.stringify(ent)); + console.warn('Unknown entity: ' + JSON.stringify(ent)); } }); }); @@ -906,7 +906,7 @@ window.renderField = function(ent) { } // put both in one group, so they can be handled by the same logic. - if (areaZoomRatio > FIELD_MU_DISPLAY_AREA_ZOOM_RATIO && countForMUDisplay > 2) { + if ('entityScore' in ent[2] && areaZoomRatio > FIELD_MU_DISPLAY_AREA_ZOOM_RATIO && countForMUDisplay > 2) { // centroid of field for placing MU count at var centroid = [ (latlngs[0].lat + latlngs[1].lat + latlngs[2].lat)/3,