From 17a81c09d9680a75cb2d9bee507a811db4feca65 Mon Sep 17 00:00:00 2001 From: Xelio Date: Tue, 26 Feb 2013 17:34:59 +0800 Subject: [PATCH 01/29] New Feature: Remove lower level portal when portal render limit reached --- code/map_data.js | 4 +++- code/utils_misc.js | 60 +++++++++++++++++++++++++++++++++++++++++++++- main.js | 1 + 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/code/map_data.js b/code/map_data.js index 196a975e..3fbddbef 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -70,6 +70,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { // https://github.com/Leaflet/Leaflet/issues/185 var ppp = []; var p2f = {}; + PRL.resetOrInit(); $.each(m, function(qk, val) { $.each(val.deletedGameEntityGuids, function(ind, guid) { if(getTypeByGuid(guid) === TYPE_FIELD && window.fields[guid] !== undefined) { @@ -98,7 +99,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { ) return; - + PRL.pushPortal(ent); ppp.push(ent); // delay portal render } else if(ent[2].edge !== undefined) { renderLink(ent); @@ -147,6 +148,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { if(portalUpdateAvailable) renderPortalDetails(selectedPortal); resolvePlayerNames(); + renderUpdateStatus(); } // removes entities that are still handled by Leaflet, although they diff --git a/code/utils_misc.js b/code/utils_misc.js index 1f640e78..c4e9cdc7 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -2,6 +2,60 @@ // UTILS + MISC /////////////////////////////////////////////////////// +// PRL - Portal Render Limit +window.PRL = function() {} + +window.PRL.resetOrInit = function () { + PRL.initialized = true; + PRL.minLevel = -1; + PRL.minLevelSet = false; + PRL.newPortalsPerLevel = new Array(MAX_PORTAL_LEVEL+1); + for(var i = 0; i <= MAX_PORTAL_LEVEL; i++) { + PRL.newPortalsPerLevel[i] = 0; + } +} + +window.PRL.pushPortal = function(ent) { + var portalGuid = ent[0]; + var portalLevel = parseInt(getPortalLevel(ent[2])); + var layerGroup = portalsLayers[portalLevel]; + + if(findEntityInLeaflet(layerGroup, window.portals, ent[0])) return; + PRL.newPortalsPerLevel[portalLevel]++; +} + +window.PRL.getMinLevel = function() { + if(!PRL.initialized) return -1; + if(!PRL.minLevelSet) PRL.setMinLevel(); + return PRL.minLevel; +} + +window.PRL.setMinLevel = function() { + var totalPortalsCount = 0; + PRL.minLevel = MAX_PORTAL_LEVEL + 1; + + // Find the min portal level under render limit + while(PRL.minLevel > 0) { + var oldPortalCount = layerGroupLength(portalsLayers[PRL.minLevel - 1]); + totalPortalsCount += oldPortalCount + PRL.newPortalsPerLevel[PRL.minLevel - 1]; + if(totalPortalsCount >= MAX_DRAWN_PORTALS) + break; + PRL.minLevel--; + } + + // If render limit reached at max portal level, still let portal at max level render + if(PRL.minLevel === MAX_PORTAL_LEVEL + 1) PRL.minLevel = MAX_PORTAL_LEVEL; + PRL.minLevelSet = true; +} + +window.layerGroupLength = function(layerGroup) { + var layersCount = 0; + var layers = layerGroup._layers; + if (layers) + layersCount = Object.keys(layers).length; + return layersCount; +} + // retrieves parameter from the URL?query=string. window.getURLParam = function(param) { var v = document.URL; @@ -152,7 +206,11 @@ window.getMinPortalLevel = function() { var z = map.getZoom(); if(z >= 16) return 0; var conv = ['impossible', 8,7,7,6,6,5,5,4,4,3,3,2,2,1,1]; - return conv[z]; + var minLevelByRenderLimit = PRL.getMinLevel(); + var result = minLevelByRenderLimit > conv[z] + ? minLevelByRenderLimit + : conv[z]; + return result; } // returns number of pixels left to scroll down before reaching the diff --git a/main.js b/main.js index 4523e8b4..97cf6a52 100644 --- a/main.js +++ b/main.js @@ -186,6 +186,7 @@ window.DESTROY_FIELD = 750; //AP for destroying field window.CAPTURE_PORTAL = 500; //AP for capturing a portal window.DEPLOY_RESONATOR = 125; //AP for deploying a resonator window.COMPLETION_BONUS = 250; //AP for deploying all resonators on portal +window.MAX_PORTAL_LEVEL = 8; // OTHER MORE-OR-LESS CONSTANTS ////////////////////////////////////// window.TEAM_NONE = 0; From 82792cf4be100f60af9f06ce77fc430bd45ff14f Mon Sep 17 00:00:00 2001 From: Xelio Date: Tue, 26 Feb 2013 21:56:30 +0800 Subject: [PATCH 02/29] Bug Fix: minLevel of Portal Render Limit handler now persistent in same batch of request. --- code/map_data.js | 5 ++++- code/utils_misc.js | 25 ++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/code/map_data.js b/code/map_data.js index 3fbddbef..52e6a170 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -43,6 +43,8 @@ window.requestData = function() { } } + // Reset previous result of Portal Render Limit handler + PRL.init(); // finally send ajax requests $.each(tiles, function(ind, tls) { data = { minLevelOfDetail: -1 }; @@ -70,7 +72,8 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { // https://github.com/Leaflet/Leaflet/issues/185 var ppp = []; var p2f = {}; - PRL.resetOrInit(); + // Reset new portals count of Portal Render Limit handler + PRL.resetCounting(); $.each(m, function(qk, val) { $.each(val.deletedGameEntityGuids, function(ind, guid) { if(getTypeByGuid(guid) === TYPE_FIELD && window.fields[guid] !== undefined) { diff --git a/code/utils_misc.js b/code/utils_misc.js index c4e9cdc7..856232fa 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -2,14 +2,19 @@ // UTILS + MISC /////////////////////////////////////////////////////// -// PRL - Portal Render Limit +// PRL - Portal Render Limit handler window.PRL = function() {} -window.PRL.resetOrInit = function () { +window.PRL.init = function () { PRL.initialized = true; PRL.minLevel = -1; + PRL.resetCounting(); +} + +window.PRL.resetCounting = function() { PRL.minLevelSet = false; - PRL.newPortalsPerLevel = new Array(MAX_PORTAL_LEVEL+1); + if(!PRL.newPortalsPerLevel) + PRL.newPortalsPerLevel = new Array(MAX_PORTAL_LEVEL+1); for(var i = 0; i <= MAX_PORTAL_LEVEL; i++) { PRL.newPortalsPerLevel[i] = 0; } @@ -32,19 +37,21 @@ window.PRL.getMinLevel = function() { window.PRL.setMinLevel = function() { var totalPortalsCount = 0; - PRL.minLevel = MAX_PORTAL_LEVEL + 1; + var newMinLevel = MAX_PORTAL_LEVEL + 1; // Find the min portal level under render limit - while(PRL.minLevel > 0) { - var oldPortalCount = layerGroupLength(portalsLayers[PRL.minLevel - 1]); - totalPortalsCount += oldPortalCount + PRL.newPortalsPerLevel[PRL.minLevel - 1]; + while(newMinLevel > 0) { + var oldPortalCount = layerGroupLength(portalsLayers[newMinLevel - 1]); + totalPortalsCount += oldPortalCount + PRL.newPortalsPerLevel[newMinLevel - 1]; if(totalPortalsCount >= MAX_DRAWN_PORTALS) break; - PRL.minLevel--; + newMinLevel--; } // If render limit reached at max portal level, still let portal at max level render - if(PRL.minLevel === MAX_PORTAL_LEVEL + 1) PRL.minLevel = MAX_PORTAL_LEVEL; + if(newMinLevel === MAX_PORTAL_LEVEL + 1) newMinLevel = MAX_PORTAL_LEVEL; + + if(newMinLevel > PRL.minLevel) PRL.minLevel = newMinLevel; PRL.minLevelSet = true; } From f4f3e7791faf90ec1e2203610a0eeafb93bcda87 Mon Sep 17 00:00:00 2001 From: Xelio Date: Wed, 27 Feb 2013 01:14:18 +0800 Subject: [PATCH 03/29] Code restructure of portal render limit handler --- code/map_data.js | 6 +-- code/portal_render_limit.js | 80 +++++++++++++++++++++++++++++++++++++ code/utils_misc.js | 55 +------------------------ 3 files changed, 84 insertions(+), 57 deletions(-) create mode 100644 code/portal_render_limit.js diff --git a/code/map_data.js b/code/map_data.js index 52e6a170..363240c4 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -44,7 +44,7 @@ window.requestData = function() { } // Reset previous result of Portal Render Limit handler - PRL.init(); + portalRenderLimit.init(); // finally send ajax requests $.each(tiles, function(ind, tls) { data = { minLevelOfDetail: -1 }; @@ -73,7 +73,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { var ppp = []; var p2f = {}; // Reset new portals count of Portal Render Limit handler - PRL.resetCounting(); + portalRenderLimit.resetCounting(); $.each(m, function(qk, val) { $.each(val.deletedGameEntityGuids, function(ind, guid) { if(getTypeByGuid(guid) === TYPE_FIELD && window.fields[guid] !== undefined) { @@ -102,7 +102,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { ) return; - PRL.pushPortal(ent); + portalRenderLimit.pushPortal(ent); ppp.push(ent); // delay portal render } else if(ent[2].edge !== undefined) { renderLink(ent); diff --git a/code/portal_render_limit.js b/code/portal_render_limit.js new file mode 100644 index 00000000..58961023 --- /dev/null +++ b/code/portal_render_limit.js @@ -0,0 +1,80 @@ + +// PORTAL RENDER LIMIT HANDLER /////////////////////////////////////// +// Functions to handle hiding low level portal when portal render +// limit is reached. +// +// After initialized and reset in window.requestData(), portals in +// response data will pass to function "pushPortal". Each new portal +// not on the map will add 1 to newPortalsPerLevel[portal level]. +// +// "getMinLevel" will be called by "getMinPortalLevel" in utils_misc.js +// to determine min portal level to draw on map. +// +// "getMinLevel" will return minLevel and call "setMinLevel" if +// minLevel hasn't set yet. +// +// In "setMinLevel", it will loop through all portal level from +// high to low, and sum total portal count (old + new) to check +// minLevel. +// +// In each call of window.handleDataResponse(), it will call +// "resetCounting" to reset previous response data. But minLevel +// is preserved and only replaced when render limit reached in +// higher level, until next window.requestData() called and reset. +// + +window.portalRenderLimit = function() {} + +window.portalRenderLimit.initialized = false; +window.portalRenderLimit.minLevelSet = false; +window.portalRenderLimit.minLevel = -1; +window.portalRenderLimit.newPortalsPerLevel = new Array(MAX_PORTAL_LEVEL + 1); + +window.portalRenderLimit.init = function () { + portalRenderLimit.initialized = true; + portalRenderLimit.minLevel = -1; + portalRenderLimit.resetCounting(); +} + +window.portalRenderLimit.resetCounting = function() { + portalRenderLimit.minLevelSet = false; + for(var i = 0; i <= MAX_PORTAL_LEVEL; i++) { + portalRenderLimit.newPortalsPerLevel[i] = 0; + } +} + +window.portalRenderLimit.pushPortal = function(ent) { + var portalGuid = ent[0]; + var portalLevel = parseInt(getPortalLevel(ent[2])); + var layerGroup = portalsLayers[portalLevel]; + + if(findEntityInLeaflet(layerGroup, window.portals, ent[0])) return; + portalRenderLimit.newPortalsPerLevel[portalLevel]++; +} + +window.portalRenderLimit.getMinLevel = function() { + if(!portalRenderLimit.initialized) return -1; + if(!portalRenderLimit.minLevelSet) portalRenderLimit.setMinLevel(); + return portalRenderLimit.minLevel; +} + +window.portalRenderLimit.setMinLevel = function() { + var totalPortalsCount = 0; + var newMinLevel = MAX_PORTAL_LEVEL + 1; + + // Find the min portal level under render limit + while(newMinLevel > 0) { + var oldPortalCount = layerGroupLength(portalsLayers[newMinLevel - 1]); + var newPortalCount = portalRenderLimit.newPortalsPerLevel[newMinLevel - 1]; + totalPortalsCount += oldPortalCount + newPortalCount; + if(totalPortalsCount >= MAX_DRAWN_PORTALS) + break; + newMinLevel--; + } + + // If render limit reached at max portal level, still let portal at max level render + newMinLevel = Math.min(newMinLevel, MAX_PORTAL_LEVEL); + + portalRenderLimit.minLevel = Math.max(newMinLevel, portalRenderLimit.minLevel); + portalRenderLimit.minLevelSet = true; +} diff --git a/code/utils_misc.js b/code/utils_misc.js index 856232fa..8519a801 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -2,59 +2,6 @@ // UTILS + MISC /////////////////////////////////////////////////////// -// PRL - Portal Render Limit handler -window.PRL = function() {} - -window.PRL.init = function () { - PRL.initialized = true; - PRL.minLevel = -1; - PRL.resetCounting(); -} - -window.PRL.resetCounting = function() { - PRL.minLevelSet = false; - if(!PRL.newPortalsPerLevel) - PRL.newPortalsPerLevel = new Array(MAX_PORTAL_LEVEL+1); - for(var i = 0; i <= MAX_PORTAL_LEVEL; i++) { - PRL.newPortalsPerLevel[i] = 0; - } -} - -window.PRL.pushPortal = function(ent) { - var portalGuid = ent[0]; - var portalLevel = parseInt(getPortalLevel(ent[2])); - var layerGroup = portalsLayers[portalLevel]; - - if(findEntityInLeaflet(layerGroup, window.portals, ent[0])) return; - PRL.newPortalsPerLevel[portalLevel]++; -} - -window.PRL.getMinLevel = function() { - if(!PRL.initialized) return -1; - if(!PRL.minLevelSet) PRL.setMinLevel(); - return PRL.minLevel; -} - -window.PRL.setMinLevel = function() { - var totalPortalsCount = 0; - var newMinLevel = MAX_PORTAL_LEVEL + 1; - - // Find the min portal level under render limit - while(newMinLevel > 0) { - var oldPortalCount = layerGroupLength(portalsLayers[newMinLevel - 1]); - totalPortalsCount += oldPortalCount + PRL.newPortalsPerLevel[newMinLevel - 1]; - if(totalPortalsCount >= MAX_DRAWN_PORTALS) - break; - newMinLevel--; - } - - // If render limit reached at max portal level, still let portal at max level render - if(newMinLevel === MAX_PORTAL_LEVEL + 1) newMinLevel = MAX_PORTAL_LEVEL; - - if(newMinLevel > PRL.minLevel) PRL.minLevel = newMinLevel; - PRL.minLevelSet = true; -} - window.layerGroupLength = function(layerGroup) { var layersCount = 0; var layers = layerGroup._layers; @@ -213,7 +160,7 @@ window.getMinPortalLevel = function() { var z = map.getZoom(); if(z >= 16) return 0; var conv = ['impossible', 8,7,7,6,6,5,5,4,4,3,3,2,2,1,1]; - var minLevelByRenderLimit = PRL.getMinLevel(); + var minLevelByRenderLimit = portalRenderLimit.getMinLevel(); var result = minLevelByRenderLimit > conv[z] ? minLevelByRenderLimit : conv[z]; From 8fa4b096defffe70a29c71abee06b56d53279bda Mon Sep 17 00:00:00 2001 From: Waynn Lue Date: Tue, 26 Feb 2013 17:28:04 -0800 Subject: [PATCH 04/29] edits to have consistent periods and some phrasing changes --- USERGUIDE.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/USERGUIDE.md b/USERGUIDE.md index 089d78b5..4b0ee036 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -21,8 +21,8 @@ General Usage ------------- - many things have more information in tooltips. Let your cursor rest over stuff to show the tooltip. *Hint:* your cursor changes into a question mark / help cursor if there’s a tooltip available. -- single left click on portals to show details -- double left click on portals to zoom in to them +- single left click on portals to show details. +- double left click on portals to zoom in to them. Chat @@ -37,7 +37,7 @@ The chat is split up into several categories. It usually only shows messages for - faction: shows messages for own faction (e.g. only Resistance can read Resistance messages) **Posting messages:** -- You can post in the faction and public categories only +- You can post in the faction and public categories only. - Your message will be tagged with the coordinates in the center of the map. - Your zoom level does not matter. Zooming out will not show your messages to more users. @@ -62,7 +62,7 @@ Resonators are shown at their actual positions if you zoom in close enough. They They are handled the same way portals are, see above. **Other:** -When you select a portal its outer ring becomes red. There’s also a small yellow circle around it which depicts the hack range. You need to be in hack range to hack the portal or update its resonators or mods. +When you select a portal its outer ring becomes red. There’s also a small yellow circle around it which depicts the hack range. You need to be in hack range to hack the portal or upgrade its resonators or mods. If you are zoomed out quite a bit, there’s a larger red circle. This is the link range. Only portals within this link range can be linked while standing at the selected portal. [Click the range in the sidebar to zoom to link range for the selected portal](#random-details). @@ -72,11 +72,11 @@ If you are zoomed out quite a bit, there’s a larger red circle. This is the li Map Status / Updates -------------------- -It shows if there are currently operations pending. This includes chat updates as well as map data requests. Updates happen every 45s to 90s, depending on how far zoomed in you are. Zoom in closer for faster updates. +It shows if there are operations currently pending. This includes chat updates as well as map data requests. Updates happen every 45s to 90s, depending on how far zoomed in you are. Zoom in closer for faster updates. It also shows which portals are being loaded/shown. Zoom in to see lower level portals. This is a limit of the server and not IITC. Portals levels that cannot be shown are also striked through in the layer chooser. -**Failures:** If a data request failed, it is retried once. Only if the retry fails as well, a “failure” message is shown in the map status. You can either wait for the next automatic update or move the map a little. Also try to zoom in to request less data, which makes it less likely that the servers fail. The failure counter is reset on the next auto update or if you move the map. +**Failures:** If a data request failed, it is retried once. If the retry fails as well, a “failure” message is shown in the map status. You can either wait for the next automatic update or move the map a little. Also try to zoom in to request less data, which makes it less likely that the servers fail. The failure counter is reset on the next auto update or if you move the map. **Render Limit:** The script tries to stay responsive. If too much data needs to be rendered, this cannot be guaranteed. Instead it will simply stop drawing portals/links/fields and show “render limit” in the map status. Zoom in to solve this. @@ -88,11 +88,11 @@ Sidebar The sidebar is mainly used to show game stats and portal details. However, it also allows you to perform certain actions. ### General usage: -- single click a portal to show details about it in the sidebar +- single click a portal to show details about it in the sidebar. - the portal information is updated automatically, as long as the selected portal is kept in view and you do not zoom out too much. - the sidebar may be collapsed. Click the triangle button that stands out at the left hand side. - the sidebar **can be scrolled** if your screen is too small. Use your scroll wheel. -- almost anything has tooltips. See [General usage](#general-usage) above. +- almost everything has tooltips. See [General usage](#general-usage) above. ### Details: Starting from the top, the sidebar shows this information: From 07cb3c2f4937826e6d27a3faef91d9a61719b7ee Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Wed, 27 Feb 2013 10:14:55 +0800 Subject: [PATCH 05/29] Add href link in chat msg --- code/chat.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/chat.js b/code/chat.js index a95b56ad..6faea140 100644 --- a/code/chat.js +++ b/code/chat.js @@ -279,8 +279,14 @@ window.chat.writeDataToHash = function(newData, storageHash, skipSecureMsgs) { case 'PORTAL': var latlng = [markup[1].latE6/1E6, markup[1].lngE6/1E6]; - var js = 'window.zoomToAndShowPortal(\''+markup[1].guid+'\', ['+latlng[0]+', '+latlng[1]+'])'; - msg += ''+markup[1].name+''; + var perma = 'https://ingress.com/intel?latE6='+markup[1].latE6+'&lngE6='+markup[1].lngE6+'&z=17&pguid='+markup[1].guid; + var js = 'window.zoomToAndShowPortal(\''+markup[1].guid+'\', ['+latlng[0]+', '+latlng[1]+']);return false'; + + msg += '' + + markup[1].name + + ''; break; case 'SECURE': From 68e666c50e6680a833454fa03cda01a9d3f77e49 Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Wed, 27 Feb 2013 14:42:27 +0800 Subject: [PATCH 06/29] Use https in permalink --- code/portal_detail_display.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index c47a4eee..c3be0a8a 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -50,7 +50,7 @@ window.renderPortalDetails = function(guid) { var lat = d.locationE6.latE6; var lng = d.locationE6.lngE6; - var perma = 'http://ingress.com/intel?latE6='+lat+'&lngE6='+lng+'&z=17&pguid='+guid; + var perma = 'https://ingress.com/intel?latE6='+lat+'&lngE6='+lng+'&z=17&pguid='+guid; var imgTitle = 'title="'+getPortalDescriptionFromDetails(d)+'\n\nClick to show full image."'; var poslinks = 'window.showPortalPosLinks('+lat/1E6+','+lng/1E6+')'; var postcard = 'Send in a postcard. Will put it online after receiving. Address:\\n\\nStefan Breunig\\nINF 305 – R045\\n69120 Heidelberg\\nGermany'; From e8c5af74d8d72f3f321a574d6c0d10ec2129503b Mon Sep 17 00:00:00 2001 From: Waynn Lue Date: Tue, 26 Feb 2013 23:00:43 -0800 Subject: [PATCH 07/29] change back to "Only if" --- USERGUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USERGUIDE.md b/USERGUIDE.md index 4b0ee036..7810daec 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -76,7 +76,7 @@ It shows if there are operations currently pending. This includes chat updates a It also shows which portals are being loaded/shown. Zoom in to see lower level portals. This is a limit of the server and not IITC. Portals levels that cannot be shown are also striked through in the layer chooser. -**Failures:** If a data request failed, it is retried once. If the retry fails as well, a “failure” message is shown in the map status. You can either wait for the next automatic update or move the map a little. Also try to zoom in to request less data, which makes it less likely that the servers fail. The failure counter is reset on the next auto update or if you move the map. +**Failures:** If a data request failed, it is retried once. Only if the retry fails as well, a “failure” message is shown in the map status. You can either wait for the next automatic update or move the map a little. Also try to zoom in to request less data, which makes it less likely that the servers fail. The failure counter is reset on the next auto update or if you move the map. **Render Limit:** The script tries to stay responsive. If too much data needs to be rendered, this cannot be guaranteed. Instead it will simply stop drawing portals/links/fields and show “render limit” in the map status. Zoom in to solve this. From 42e8af1c36eb810fef1ce6e608a1535422e4ed44 Mon Sep 17 00:00:00 2001 From: Waynn Lue Date: Wed, 27 Feb 2013 14:29:06 -0800 Subject: [PATCH 08/29] add waynn as contributor --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8bd6ebb4..4cb66b4e 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,8 @@ First of all, it’s very nice you want to help. There are several equally impor [tpenner](https://github.com/tpenner), [vita10gy](https://github.com/vita10gy), [Xelio](https://github.com/Xelio), -[ZauberNerd](https://github.com/ZauberNerd) +[ZauberNerd](https://github.com/ZauberNerd), +[waynn](https://github.com/waynn) Attribution & License From c75caa91dd0f89bf520e8640eb6b54beb8698f55 Mon Sep 17 00:00:00 2001 From: Xelio Date: Thu, 28 Feb 2013 14:40:35 +0800 Subject: [PATCH 09/29] Fix flicker portal in portal render limit handler Change: Extract portal handle process from "handleDataResponse" to "handlePortalData" Add "action" property to object returned by $.ajax() to identity type of request Delay low level portal render until no active request of map data. --- code/map_data.js | 33 ++++++++----- code/portal_render_limit.js | 93 +++++++++++++++++++++++++++++++++++-- code/utils_misc.js | 4 +- 3 files changed, 113 insertions(+), 17 deletions(-) diff --git a/code/map_data.js b/code/map_data.js index 363240c4..300be338 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -49,7 +49,7 @@ window.requestData = function() { $.each(tiles, function(ind, tls) { data = { minLevelOfDetail: -1 }; data.boundsParamsList = tls; - window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse)); + window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, portalRenderLimit.handleFailRequest)); }); } @@ -59,11 +59,10 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { if(!data || !data.result) { window.failedRequestCount++; console.warn(data); + portalRenderLimit.handleFailRequest(); return; } - var portalUpdateAvailable = false; - var portalInUrlAvailable = false; var m = data.result.map; // 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 @@ -72,8 +71,6 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { // https://github.com/Leaflet/Leaflet/issues/185 var ppp = []; var p2f = {}; - // Reset new portals count of Portal Render Limit handler - portalRenderLimit.resetCounting(); $.each(m, function(qk, val) { $.each(val.deletedGameEntityGuids, function(ind, guid) { if(getTypeByGuid(guid) === TYPE_FIELD && window.fields[guid] !== undefined) { @@ -92,8 +89,6 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { // format for portals: { controllingTeam, turret } if(ent[2].turret !== undefined) { - 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) @@ -102,7 +97,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { ) return; - portalRenderLimit.pushPortal(ent); + ppp.push(ent); // delay portal render } else if(ent[2].edge !== undefined) { renderLink(ent); @@ -118,7 +113,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { } }); }); - + $.each(ppp, function(ind, portal) { if(portal[2].portalV2['linkedFields'] === undefined) { portal[2].portalV2['linkedFields'] = []; @@ -128,12 +123,28 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { portal[2].portalV2['linkedFields'] = uniqueArray(p2f[portal[0]]); } }); + + // Process the portals with portal render limit handler first + ppp = portalRenderLimit.processPortals(ppp); + handlePortalData(ppp); + + resolvePlayerNames(); + renderUpdateStatus(); +} + +window.handlePortalData = function(ppp) { + var portalUpdateAvailable = false; + var portalInUrlAvailable = false; // Preserve and restore "selectedPortal" between portal re-render if(portalUpdateAvailable) var oldSelectedPortal = selectedPortal; runHooks('portalDataLoaded', {portals : ppp}); - $.each(ppp, function(ind, portal) { renderPortal(portal); }); + $.each(ppp, function(ind, portal) { + if(selectedPortal === portal[0]) portalUpdateAvailable = true; + if(urlPortal && portal[0] == urlPortal) portalInUrlAvailable = true; + renderPortal(portal); + }); var selectedPortalLayer = portals[oldSelectedPortal]; if(portalUpdateAvailable && selectedPortalLayer) selectedPortal = oldSelectedPortal; @@ -150,8 +161,6 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { } if(portalUpdateAvailable) renderPortalDetails(selectedPortal); - resolvePlayerNames(); - renderUpdateStatus(); } // removes entities that are still handled by Leaflet, although they diff --git a/code/portal_render_limit.js b/code/portal_render_limit.js index 58961023..f80bd7b9 100644 --- a/code/portal_render_limit.js +++ b/code/portal_render_limit.js @@ -3,9 +3,22 @@ // Functions to handle hiding low level portal when portal render // limit is reached. // -// After initialized and reset in window.requestData(), portals in -// response data will pass to function "pushPortal". Each new portal -// not on the map will add 1 to newPortalsPerLevel[portal level]. +// On initialization, previous minLevel will preserve to previousMinLevel +// with zoom level difference. +// +// After initialized and reset in window.requestData(), "processPortals" +// intercept all portals data in "handleDataResponse". Put the count of +// new portals to newPortalsPerLevel[portal level]. And split portals +// into two parts base on previousMinLevel. Portals with level >= +// previousMinLevel will return as result and continue to render. +// Others will save to portalsPreviousMinLevel. If there is no more +// active request of map data, portals will not split and +// portalsPreviousMinLevel will add back to result and render base on +// current minLevel. +// +// "handleFailRequest" is added to handle the case when the last request +// failed and "processPortals" didn't get called. It will get +// portalsPreviousMinLevel base on current minLevel and render them. // // "getMinLevel" will be called by "getMinPortalLevel" in utils_misc.js // to determine min portal level to draw on map. @@ -28,12 +41,25 @@ window.portalRenderLimit = function() {} window.portalRenderLimit.initialized = false; window.portalRenderLimit.minLevelSet = false; window.portalRenderLimit.minLevel = -1; +window.portalRenderLimit.previousMinLevel = -1; +window.portalRenderLimit.previousZoomLevel; window.portalRenderLimit.newPortalsPerLevel = new Array(MAX_PORTAL_LEVEL + 1); +window.portalRenderLimit.portalsPreviousMinLevel = new Array(MAX_PORTAL_LEVEL + 1); window.portalRenderLimit.init = function () { + var currentZoomLevel = map.getZoom(); + if(!portalRenderLimit.previousZoomLevel) portalRenderLimit.previousZoomLevel = currentZoomLevel; + if(portalRenderLimit.minLevelSet) { + var zoomDiff = currentZoomLevel - portalRenderLimit.previousZoomLevel; + portalRenderLimit.previousMinLevel = Math.max(portalRenderLimit.minLevel - zoomDiff, -1); + portalRenderLimit.previousMinLevel = Math.min(portalRenderLimit.previousMinLevel, MAX_PORTAL_LEVEL); + } + portalRenderLimit.previousZoomLevel = currentZoomLevel; + portalRenderLimit.initialized = true; portalRenderLimit.minLevel = -1; portalRenderLimit.resetCounting(); + portalRenderLimit.resetPortalsPreviousMinLevel(); } window.portalRenderLimit.resetCounting = function() { @@ -43,7 +69,45 @@ window.portalRenderLimit.resetCounting = function() { } } -window.portalRenderLimit.pushPortal = function(ent) { +window.portalRenderLimit.resetPortalsPreviousMinLevel = function() { + for(var i = 0; i <= MAX_PORTAL_LEVEL; i++) { + portalRenderLimit.portalsPreviousMinLevel[i] = new Array(); + } +} + +window.portalRenderLimit.processPortals = function(ppp) { + portalRenderLimit.resetCounting(); + var resultPortals = new Array(); + + $.each(ppp, function(ind, portal) { + portalRenderLimit.countPortal(portal); + + if(!portalRenderLimit.isLastRequest()) { + var portalLevel = parseInt(getPortalLevel(portal[2])); + if(portalLevel < portalRenderLimit.previousMinLevel) { + portalRenderLimit.portalsPreviousMinLevel[portalLevel].push(portal); + }else{ + resultPortals.push(portal); + } + } + }); + + if(portalRenderLimit.isLastRequest()) { + resultPortals = portalRenderLimit.getLowLevelPortals(ppp); + portalRenderLimit.resetPortalsPreviousMinLevel(); + } + return resultPortals; +} + +window.portalRenderLimit.handleFailRequest = function() { + if(portalRenderLimit.isLastRequest()) { + var ppp = portalRenderLimit.getLowLevelPortals(null); + portalRenderLimit.resetPortalsPreviousMinLevel(); + handlePortalData(ppp); + } +} + +window.portalRenderLimit.countPortal = function(ent) { var portalGuid = ent[0]; var portalLevel = parseInt(getPortalLevel(ent[2])); var layerGroup = portalsLayers[portalLevel]; @@ -52,6 +116,27 @@ window.portalRenderLimit.pushPortal = function(ent) { portalRenderLimit.newPortalsPerLevel[portalLevel]++; } +window.portalRenderLimit.getLowLevelPortals = function(appendTo) { + var resultPortals = appendTo ? appendTo : new Array(); + for(var i = portalRenderLimit.getMinLevel(); + i < portalRenderLimit.previousMinLevel; + i++) { + $.merge(resultPortals, portalRenderLimit.portalsPreviousMinLevel[i]); + } + return resultPortals; +} + +window.portalRenderLimit.isLastRequest = function() { + var result = true; + $.each(window.activeRequests, function(ind, req) { + if(req.action === 'getThinnedEntitiesV2') { + result = false; + return false; + } + }); + return result; +} + window.portalRenderLimit.getMinLevel = function() { if(!portalRenderLimit.initialized) return -1; if(!portalRenderLimit.minLevelSet) portalRenderLimit.setMinLevel(); diff --git a/code/utils_misc.js b/code/utils_misc.js index 1e5e0a87..451d565e 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -58,7 +58,7 @@ window.postAjax = function(action, data, success, error) { data = JSON.stringify($.extend({method: 'dashboard.'+action}, data)); var remove = function(data, textStatus, jqXHR) { window.requests.remove(jqXHR); }; var errCnt = function(jqXHR) { window.failedRequestCount++; window.requests.remove(jqXHR); }; - return $.ajax({ + var result = $.ajax({ // use full URL to avoid issues depending on how people set their // slash. See: // https://github.com/breunigs/ingress-intel-total-conversion/issues/56 @@ -73,6 +73,8 @@ window.postAjax = function(action, data, success, error) { req.setRequestHeader('X-CSRFToken', readCookie('csrftoken')); } }); + result.action = action; + return result; } // converts unix timestamps to HH:mm:ss format if it was today; From 22491157f9c4e0307b5d4eacb5219f6296b7ee0c Mon Sep 17 00:00:00 2001 From: winkelement Date: Thu, 28 Feb 2013 20:46:20 +0100 Subject: [PATCH 10/29] Update README.md Update Information about Tampermonkey auto update not working due to TM stable release which fixes that. --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 4cb66b4e..0aa40d4b 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,7 @@ Current version is 0.7.8. [See NEWS.md for details](https://github.com/breunigs/ - Confirm once again. - Reload page. -**NOTE: You still need to manually update IITC with Tampermonkey.** There is a bug in the current stable release. It has been fixed in Tampermonkey’s development version. Until it is released, you need to manually update IITC. - -*Note:* Tampermonkey is optional. However, it ~~offers auto-update~~, shows correct version numbers and installing user scripts is much easier. If you have installed the scripts directly into Chrome before, I recommend you switch to Tampermonkey. To do so, uninstall the IITC scripts and click each install link again. Follow the procedure explained above. +*Note:* Tampermonkey is optional. However, it offers auto-update, shows correct version numbers and installing user scripts is much easier. If you have installed the scripts directly into Chrome before, I recommend you switch to Tampermonkey. To do so, uninstall the IITC scripts and click each install link again. Follow the procedure explained above. ### Opera - Download the script: [download](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/total-conversion-build.user.js) From 573562dffd7bac30a757496b4bc996f6538aeafb Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Thu, 28 Feb 2013 22:03:12 +0100 Subject: [PATCH 11/29] undo always using https for the portal image because some images are taken from panoramio which do not support https properly --- code/portal_detail_display.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index c47a4eee..7ef28a6b 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -45,7 +45,7 @@ window.renderPortalDetails = function(guid) { setPortalIndicators(d); var img = d.imageByUrl && d.imageByUrl.imageUrl - ? d.imageByUrl.imageUrl.replace(/^http:/, 'https:') + ? d.imageByUrl.imageUrl : DEFAULT_PORTAL_IMG; var lat = d.locationE6.latE6; From 6a2603d56609e022447bddc16674dc08be856f29 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Thu, 28 Feb 2013 23:49:21 +0100 Subject: [PATCH 12/29] allow quickly (de)selecting all layers by shift/ctrl/alt/meta clicking an entry in the layer chooser (fixes #232) --- USERGUIDE.md | 5 ++++- code/boot.js | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/USERGUIDE.md b/USERGUIDE.md index 7810daec..cb5497d1 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -45,7 +45,10 @@ The chat is split up into several categories. It usually only shows messages for Map Display ----------- -You can customize many aspects of how the map is rendered in the layer chooser. The layer chooser is available from the icon in the top right corner, left of the sidebar. +You can customize many aspects of how the map is rendered in the layer chooser. + +**Layer Chooser:** +The layer chooser is available from the icon in the top right corner, left of the sidebar. The top entries are background maps and you can only have one of them active at a time. The entries on the bottom can be displayed in any combination you like. *Hint:* Modifier-click an entry to quickly hide all other layers. The modifier may be either of these: shift, ctrl, alt, meta. Modifier-click the entry again to select all layers. **Background / Street Map / Base Layer:** All these refer to the same thing. The base layer is stored across sessions. The default one uses OpenStreetMap data with a style that resembles the default Ingress one. There are other styles available. diff --git a/code/boot.js b/code/boot.js index d75d1914..fcb76729 100644 --- a/code/boot.js +++ b/code/boot.js @@ -23,6 +23,25 @@ window.setupLargeImagePreview = function() { }); } +// adds listeners to the layer chooser such that a long press hides +// all custom layers except the long pressed one. +window.setupLayerChooserSelectOne = function() { + $('.leaflet-control-layers-overlays').on('click', 'label', function(e) { + if(!e || !(e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)) return; + + var isChecked = $(this).find('input').is(':checked'); + var checkSize = $('.leaflet-control-layers-overlays input:checked').length; + if((isChecked && checkSize === 1) || checkSize === 0) { + // if nothing is selected or the users long-clicks the only + // selected element, assume all boxes should be checked again + $('.leaflet-control-layers-overlays input:not(:checked)').click(); + } else { + // uncheck all + $('.leaflet-control-layers-overlays input:checked').click(); + $(this).find('input').click(); + } + }); +} window.setupStyles = function() { $('head').append('