From c9e27018909466ddc505471dd7b55d711e15f66d Mon Sep 17 00:00:00 2001 From: Jakub Ludwig Date: Sat, 9 Feb 2013 11:10:53 +0100 Subject: [PATCH 01/16] AP for destroying portal Calculate AP gained from destroyed resonators + link TODO: fields :) --- code/portal_detail_display.js | 1 + code/portal_detail_display_tools.js | 22 ++++++++++++++++++++++ main.js | 2 ++ 3 files changed, 25 insertions(+) diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index 2187b34b..d9d308d9 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -66,6 +66,7 @@ window.renderPortalDetails = function(guid) { + '
'+getModDetails(d)+'
' + '
'+randDetails+'
' + '
'+getResonatorDetails(d)+'
' + + '
'+getDestroyAP(d)+'
' + '
' + '' + '' diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index b02d40be..42cf0c95 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -131,3 +131,25 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick) { var text = ''+(nick||'')+''; return (slot <= 3 ? text+meter : meter+text) + '
'; } + +// calculate AP gain from destroying portal +// so far it counts only resonators + links +window.getDestroyAP = function(d) { + console.log('rendering destroy AP'); + var res_count = 0; + var links = 0; + + $.each(d.resonatorArray.resonators, function(ind, reso) + { + res_count += 1; + }); + + if(d.portalV2.linkedEdges) $.each(d.portalV2.linkedEdges, function(ind, link) + { + links++; + }); + + var ap_count = (res_count * DESTROY_RESONATOR) + (links * DESTROY_LINK); + + return 'Destroy ' + res_count + 'x res + ' + links + 'x link -> ' + ap_count + 'AP'; +} diff --git a/main.js b/main.js index f34165eb..b99017df 100644 --- a/main.js +++ b/main.js @@ -128,6 +128,8 @@ var MIN_AP_FOR_LEVEL = [0, 10000, 30000, 70000, 150000, 300000, 600000, 1200000] var HACK_RANGE = 35; // in meters, max. distance from portal to be able to access it var OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE']; var DEFAULT_PORTAL_IMG = 'http://commondatastorage.googleapis.com/ingress/img/default-portal-image.png'; +var DESTROY_RESONATOR = 75; //AP for destroying portal +var DESTROY_LINK = 187; //AP fro destroying link // OTHER MORE-OR-LESS CONSTANTS ////////////////////////////////////// var NOMINATIM = 'http://nominatim.openstreetmap.org/search?format=json&limit=1&q='; From 74be29ea29142d232fda2affe5bc84df20c78a2d Mon Sep 17 00:00:00 2001 From: Cameron Moon Date: Mon, 11 Feb 2013 12:25:47 +1100 Subject: [PATCH 02/16] Made the sidebar transparent like the chat box --- code/boot.js | 13 ++++++------- style.css | 23 ++++++++++------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/code/boot.js b/code/boot.js index b4d927ba..246d6c1f 100644 --- a/code/boot.js +++ b/code/boot.js @@ -27,14 +27,14 @@ window.setupLargeImagePreview = function() { window.setupStyles = function() { $('head').append(''); } diff --git a/code/request_handling.js b/code/request_handling.js index 60aa00f6..042fc397 100644 --- a/code/request_handling.js +++ b/code/request_handling.js @@ -50,7 +50,7 @@ window.renderUpdateStatus = function() { t += ' RENDER LIMIT ' if(window.failedRequestCount > 0) - t += ' ' + window.failedRequestCount + ' requests failed.' + t += ' ' + window.failedRequestCount + ' failed.' t += '
('; var minlvl = getMinPortalLevel(); diff --git a/main.js b/main.js index 6f722903..a9242ec3 100644 --- a/main.js +++ b/main.js @@ -49,14 +49,13 @@ for(var i = 0; i < d.length; i++) { // player information is now available in a hash like this: // window.PLAYER = {"ap": "123", "energy": 123, "available_invites": 123, "nickname": "somenick", "team": "ALIENS||RESISTANCE"}; - // remove complete page. We only wanted the user-data and the page’s // security context so we can access the API easily. Setup as much as // possible without requiring scripts. document.getElementsByTagName('head')[0].innerHTML = '' - //~ + '' + + '' + 'Ingress Intel Map' - + '' + //~ + '' + '' + ''; @@ -81,9 +80,9 @@ document.getElementsByTagName('body')[0].innerHTML = '' + ' ' + ' ' + '
' - + '
' - + '
'; - + ''; + + ' ' + + '' + + '
'; // putting everything in a wrapper function that in turn is placed in a // script tag on the website allows us to execute in the site’s context diff --git a/style.css b/style.css index 3f79011c..f23b7799 100644 --- a/style.css +++ b/style.css @@ -11,22 +11,22 @@ body { } #scrollwrapper { - height: 100%; overflow: hidden; position: fixed; right: -38px; top: 0; width: 340px; + bottom: 45px; } #sidebar { background-color: rgba(8, 48, 78, 0.9); border-left: 1px solid #20A8B1; color: #888; - height: 100%; position: relative; left: 0; top: 0; + max-height: 100%; overflow-y:scroll; overflow-x:hidden; z-index: 3000; @@ -523,16 +523,14 @@ aside:nth-child(odd) span { } #spacer { - /* cheap hack to prevent sidebar content being overlayed by the map - * status box */ - height: 55px; + height: 10px; } /* a common portal display takes this much space (prevents moving * content when first selecting a portal) */ #portaldetails { - min-height: 532px; + min-height: 553px; } @@ -541,12 +539,14 @@ aside:nth-child(odd) span { background-color: rgba(8, 48, 78, 1); border-bottom: 0; border-top: 1px solid #20A8B1; + border-left: 1px solid #20A8B1; bottom: 0; color: #ffce00; font-size:13px; padding: 4px; position: fixed; right: 0; + z-index:3002; } From c170995da704b0804bbe15d6d07e025824a84fc1 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Mon, 11 Feb 2013 12:36:14 +0100 Subject: [PATCH 09/16] fix style sheet link (thanks cmrn) --- main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index a9242ec3..0a229350 100644 --- a/main.js +++ b/main.js @@ -53,9 +53,9 @@ for(var i = 0; i < d.length; i++) { // security context so we can access the API easily. Setup as much as // possible without requiring scripts. document.getElementsByTagName('head')[0].innerHTML = '' - + '' + //~ + '' + 'Ingress Intel Map' - //~ + '' + + '' + '' + ''; From 63083407ed3704f3e77ea6a06efcd22b331400b3 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Mon, 11 Feb 2013 13:14:03 +0100 Subject: [PATCH 10/16] add info about other types --- code/utils_misc.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/utils_misc.js b/code/utils_misc.js index 2f982f7e..75cd1d72 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -160,6 +160,10 @@ window.getTypeByGuid = function(guid) { // .c == player/creator // .d == chat messages // + // others, not used in web: + // .5 == resources (burster/resonator) + // .6 == XM + // .4 == media items, maybe all droppped resources (?) // resonator guid is [portal guid]-resonator-[slot] switch(guid.slice(33)) { case '11': From 8b94121bb25aa1a974a9b6efbd9ba7fce4258d1e Mon Sep 17 00:00:00 2001 From: Peter Sorger Date: Mon, 11 Feb 2013 13:48:05 +0100 Subject: [PATCH 11/16] z-index for #scrollwallpaper had problem with sidebar not showing in Chrome 25, the sidebar got under the map layer. Added z-index 1001; --- style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/style.css b/style.css index f23b7799..ebe3d41d 100644 --- a/style.css +++ b/style.css @@ -17,6 +17,7 @@ body { top: 0; width: 340px; bottom: 45px; + z-index: 1001; } #sidebar { From 2850d44dace2812005f77762de8bc205037e8b4f Mon Sep 17 00:00:00 2001 From: Jakub Ludwig Date: Mon, 11 Feb 2013 13:53:35 +0100 Subject: [PATCH 12/16] Added field count formula --- code/portal_detail_display_tools.js | 23 ++++++++++++++--------- main.js | 3 ++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index 42cf0c95..4e082670 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -137,19 +137,24 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick) { window.getDestroyAP = function(d) { console.log('rendering destroy AP'); var res_count = 0; - var links = 0; + var links_count = 0; + var fields_count - $.each(d.resonatorArray.resonators, function(ind, reso) - { + $.each(d.resonatorArray.resonators, function(ind, reso) { res_count += 1; }); - if(d.portalV2.linkedEdges) $.each(d.portalV2.linkedEdges, function(ind, link) - { - links++; - }); + if(d.portalV2.linkedEdges) { + $.each(d.portalV2.linkedEdges, function(ind, link) { + links_count++; + }); + } - var ap_count = (res_count * DESTROY_RESONATOR) + (links * DESTROY_LINK); + if(d.portalV2.linkedFields) { + fields_count = d.portalV2.linkedFields.length; + } + + var ap_count = (res_count * DESTROY_RESONATOR) + (links_count * DESTROY_LINK) + (fields_count * DESTROY_FIELD); - return 'Destroy ' + res_count + 'x res + ' + links + 'x link -> ' + ap_count + 'AP'; + return 'Destroy ' + res_count + 'x res + ' + links_count + 'x link → ' + ap_count + 'AP'; } diff --git a/main.js b/main.js index b99017df..f36b3b70 100644 --- a/main.js +++ b/main.js @@ -129,7 +129,8 @@ var HACK_RANGE = 35; // in meters, max. distance from portal to be able to acces var OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE']; var DEFAULT_PORTAL_IMG = 'http://commondatastorage.googleapis.com/ingress/img/default-portal-image.png'; var DESTROY_RESONATOR = 75; //AP for destroying portal -var DESTROY_LINK = 187; //AP fro destroying link +var DESTROY_LINK = 187; //AP for destroying link +var DESTROY_FIELD = 750; //AP for destroying field // OTHER MORE-OR-LESS CONSTANTS ////////////////////////////////////// var NOMINATIM = 'http://nominatim.openstreetmap.org/search?format=json&limit=1&q='; From 0c3a9ef4fc1aa774dfd68b15029af5f3e125d970 Mon Sep 17 00:00:00 2001 From: Cameron Moon Date: Tue, 12 Feb 2013 00:14:27 +1100 Subject: [PATCH 13/16] Made sidebar look less broken when using out-of-date plugin --- style.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/style.css b/style.css index ebe3d41d..c7d2dae7 100644 --- a/style.css +++ b/style.css @@ -18,6 +18,13 @@ body { width: 340px; bottom: 45px; z-index: 1001; + + /* + * NOTE: following 2 items are needed for back compatability + * between new css and old plugin versions (0.4) as of 2013-02-11 UTC. + */ + background-color: rgba(8, 48, 78, 1); + border-left: 1px solid #20A8B1; } #sidebar { From 6599f1375ab83a1fd6fb8ba340842d7f3170950b Mon Sep 17 00:00:00 2001 From: Cameron Moon Date: Tue, 12 Feb 2013 00:20:22 +1100 Subject: [PATCH 14/16] Remove border on #scrollwrapper as it was duplicating border on #sidebar --- style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/style.css b/style.css index c7d2dae7..49539198 100644 --- a/style.css +++ b/style.css @@ -24,7 +24,6 @@ body { * between new css and old plugin versions (0.4) as of 2013-02-11 UTC. */ background-color: rgba(8, 48, 78, 1); - border-left: 1px solid #20A8B1; } #sidebar { From 5e4b3c94ba96dc099fa7489fb16fff3df7a039e4 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Mon, 11 Feb 2013 14:22:14 +0100 Subject: [PATCH 15/16] clean up Pirozek 'show AP' patch a bit and handle random details differently. --- code/portal_detail_display.js | 14 ++++----- code/portal_detail_display_tools.js | 44 +++++++++++++++-------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index d1cc877d..98b33592 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -19,24 +19,23 @@ window.renderPortalDetails = function(guid) { links[link.isOrigin ? 'outgoing' : 'incoming']++; }); function linkExpl(t) { return ''+t+''; } - var linksText = linkExpl('links')+':'+linkExpl(' ↳ ' + links.incoming+'  •  '+links.outgoing+' ↴'); + var linksText = [linkExpl('links'), linkExpl(' ↳ ' + links.incoming+'  •  '+links.outgoing+' ↴')]; var player = d.captured && d.captured.capturingPlayerId ? getPlayerName(d.captured.capturingPlayerId) : null; - var playerText = player ? 'owner: ' + player : null; + var playerText = player ? ['owner', player] : null; var time = d.captured ? unixTimeToString(d.captured.capturedTime) : null; - var sinceText = time ? 'since: ' + time : null; + var sinceText = time ? ['since', time] : null; - var linkedFields = 'fields: ' + d.portalV2.linkedFields.length; + var linkedFields = ['fields', d.portalV2.linkedFields.length]; // collect and html-ify random data - var randDetails = [playerText, sinceText, getRangeText(d), getEnergyText(d), linksText, getAvgResoDistText(d), linkedFields]; + var randDetails = [playerText, sinceText, getRangeText(d), getEnergyText(d), linksText, getAvgResoDistText(d), linkedFields, getDestroyAP(d)]; randDetails = randDetails.map(function(detail) { if(!detail) return ''; - detail = detail.split(':'); - detail = ''; + detail = ''; return detail; }).join('\n'); @@ -68,7 +67,6 @@ window.renderPortalDetails = function(guid) { + '
'+getModDetails(d)+'
' + '
'+randDetails+'
' + '
'+getResonatorDetails(d)+'
' - + '
'+getDestroyAP(d)+'
' + '
' + '' + '' diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index ee5edb56..94effc4b 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -6,12 +6,12 @@ // returns displayable text+link about portal range window.getRangeText = function(d) { var range = getPortalRange(d); - return 'range: ' + return ['range', + '' + (range > 1000 ? Math.round(range/1000) + ' km' : Math.round(range) + ' m') - + ''; + + '']; } // generates description text from details for portal @@ -69,13 +69,12 @@ window.getEnergyText = function(d) { var totalNrg = getTotalPortalEnergy(d); var inf = currentNrg + ' / ' + totalNrg; var fill = prettyEnergy(currentNrg) + ' / ' + prettyEnergy(totalNrg) - var meter = 'energy: ' + fill + ''; - return meter; + return ['energy', '' + fill + '']; } window.getAvgResoDistText = function(d) { var avgDist = Math.round(10*getAvgResoDist(d))/10; - return '⌀ res dist: ' + avgDist + ' m'; + return ['⌀ res dist', avgDist + ' m']; } window.getResonatorDetails = function(d) { @@ -142,26 +141,29 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick, isLeft) { // calculate AP gain from destroying portal // so far it counts only resonators + links window.getDestroyAP = function(d) { - console.log('rendering destroy AP'); - var res_count = 0; - var links_count = 0; - var fields_count + var resoCount = 0; $.each(d.resonatorArray.resonators, function(ind, reso) { - res_count += 1; + if(!reso) return true; + resoCount += 1; }); - if(d.portalV2.linkedEdges) { - $.each(d.portalV2.linkedEdges, function(ind, link) { - links_count++; - }); + var linkCount = d.portalV2.linkedEdges ? d.portalV2.linkedEdges.length : 0; + var fieldCount = d.portalV2.linkedFields ? d.portalV2.linkedFields.length : 0; + + var resoAp = resoCount * DESTROY_RESONATOR; + var linkAp = linkCount * DESTROY_LINK; + var fieldAp = fieldCount * DESTROY_FIELD; + var sum = resoAp + linkAp + fieldAp; + + function tt(text) { + var t = 'Destroy:\n'; + t += resoCount + '×\tResonators\t= ' + digits(resoAp) + '\n'; + t += linkCount + '×\tLinks\t\t= ' + digits(linkAp) + '\n'; + t += fieldCount + '×\tFields\t\t= ' + digits(fieldAp) + '\n'; + t += 'Sum: ' + digits(sum) + ' AP'; + return '' + digits(text) + ''; } - if(d.portalV2.linkedFields) { - fields_count = d.portalV2.linkedFields.length; - } - - var ap_count = (res_count * DESTROY_RESONATOR) + (links_count * DESTROY_LINK) + (fields_count * DESTROY_FIELD); - - return 'Destroy ' + res_count + 'x res + ' + links_count + 'x link → ' + ap_count + 'AP'; + return [tt('AP Gain'), tt(sum)]; } From 0f6422b48e42a8161214d9c09a3d85fac3995ba9 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Mon, 11 Feb 2013 14:23:17 +0100 Subject: [PATCH 16/16] add Pirozek to contribs --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ba4c719d..e5d35a23 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ Contributors [JasonMillward](https://github.com/JasonMillward), [mledoze](https://github.com/mledoze), [OshiHidra](https://github.com/OshiHidra), +[Pirozek](https://github.com/Pirozek), [Scrool](https://github.com/Scrool), [sorgo](https://github.com/sorgo), [Xelio](https://github.com/Xelio),