From 25fe86b43c56e1a7228bb6555725512d3f5dd656 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 1 Dec 2013 03:31:53 +0000 Subject: [PATCH] plugin: player tracker. something odd was happening in the case of $.each and 'this' in the loop function - so changed to use parameters to functions --- plugins/player-tracker.user.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/player-tracker.user.js b/plugins/player-tracker.user.js index b5fd4be3..efa3b964 100644 --- a/plugins/player-tracker.user.js +++ b/plugins/player-tracker.user.js @@ -250,9 +250,9 @@ window.plugin.playerTracker.getLatLngFromEvent = function(ev) { //TODO? add weight to certain events, or otherwise prefer them, to give better locations? var lats = 0; var lngs = 0; - $.each(ev.latlngs, function() { - lats += this[0]; - lngs += this[1]; + $.each(ev.latlngs, function(i, latlng) { + lats += latlng[0]; + lngs += latlng[1]; }); return L.latLng(lats / ev.latlngs.length, lngs / ev.latlngs.length); @@ -344,15 +344,15 @@ window.plugin.playerTracker.drawData = function() { var eventPortal = [] var closestPortal; var mostPortals = 0; - $.each(last.guids, function() { - if(eventPortal[this]) { - eventPortal[this]++; + $.each(last.guids, function(i, guid) { + if(eventPortal[guid]) { + eventPortal[guid]++; } else { - eventPortal[this] = 1; + eventPortal[guid] = 1; } - if(eventPortal[this] > mostPortals) { - mostPortals = eventPortal[this]; - closestPortal = this; + if(eventPortal[guid] > mostPortals) { + mostPortals = eventPortal[guid]; + closestPortal = guid; } });