diff --git a/plugins/portals-list.user.js b/plugins/portals-list.user.js index b9c0f7b9..39129630 100644 --- a/plugins/portals-list.user.js +++ b/plugins/portals-list.user.js @@ -19,6 +19,7 @@ // 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 @@ -42,7 +43,7 @@ // use own namespace for plugin window.plugin.portalslist = function() {}; -window.plugin.portalslist.listPortals = []; // structure : name, team, level, resonators = Array, Shields = Array, APgain +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; @@ -68,6 +69,16 @@ window.plugin.portalslist.getPortals = function() { var address = d.portalV2.descriptiveText.ADDRESS; var img = d.imageByUrl && d.imageByUrl.imageUrl ? d.imageByUrl.imageUrl : DEFAULT_PORTAL_IMG; var team = portal.options.team; + var now = new Date(); + var now_ms = now.getTime();// + (now.getTimezoneOffset() * 60000); + var age_string_long = 'This portal has never been 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++; @@ -131,7 +142,26 @@ window.plugin.portalslist.getPortals = function() { }); console.log(mods); 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}; + 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); }); @@ -266,7 +296,8 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { + '