From 9a7856e28e8fc283e891f6e4d57c136220a84a62 Mon Sep 17 00:00:00 2001 From: teo96 Date: Wed, 12 Jun 2013 22:40:33 +0200 Subject: [PATCH] 0.0.14: Add support to new mods (S:Shield - T:Turret - LA:Link Amp - H:Heat-sink - M:Multi-hack - FA:Force Amp) --- plugins/portals-list.user.js | 74 ++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/plugins/portals-list.user.js b/plugins/portals-list.user.js index 38b3023e..f5923b41 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.13.@@DATETIMEVERSION@@ +// @version 0.0.14.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -15,6 +15,7 @@ // ==/UserScript== /* whatsnew +* 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 @@ -95,19 +96,44 @@ window.plugin.portalslist.getPortals = function() { // Sort resonators array by resonator level resonators.sort(function (a, b) {return b[0] - a[0]}); - //get shield informations - var shields = []; + //get mods informations + var mods = []; $.each(d.portalV2.linkedModArray, function(ind, mod) { - if (mod) { - //shields[ind] = mod.rarity.capitalize().replace('_', ' '); - shields[ind] = [mod.rarity.substr(0,1).capitalize(), getPlayerName(mod.installingUser)] ; - } else { - shields[ind] = ['', '']; - } + 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 { + mods[ind] = [mod.rarity, getPlayerName(mod.installingUser), modShortName, mod.displayName]; + } + }else { mods[ind] = ['', '', '']; } }); - + 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, 'shields': shields, '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}; window.plugin.portalslist.listPortals.push(thisPortal); }); @@ -200,16 +226,16 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { retVal = b.resonators[7][0] - a.resonators[7][0]; break; case 's1': - retVal = a.shields[0].toLowerCase() > b.shields[0].toLowerCase() ? -1 : 1; + retVal = a.mods[0][2] > b.mods[0][2] ? -1 : 1; break; case 's2': - retVal = a.shields[1].toLowerCase() > b.shields[1].toLowerCase() ? -1 : 1; + retVal = a.mods[1][2] > b.mods[1][2] ? -1 : 1; break; case 's3': - retVal = a.shields[2].toLowerCase() > b.shields[2].toLowerCase() ? -1 : 1; + retVal = a.mods[2][2] > b.mods[2][2] ? -1 : 1; break; case 's4': - retVal = a.shields[3].toLowerCase() > b.shields[3].toLowerCase() ? -1 : 1; + retVal = a.mods[3][2] > b.mods[3][2] ? -1 : 1; break; default: retVal = b[sortBy] - a[sortBy]; @@ -236,10 +262,10 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { + 'Energy' + '%' + 'Links' - + 'S1' - + 'S2' - + 'S3' - + 'S4' + + 'M1' + + 'M2' + + 'M3' + + 'M4' + 'AP Gain' + 'E/AP'; @@ -264,13 +290,13 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { }); - html += '' + prettyEnergy(portal.energy) + '' + html += '' + prettyEnergy(portal.energy) + '' + '' + portal.energyratio + '%' + '' + portal.links + '' - + '' + portal.shields[0][0] + '' - + '' + portal.shields[1][0] + '' - + '' + portal.shields[2][0] + '' - + '' + portal.shields[3][0] + '' + + '' + portal.mods[0][2] + '' + + '' + portal.mods[1][2] + '' + + '' + portal.mods[2][2] + '' + + '' + portal.mods[3][2] + '' + '' + portal.APgain + '' + '' + portal.EAP + '';