From 03fadb3078b11dd9caacb079968c5f40ded55a82 Mon Sep 17 00:00:00 2001 From: maubry Date: Tue, 3 Dec 2013 00:24:10 -0500 Subject: [PATCH 1/5] plugin: portals list - fix for changes to Niantc data Issue #668 --- plugins/portals-list.user.js | 248 ++++++++++++++++++++++++++++++++++- 1 file changed, 245 insertions(+), 3 deletions(-) diff --git a/plugins/portals-list.user.js b/plugins/portals-list.user.js index 88bb636b..e98e60e1 100644 --- a/plugins/portals-list.user.js +++ b/plugins/portals-list.user.js @@ -1,15 +1,257 @@ // ==UserScript== // @id iitc-plugin-portals-list@teo96 // @name IITC plugin: show list of portals -// @category Deleted -// @version 0.0.18.@@DATETIMEVERSION@@ +// @category Info +// @version 0.0.19.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description PLUGIN CURRENTLY UNAVAILABLE +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Display a sortable list of all visible portals with full details about the team, resonators, shields, etc. // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* // @match http://www.ingress.com/intel* // @grant none // ==/UserScript== + +@@PLUGINSTART@@ + +// PLUGIN START //////////////////////////////////////////////////////// + + /* whatsnew + * 0.0.19: Using the new data format + * 0.0.15: Add 'age' column to display how long each portal has been controlled by its current owner. + * 0.0.14: Add support to new mods (S:Shield - T:Turret - LA:Link Amp - H:Heat-sink - M:Multi-hack - FA:Force Amp) + * 0.0.12: Use dialog() instead of alert so the user can drag the box around + * 0.0.11: Add nominal energy column and # links, fix sort bug when opened even amounts of times, nits + * 0.0.10: Fixed persistent css problem with alert + * 0.0.9 : bugs hunt + * 0.0.8 : Aborted to avoid problems with Niantic (export portals informations as csv or kml file) + * 0.0.7 : more informations available via tooltips (who deployed, energy, ...), new E/AP column + * 0.0.6 : Add power charge information into a new column + bugfix + * 0.0.5 : Filter portals by clicking on 'All portals', 'Res Portals' or 'Enl Portals' + * 0.0.4 : Add link to portals name, one click to display full information in portal panel, double click to zoom on portal, hover to show address + * 0.0.3 : sorting ascending/descending and add numbers of portals by faction on top on table + * 0.0.2 : add sorting feature when click on header column + * 0.0.1 : initial release, show list of portals with level, team, resonators and shield information + * + * Display code inspired from @vita10gy's scoreboard plugin : iitc-plugin-scoreboard@vita10gy - https://github.com/breunigs/ingress-intel-total-conversion + * Portal link code from xelio - iitc: AP List - https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/ap-list.user.js + * + * todo : export as GPX, Open in Google Maps, more statistics in the header, what else ? + */ + +// use own namespace for plugin +window.plugin.portalslist = function() {}; + +window.plugin.portalslist.listPortals = []; +window.plugin.portalslist.sortOrder=-1; +window.plugin.portalslist.enlP = 0; +window.plugin.portalslist.resP = 0; +window.plugin.portalslist.filter=0; + +//fill the listPortals array with portals avaliable on the map (level filtered portals will not appear in the table) +window.plugin.portalslist.getPortals = function() { + //filter : 0 = All, 1 = Res, 2 = Enl + var retval=false; + + var displayBounds = map.getBounds(); + + window.plugin.portalslist.listPortals = []; + $.each(window.portals, function(i, portal) { + // eliminate offscreen portals (selected, and in padding) + if(!displayBounds.contains(portal.getLatLng())) return true; + + retval=true; + var d = portal.options.data; + var teamN = 0; + + switch (d.team){ + case 'RESISTANCE' : + window.plugin.portalslist.resP++; + teamN = 1 + break; + case 'ENLIGHTENED' : + window.plugin.portalslist.enlP++; + teamN = 2; + break; + } + + var thisPortal = { + 'guid': i, + 'teamN': teamN, + 'name': d.title, + 'team': d.team, + 'level': d.level, + 'health': d.health, + 'resCount': d.resCount, + 'lat': d.latE6, + 'lng': d.lngE6, + 'img': d.img}; + window.plugin.portalslist.listPortals.push(thisPortal); + }); + + return retval; +} + +window.plugin.portalslist.displayPL = function() { + var html = ''; + window.plugin.portalslist.sortOrder=-1; + window.plugin.portalslist.enlP = 0; + window.plugin.portalslist.resP = 0; + + if (window.plugin.portalslist.getPortals()) { + html += window.plugin.portalslist.portalTable('level', window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter); + } else { + html = '
Nothing to show!
'; + }; + + dialog({ + html: '
' + html + '
', + dialogClass: 'ui-dialog-portalslist', + title: 'Portal list: ' + window.plugin.portalslist.listPortals.length + ' ' + (window.plugin.portalslist.listPortals.length == 1 ? 'portal' : 'portals'), + id: 'portal-list', + width: 800 + }); + + //run the name resolving process + //resolvePlayerNames(); +} + +window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { + // sortOrder <0 ==> desc, >0 ==> asc, i use sortOrder * -1 to change the state + window.plugin.portalslist.filter=filter; + var portals=window.plugin.portalslist.listPortals; + + //Array sort + window.plugin.portalslist.listPortals.sort(function(a, b) { + var retVal = 0; + switch (sortBy) { + case 'names': + retVal = a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; + break; + default: + retVal = b[sortBy] - a[sortBy]; + break; + } + if (sortOrder > 0) retVal = -retVal; //thx @jonatkins + return retVal; + }); + + var sort = window.plugin.portalslist.portalTableSort; + var html = window.plugin.portalslist.stats(); + html += '' + + '' + + '' + + '' + + '' + + '' + + + $.each(portals, function(ind, portal) { + if (filter === 0 || filter === portal.teamN) { + html += '' + + '' + + '' + + ''; + + html += '' + + ''; + + html+= ''; + } + }); + html += '
PortalLevelTeamHealthResonator Count
' + window.plugin.portalslist.getPortalLink(portal, portal.guid) + '' + portal.level + '' + portal.team + '' + portal.health + '' + portal.resCount + '
'; + + html += '
Click on portals table headers to sort by that column. ' + + 'Click on All Portals, Resistance Portals, Enlightened Portals to filter
' + + 'Thanks to @vita10gy & @xelio for their IITC plugins who inspired me. A @teo96 production. Vive la Résistance !
'; + + window.plugin.portalslist.sortOrder = window.plugin.portalslist.sortOrder*-1; + return html; +} + +window.plugin.portalslist.stats = function(sortBy) { + var html = '' + + '' + + '' + + '' + + '' + + '
All Portals : (click to filter)' + window.plugin.portalslist.listPortals.length + 'Resistance Portals : ' + window.plugin.portalslist.resP +' (' + Math.floor(window.plugin.portalslist.resP/window.plugin.portalslist.listPortals.length*100) + '%)Enlightened Portals : '+ window.plugin.portalslist.enlP +' (' + Math.floor(window.plugin.portalslist.enlP/window.plugin.portalslist.listPortals.length*100) + '%)
'; + return html; +} + +// A little helper function so the above isn't so messy +window.plugin.portalslist.portalTableSort = function(name, by) { + var retVal = 'data-sort="' + name + '"'; + if(name === by) { + retVal += ' class="sorted"'; + } + return retVal; +}; + +// portal link - single click: select portal +// double click: zoom to and select portal +// hover: show address +// code from getPortalLink function by xelio from iitc: AP List - https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/ap-list.user.js +window.plugin.portalslist.getPortalLink = function(portal,guid) { + + var latlng = [portal.latE6/1E6, portal.lngE6/1E6].join(); + var jsSingleClick = 'window.renderPortalDetails(\''+guid+'\');return false'; + var jsDoubleClick = 'window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false'; + var perma = '/intel?latE6='+portal.latE6+'&lngE6='+portal.lngE6+'&z=17&pguid='+guid; + + //Use Jquery to create the link, which escape characters in TITLE and ADDRESS of portal + var a = $('',{ + "class": 'help', + text: portal.name, + title: portal.name, + href: perma, + onClick: jsSingleClick, + onDblClick: jsDoubleClick + })[0].outerHTML; + var div = '
'+a+'
'; + return div; +} + +var setup = function() { + $('#toolbox').append('
Portals list'); + $('head').append(''); + // Setup sorting + $(document).on('click.portalslist', '#portalslist table th', function() { + $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter)); + }); + $(document).on('click.portalslist', '#portalslist .filterAll', function() { + $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,0)); + }); + $(document).on('click.portalslist', '#portalslist .filterRes', function() { + $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,1)); + }); + $(document).on('click.portalslist', '#portalslist .filterEnl', function() { + $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,2)); + }); +} + +// PLUGIN END ////////////////////////////////////////////////////////// + +@@PLUGINEND@@ From 7a12681fab4c1fc712654a06fd4df74d42665def Mon Sep 17 00:00:00 2001 From: maubry Date: Tue, 3 Dec 2013 11:11:10 -0500 Subject: [PATCH 2/5] Iteration two, using TEAM_* constant, level with 0 base, getLatLng and fields/links count. plugin: portals list - fix for changes to Niantc data Issue #668 --- plugins/portals-list.user.js | 42 ++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/plugins/portals-list.user.js b/plugins/portals-list.user.js index e98e60e1..931fbf5a 100644 --- a/plugins/portals-list.user.js +++ b/plugins/portals-list.user.js @@ -2,7 +2,7 @@ // @id iitc-plugin-portals-list@teo96 // @name IITC plugin: show list of portals // @category Info -// @version 0.0.19.@@DATETIMEVERSION@@ +// @version 0.1.0.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -19,7 +19,7 @@ // PLUGIN START //////////////////////////////////////////////////////// /* whatsnew - * 0.0.19: Using the new data format + * 0.1.0 : Using the new data format * 0.0.15: Add 'age' column to display how long each portal has been controlled by its current owner. * 0.0.14: Add support to new mods (S:Shield - T:Turret - LA:Link Amp - H:Heat-sink - M:Multi-hack - FA:Force Amp) * 0.0.12: Use dialog() instead of alert so the user can drag the box around @@ -64,30 +64,36 @@ window.plugin.portalslist.getPortals = function() { retval=true; var d = portal.options.data; - var teamN = 0; + var teamN = window.TEAM_NONE; switch (d.team){ case 'RESISTANCE' : window.plugin.portalslist.resP++; - teamN = 1 + teamN = window.TEAM_RES break; case 'ENLIGHTENED' : window.plugin.portalslist.enlP++; - teamN = 2; + teamN = window.TEAM_ENL; break; } + var l = window.getPortalLinks(i); + var f = window.getPortalFields(i); var thisPortal = { + 'portal': portal, 'guid': i, 'teamN': teamN, 'name': d.title, 'team': d.team, - 'level': d.level, + 'level': portal.options.level, 'health': d.health, 'resCount': d.resCount, - 'lat': d.latE6, - 'lng': d.lngE6, - 'img': d.img}; + 'img': d.img, + 'linkCount': l.in.length + l.out.length, + 'link' : l, + 'fieldCount': f.length, + 'field' : f + }; window.plugin.portalslist.listPortals.push(thisPortal); }); @@ -126,7 +132,7 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { //Array sort window.plugin.portalslist.listPortals.sort(function(a, b) { var retVal = 0; - switch (sortBy) { + switch (sortBy) { win case 'names': retVal = a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; break; @@ -146,17 +152,21 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { + 'Team' + 'Health' + 'Resonator Count' + + 'Link Count' + + 'Field Count' $.each(portals, function(ind, portal) { - if (filter === 0 || filter === portal.teamN) { - html += '' + if (filter === TEAM_NONE || filter === portal.teamN) { + html += '' + '' + window.plugin.portalslist.getPortalLink(portal, portal.guid) + '' + '' + portal.level + '' + '' + portal.team + ''; html += '' + portal.health + '' - + '' + portal.resCount + ''; + + '' + portal.resCount + '' + + '' + portal.linkCount + '' + + '' + portal.fieldCount + ''; html+= ''; } @@ -195,11 +205,11 @@ window.plugin.portalslist.portalTableSort = function(name, by) { // hover: show address // code from getPortalLink function by xelio from iitc: AP List - https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/ap-list.user.js window.plugin.portalslist.getPortalLink = function(portal,guid) { - - var latlng = [portal.latE6/1E6, portal.lngE6/1E6].join(); + var coord = portal.portal.getLatLng(); + var latlng = [coord.lat, coord.lng].join(); var jsSingleClick = 'window.renderPortalDetails(\''+guid+'\');return false'; var jsDoubleClick = 'window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false'; - var perma = '/intel?latE6='+portal.latE6+'&lngE6='+portal.lngE6+'&z=17&pguid='+guid; + var perma = '/intel?latE6='+coord.lat+'&lngE6='+coord.lng+'&z=17&pguid='+guid; //Use Jquery to create the link, which escape characters in TITLE and ADDRESS of portal var a = $('',{ From 18bacd956a84f5813b17460e64e77a0be4a911a0 Mon Sep 17 00:00:00 2001 From: maubry Date: Tue, 3 Dec 2013 17:47:28 -0500 Subject: [PATCH 3/5] accidental copy and pasta! plugin: portals list - fix for changes to Niantc data Issue #668 --- plugins/portals-list.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/portals-list.user.js b/plugins/portals-list.user.js index 931fbf5a..fcddc4ff 100644 --- a/plugins/portals-list.user.js +++ b/plugins/portals-list.user.js @@ -132,7 +132,7 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { //Array sort window.plugin.portalslist.listPortals.sort(function(a, b) { var retVal = 0; - switch (sortBy) { win + switch (sortBy) { case 'names': retVal = a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; break; @@ -165,7 +165,7 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { html += '' + portal.health + '' + '' + portal.resCount + '' - + '' + portal.linkCount + '' + + '' + portal.linkCount + '' + '' + portal.fieldCount + ''; html+= ''; From 99a0b3e975350579a6dcdb80a4022821574b51d2 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 3 Dec 2013 23:29:48 +0000 Subject: [PATCH 4/5] delete the old broken version of portals-list --- plugins/broken/portals-list.user.js | 453 ---------------------------- 1 file changed, 453 deletions(-) delete mode 100644 plugins/broken/portals-list.user.js diff --git a/plugins/broken/portals-list.user.js b/plugins/broken/portals-list.user.js deleted file mode 100644 index 2b439f92..00000000 --- a/plugins/broken/portals-list.user.js +++ /dev/null @@ -1,453 +0,0 @@ -// ==UserScript== -// @id iitc-plugin-portals-list@teo96 -// @name IITC plugin: show list of portals -// @category Info -// @version 0.0.18.@@DATETIMEVERSION@@ -// @namespace https://github.com/jonatkins/ingress-intel-total-conversion -// @updateURL @@UPDATEURL@@ -// @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] Display a sortable list of all visible portals with full details about the team, resonators, shields, etc. -// @include https://www.ingress.com/intel* -// @include http://www.ingress.com/intel* -// @match https://www.ingress.com/intel* -// @match http://www.ingress.com/intel* -// @grant none -// ==/UserScript== - -@@PLUGINSTART@@ - -// PLUGIN START //////////////////////////////////////////////////////// - -/* whatsnew -* 0.0.15: Add 'age' column to display how long each portal has been controlled by its current owner. -* 0.0.14: Add support to new mods (S:Shield - T:Turret - LA:Link Amp - H:Heat-sink - M:Multi-hack - FA:Force Amp) -* 0.0.12: Use dialog() instead of alert so the user can drag the box around -* 0.0.11: Add nominal energy column and # links, fix sort bug when opened even amounts of times, nits -* 0.0.10: Fixed persistent css problem with alert -* 0.0.9 : bugs hunt -* 0.0.8 : Aborted to avoid problems with Niantic (export portals informations as csv or kml file) -* 0.0.7 : more informations available via tooltips (who deployed, energy, ...), new E/AP column -* 0.0.6 : Add power charge information into a new column + bugfix -* 0.0.5 : Filter portals by clicking on 'All portals', 'Res Portals' or 'Enl Portals' -* 0.0.4 : Add link to portals name, one click to display full information in portal panel, double click to zoom on portal, hover to show address -* 0.0.3 : sorting ascending/descending and add numbers of portals by faction on top on table -* 0.0.2 : add sorting feature when click on header column -* 0.0.1 : initial release, show list of portals with level, team, resonators and shield information -* -* Display code inspired from @vita10gy's scoreboard plugin : iitc-plugin-scoreboard@vita10gy - https://github.com/breunigs/ingress-intel-total-conversion -* Portal link code from xelio - iitc: AP List - https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/ap-list.user.js -* -* todo : export as GPX, Open in Google Maps, more statistics in the header, what else ? -*/ - -// use own namespace for plugin -window.plugin.portalslist = function() {}; - -window.plugin.portalslist.listPortals = []; // structure : name, team, level, resonators = Array, Shields = Array, APgain, Age -window.plugin.portalslist.sortOrder=-1; -window.plugin.portalslist.enlP = 0; -window.plugin.portalslist.resP = 0; -window.plugin.portalslist.filter=0; - -//fill the listPortals array with portals avaliable on the map (level filtered portals will not appear in the table) -window.plugin.portalslist.getPortals = function() { - //filter : 0 = All, 1 = Res, 2 = Enl - //console.log('** getPortals'); - var retval=false; - - var displayBounds = map.getBounds(); - - window.plugin.portalslist.listPortals = []; - //get portals informations from IITC - $.each(window.portals, function(i, portal) { - // eliminate offscreen portals (selected, and in padding) - if(!displayBounds.contains(portal.getLatLng())) return true; - - retval=true; - var d = portal.options.details; - var name = d.portalV2.descriptiveText.TITLE; - var address = d.portalV2.descriptiveText.ADDRESS; - var img = getPortalImageUrl(d); - var team = portal.options.team; - var now = new Date(); - var now_ms = now.getTime();// + (now.getTimezoneOffset() * 60000); - var age_in_seconds = 0; - var age_string_long = 'This portal is not captured.'; - var age_string_short = 'n/a'; - if(portal.options.details.hasOwnProperty('captured') && portal.options.details.captured.hasOwnProperty('capturedTime')) { - var age_in_seconds = Math.floor((now_ms - portal.options.details.captured.capturedTime)/1000); - var age_string_long = window.plugin.portalslist.secondsToString(age_in_seconds, 'l'); - var age_string_short = window.plugin.portalslist.secondsToString(age_in_seconds, 's'); - } - - switch (team){ - case 1 : - window.plugin.portalslist.resP++; - break; - case 2 : - window.plugin.portalslist.enlP++; - break; - } - var level = getPortalLevel(d).toFixed(2); - var guid = portal.options.guid; - - - //get resonators informations - var resonators = []; // my local resonator array : reso level, reso deployed by, distance to portal, energy total, max - var energy = 0; - var maxenergy=0; - $.each(portal.options.details.resonatorArray.resonators, function(ind, reso) { - if(reso) { - resonators[ind] = [reso.level, window.getPlayerName(reso.ownerGuid), reso.distanceToPortal, reso.energyTotal, RESO_NRG[reso.level]]; - energy += reso.energyTotal; - maxenergy += RESO_NRG[reso.level]; - } else { resonators[ind] = [0,'',0,0,0]; } - }); - // Sort resonators array by resonator level - resonators.sort(function (a, b) {return b[0] - a[0]}); - - //get mods informations - var mods = []; - $.each(d.portalV2.linkedModArray, function(ind, mod) { - var modShortName=''; - if (mod) { - switch (mod.displayName) { - case 'Portal Shield': - modShortName = 'S'; - break; - case 'Force Amp': - modShortName = 'FA'; - break; - case 'Link Amp': - modShortName = 'LA'; - break; - case 'Heat Sink': - modShortName = 'H'; - break; - case 'Multi-hack': - modShortName = 'M'; - break; - case 'Turret': - modShortName = 'T'; - break; - default: - modShortName = ''; - break; - } - if (modShortName === '') { - mods[ind] = ['', '', '']; - } else { - if ((modShortName === 'S') && - ((mod.rarity=='COMMON' && mod.stats.MITIGATION == 6) || - (mod.rarity=='RARE' && mod.stats.MITIGATION == 8) || - (mod.rarity=='VERY_RARE' && mod.stats.MITIGATION == 10))) - modShortName=modShortName+'!'; - mods[ind] = [mod.rarity, getPlayerName(mod.installingUser), modShortName, mod.displayName]; - } - }else { mods[ind] = ['', '', '']; } - }); - - var APgain= getAttackApGain(d).enemyAp; - var thisPortal = {'portal': d, - 'name': name, - 'team': team, - 'level': level, - 'guid': guid, - 'resonators': resonators, - 'energyratio': maxenergy ? Math.floor(energy/maxenergy*100) : 0, - 'mods': mods, - 'APgain': APgain, - 'EAP': (energy/APgain).toFixed(2), - 'energy': energy, - 'maxenergy': maxenergy, - 'links': d.portalV2.linkedEdges.length, - 'lat': portal._latlng.lat, - 'lng': portal._latlng.lng, - 'address': address, - 'img': img, - 'age': age_in_seconds, - 'age_string_long': age_string_long, - 'age_string_short': age_string_short}; - window.plugin.portalslist.listPortals.push(thisPortal); - }); - - return retval; -} - -window.plugin.portalslist.displayPL = function() { - // debug tools - //var start = new Date().getTime(); - //console.log('***** Start ' + start); - - var html = ''; - window.plugin.portalslist.sortOrder=-1; - window.plugin.portalslist.enlP = 0; - window.plugin.portalslist.resP = 0; - - if (window.plugin.portalslist.getPortals()) { - html += window.plugin.portalslist.portalTable('level', window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter); - } else { - html = '
Nothing to show!
'; - }; - - dialog({ - html: '
' + html + '
', - dialogClass: 'ui-dialog-portalslist', - title: 'Portal list: ' + window.plugin.portalslist.listPortals.length + ' ' + (window.plugin.portalslist.listPortals.length == 1 ? 'portal' : 'portals'), - id: 'portal-list', - width: 800 - }); - - //run the name resolving process - resolvePlayerNames(); - - //debug tools - //end = new Date().getTime(); - //console.log('***** end : ' + end + ' and Elapse : ' + (end - start)); -} - -window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { - // sortOrder <0 ==> desc, >0 ==> asc, i use sortOrder * -1 to change the state - window.plugin.portalslist.filter=filter; - var portals=window.plugin.portalslist.listPortals; - - //Array sort - window.plugin.portalslist.listPortals.sort(function(a, b) { - var retVal = 0; - switch (sortBy) { - case 'names': - retVal = a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; - break; - case 'r1': - retVal = b.resonators[0][0] - a.resonators[0][0]; - if (retVal) - break; - case 'r2': - retVal = b.resonators[1][0] - a.resonators[1][0]; - if (retVal) - break; - case 'r3': - retVal = b.resonators[2][0] - a.resonators[2][0]; - if (retVal) - break; - case 'r4': - retVal = b.resonators[3][0] - a.resonators[3][0]; - if (retVal) - break; - case 'r5': - retVal = b.resonators[4][0] - a.resonators[4][0]; - if (retVal) - break; - case 'r6': - retVal = b.resonators[5][0] - a.resonators[5][0]; - if (retVal) - break; - case 'r7': - retVal = b.resonators[6][0] - a.resonators[6][0]; - if (retVal) - break; - case 'r8': - retVal = b.resonators[7][0] - a.resonators[7][0]; - break; - case 's1': - retVal = a.mods[0][2] > b.mods[0][2] ? -1 : 1; - break; - case 's2': - retVal = a.mods[1][2] > b.mods[1][2] ? -1 : 1; - break; - case 's3': - retVal = a.mods[2][2] > b.mods[2][2] ? -1 : 1; - break; - case 's4': - retVal = a.mods[3][2] > b.mods[3][2] ? -1 : 1; - break; - default: - retVal = b[sortBy] - a[sortBy]; - break; - } - if (sortOrder > 0) retVal = -retVal; //thx @jonatkins - return retVal; - }); - - var sort = window.plugin.portalslist.portalTableSort; - var html = window.plugin.portalslist.stats(); - html += '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + ''; - - - $.each(portals, function(ind, portal) { - - if (filter === 0 || filter === portal.team) { - html += '' - + '' - + '' - + ''; - - var mitigationDetails = getPortalMitigationDetails(portal.portal); - portal.mitigation = mitigationDetails.total + mitigationDetails.excess; - - var title; - var percent; - $.each([0, 1, 2, 3 ,4 ,5 ,6 ,7], function(ind, slot) { - percent = portal.resonators[slot][4] ? Math.floor(portal.resonators[slot][3]/portal.resonators[slot][4]*100) : 0; - title = 'title="owner: ' + portal.resonators[slot][1] + '
' - + 'energy: ' + portal.resonators[slot][3] + ' / ' + portal.resonators[slot][4] + ' (' + percent + '%)
' - + 'distance: ' + portal.resonators[slot][2] + 'm'; - - html += ''; - - }); - - html += '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + ''; - - html+= ''; - } - }); - html += '
PortalLevelTR1R2R3R4R5R6R7R8Energy%LinksM1M2M3M4Mit.AP GainE/APAge
' + window.plugin.portalslist.getPortalLink(portal.portal, portal.guid) + '' + portal.level + '' + portal.team + '' + portal.resonators[slot][0] + '' + prettyEnergy(portal.energy) + '' + portal.energyratio + '%' + portal.links + '' + portal.mods[0][2] + '' + portal.mods[1][2] + '' + portal.mods[2][2] + '' + portal.mods[3][2] + '' + portal.mitigation + '' + portal.APgain + '' + portal.EAP + '' + portal.age_string_short + '
'; - - html += '
'; - - window.plugin.portalslist.sortOrder = window.plugin.portalslist.sortOrder*-1; - return html; -} - -window.plugin.portalslist.stats = function(sortBy) { - //console.log('** stats'); - var html = '' - + '' - + '' - + '' - + '' - + '
All Portals : (click to filter)' + window.plugin.portalslist.listPortals.length + 'Resistance Portals : ' + window.plugin.portalslist.resP +' (' + Math.floor(window.plugin.portalslist.resP/window.plugin.portalslist.listPortals.length*100) + '%)Enlightened Portals : '+ window.plugin.portalslist.enlP +' (' + Math.floor(window.plugin.portalslist.enlP/window.plugin.portalslist.listPortals.length*100) + '%)
'; - return html; -} - -// A little helper function so the above isn't so messy -window.plugin.portalslist.portalTableSort = function(name, by) { - var retVal = 'data-sort="' + name + '"'; - if(name === by) { - retVal += ' class="sorted"'; - } - return retVal; -}; - -// portal link - single click: select portal -// double click: zoom to and select portal -// hover: show address -// code from getPortalLink function by xelio from iitc: AP List - https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/ap-list.user.js -window.plugin.portalslist.getPortalLink = function(portal,guid) { - - var latlng = [portal.locationE6.latE6/1E6, portal.locationE6.lngE6/1E6].join(); - var jsSingleClick = 'window.renderPortalDetails(\''+guid+'\');return false'; - var jsDoubleClick = 'window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false'; - var perma = '/intel?latE6='+portal.locationE6.latE6+'&lngE6='+portal.locationE6.lngE6+'&z=17&pguid='+guid; - - //Use Jquery to create the link, which escape characters in TITLE and ADDRESS of portal - var a = $('',{ - "class": 'help', - text: portal.portalV2.descriptiveText.TITLE, - title: portal.portalV2.descriptiveText.ADDRESS, - href: perma, - onClick: jsSingleClick, - onDblClick: jsDoubleClick - })[0].outerHTML; - var div = '
'+a+'
'; - return div; -} - -// length can be "s" or "l" for "short" or "long" -window.plugin.portalslist.secondsToString = function(seconds, length) { - var numdays = Math.floor(seconds / 86400); - var numhours = Math.floor((seconds % 86400) / 3600); - var numminutes = Math.floor(((seconds % 86400) % 3600) / 60); - var numseconds = ((seconds % 86400) % 3600) % 60; - if(length === "l") { - return numdays + " days " + numhours + " hours " + numminutes + " minutes " + numseconds + " seconds"; - } else { - return numdays + "d" + numhours + "h"; - } -} - -var setup = function() { - $('#toolbox').append('
Portals list'); - $('head').append(''); - // Setup sorting - $(document).on('click.portalslist', '#portalslist table th', function() { - $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter)); - }); - $(document).on('click.portalslist', '#portalslist .filterAll', function() { - $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,0)); - }); - $(document).on('click.portalslist', '#portalslist .filterRes', function() { - $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,1)); - }); - $(document).on('click.portalslist', '#portalslist .filterEnl', function() { - $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,2)); - }); -} - -// PLUGIN END ////////////////////////////////////////////////////////// - -@@PLUGINEND@@ From 89b23e8fbc0fb83358d6a4d28c10c1eb01585693 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 3 Dec 2013 23:34:53 +0000 Subject: [PATCH 5/5] decrease width from 800 to 700 pixels - resolves issues on mobile --- plugins/portals-list.user.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/portals-list.user.js b/plugins/portals-list.user.js index fcddc4ff..ce61c6a6 100644 --- a/plugins/portals-list.user.js +++ b/plugins/portals-list.user.js @@ -117,7 +117,7 @@ window.plugin.portalslist.displayPL = function() { dialogClass: 'ui-dialog-portalslist', title: 'Portal list: ' + window.plugin.portalslist.listPortals.length + ' ' + (window.plugin.portalslist.listPortals.length == 1 ? 'portal' : 'portals'), id: 'portal-list', - width: 800 + width: 700 }); //run the name resolving process @@ -227,9 +227,6 @@ window.plugin.portalslist.getPortalLink = function(portal,guid) { var setup = function() { $('#toolbox').append(' Portals list'); $('head').append('