remove array with portal details references that might have been leaking. Instead, store the details with the rendered portals so removal is handled automatically
This commit is contained in:
@ -55,11 +55,13 @@ window.requestData = function() {
|
|||||||
window.handleDataResponse = function(data, textStatus, jqXHR) {
|
window.handleDataResponse = function(data, textStatus, jqXHR) {
|
||||||
// remove from active ajax queries list
|
// remove from active ajax queries list
|
||||||
if(!data || !data.result) {
|
if(!data || !data.result) {
|
||||||
|
window.failedRequestCount++;
|
||||||
console.warn(data);
|
console.warn(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var portalUpdateAvailable = false;
|
var portalUpdateAvailable = false;
|
||||||
|
var portalInUrlAvailable = false;
|
||||||
var m = data.result.map;
|
var m = data.result.map;
|
||||||
// defer rendering of portals because there is no z-index in SVG.
|
// defer rendering of portals because there is no z-index in SVG.
|
||||||
// this means that what’s rendered last ends up on top. While the
|
// this means that what’s rendered last ends up on top. While the
|
||||||
@ -79,15 +81,16 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
|
|||||||
|
|
||||||
if(ent[2].turret !== undefined) {
|
if(ent[2].turret !== undefined) {
|
||||||
if(selectedPortal == ent[0]) portalUpdateAvailable = true;
|
if(selectedPortal == ent[0]) portalUpdateAvailable = true;
|
||||||
|
if(urlPortal && ent[0] == urlPortal) portalInUrlAvailable = true;
|
||||||
|
|
||||||
|
var latlng = [ent[2].locationE6.latE6/1E6, ent[2].locationE6.lngE6/1E6];
|
||||||
|
if(!window.getPaddedBounds().contains(latlng)
|
||||||
|
&& selectedPortal != ent[0]
|
||||||
|
&& urlPortal != ent[0]
|
||||||
|
) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
portalsDetail[ent[0]] = ent[2];
|
|
||||||
// immediately render portal details if selected by URL.
|
|
||||||
// is also used internally to select a portal that may not have
|
|
||||||
// been loaded yet. See utils_misc#zoomToAndShowPortal.
|
|
||||||
if(urlPortal && ent[0] == urlPortal && !selectedPortal) {
|
|
||||||
urlPortal = null; // only pre-select it once
|
|
||||||
window.renderPortalDetails(ent[0]);
|
|
||||||
}
|
|
||||||
ppp.push(ent); // delay portal render
|
ppp.push(ent); // delay portal render
|
||||||
} else if(ent[2].edge !== undefined)
|
} else if(ent[2].edge !== undefined)
|
||||||
renderLink(ent);
|
renderLink(ent);
|
||||||
@ -99,9 +102,13 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.each(ppp, function(ind, portal) { renderPortal(portal); });
|
$.each(ppp, function(ind, portal) { renderPortal(portal); });
|
||||||
|
|
||||||
if(portals[selectedPortal]) portals[selectedPortal].bringToFront();
|
if(portals[selectedPortal]) portals[selectedPortal].bringToFront();
|
||||||
|
|
||||||
|
if(portalInUrlAvailable) {
|
||||||
|
renderPortalDetails(urlPortal);
|
||||||
|
urlPortal = null; // select it only once
|
||||||
|
}
|
||||||
|
|
||||||
if(portalUpdateAvailable) renderPortalDetails(selectedPortal);
|
if(portalUpdateAvailable) renderPortalDetails(selectedPortal);
|
||||||
resolvePlayerNames();
|
resolvePlayerNames();
|
||||||
}
|
}
|
||||||
@ -172,7 +179,9 @@ window.renderPortal = function(ent) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var latlng = [ent[2].locationE6.latE6/1E6, ent[2].locationE6.lngE6/1E6];
|
var latlng = [ent[2].locationE6.latE6/1E6, ent[2].locationE6.lngE6/1E6];
|
||||||
if(!getPaddedBounds().contains(latlng)) return;
|
// needs to be checked before, so the portal isn’t added to the
|
||||||
|
// details list and other places
|
||||||
|
//if(!getPaddedBounds().contains(latlng)) return;
|
||||||
|
|
||||||
// hide low level portals on low zooms
|
// hide low level portals on low zooms
|
||||||
var portalLevel = getPortalLevel(ent[2]);
|
var portalLevel = getPortalLevel(ent[2]);
|
||||||
@ -199,6 +208,7 @@ window.renderPortal = function(ent) {
|
|||||||
fillOpacity: 0.5,
|
fillOpacity: 0.5,
|
||||||
clickable: true,
|
clickable: true,
|
||||||
level: portalLevel,
|
level: portalLevel,
|
||||||
|
details: ent[2],
|
||||||
guid: ent[0]});
|
guid: ent[0]});
|
||||||
|
|
||||||
p.on('remove', function() { delete window.portals[this.options.guid]; });
|
p.on('remove', function() { delete window.portals[this.options.guid]; });
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// methods that highlight the portal in the map view.
|
// methods that highlight the portal in the map view.
|
||||||
|
|
||||||
window.renderPortalDetails = function(guid) {
|
window.renderPortalDetails = function(guid) {
|
||||||
var d = portalsDetail[guid];
|
var d = window.portals[guid].options.details;
|
||||||
if(!d) {
|
if(!d) {
|
||||||
unselectOldPortal();
|
unselectOldPortal();
|
||||||
urlPortal = guid;
|
urlPortal = guid;
|
||||||
|
@ -40,7 +40,7 @@ window.renderUpdateStatus = function() {
|
|||||||
if(mapRunsUserAction)
|
if(mapRunsUserAction)
|
||||||
t += 'paused during interaction';
|
t += 'paused during interaction';
|
||||||
else if(isIdle())
|
else if(isIdle())
|
||||||
t += 'Idle, not updating.';
|
t += '<span style="color:red">Idle, not updating.</span>';
|
||||||
else if(window.activeRequests.length > 0)
|
else if(window.activeRequests.length > 0)
|
||||||
t += window.activeRequests.length + ' requests running.';
|
t += window.activeRequests.length + ' requests running.';
|
||||||
else
|
else
|
||||||
|
1
main.js
1
main.js
@ -145,7 +145,6 @@ window.portalRangeIndicator = null;
|
|||||||
window.portalAccessIndicator = null;
|
window.portalAccessIndicator = null;
|
||||||
window.mapRunsUserAction = false;
|
window.mapRunsUserAction = false;
|
||||||
var portalsLayer, linksLayer, fieldsLayer;
|
var portalsLayer, linksLayer, fieldsLayer;
|
||||||
var portalsDetail = {};
|
|
||||||
|
|
||||||
// contain references to all entities shown on the map. These are
|
// contain references to all entities shown on the map. These are
|
||||||
// automatically kept in sync with the items on *sLayer, so never ever
|
// automatically kept in sync with the items on *sLayer, so never ever
|
||||||
|
Reference in New Issue
Block a user