From 023c1d3ec8d028e7b32ab9b4eef500b374dc53c5 Mon Sep 17 00:00:00 2001 From: Xelio Date: Thu, 28 Mar 2013 02:00:41 +0800 Subject: [PATCH] Plugin AP List: Add stats tooltip to show total AP, average EL of selected portals. --- plugins/ap-list.css | 16 +++++++++++++--- plugins/ap-list.user.js | 34 +++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/plugins/ap-list.css b/plugins/ap-list.css index 4f4830f4..c4857820 100644 --- a/plugins/ap-list.css +++ b/plugins/ap-list.css @@ -93,9 +93,8 @@ } .ap-list-center-div { - width: 50%; + width: 55%; margin: 0px auto; - } .ap-list-page-control { @@ -145,4 +144,15 @@ .ap-list-triangle-right-full { border-width: 7.5px 0px 7.5px 13px; -} \ No newline at end of file +} +#ap-list-pagination { + display: inline-block; + width: 90%; + vertical-align: bottom; +} + +#ap-list-misc-info { + display: inline-block; + vertical-align: bottom; + padding: 0px 6px; +} diff --git a/plugins/ap-list.user.js b/plugins/ap-list.user.js index 1a6b715d..3bc172a1 100644 --- a/plugins/ap-list.user.js +++ b/plugins/ap-list.user.js @@ -79,6 +79,7 @@ window.plugin.apList.updatePortalTable = function(side) { $('div#ap-list-table').html(table); plugin.apList.updatePaginationControl(); + plugin.apList.updateStats(); } window.plugin.apList.tableHeaderBuilder = function(side) { @@ -169,7 +170,7 @@ window.plugin.apList.getPortalApTitle = function(portal) { window.plugin.apList.getPortalEffectiveLvText = function(portal) { var title = plugin.apList.getPortalEffectiveLvTitle(portal); - return '
' + portal.effectiveLevel.effectiveLevel + '
'; + return '
' + portal.effectiveLevel.effectiveLevel.toFixed(1) + '
'; } window.plugin.apList.getPortalEffectiveLvTitle = function(portal) { @@ -211,6 +212,28 @@ window.plugin.apList.updatePaginationControl = function() { $('#ap-list-total-p').html(plugin.apList.totalPage[plugin.apList.displaySide]); } +window.plugin.apList.updateStats = function() { + var destroyPortals = plugin.apList.destroyPortalsGuid.length; + if(destroyPortals === 0) { + title = 'Stats'; + } else { + var destroyAP = 0; + var averageEL = 0; + $.each(plugin.apList.destroyPortalsGuid, function(ind,guid) { + destroyAP += plugin.apList.cachedPortals[guid].playerApGain.totalAp; + averageEL += plugin.apList.cachedPortals[guid].effectiveLevel.effectiveLevel; + }); + averageEL = Math.round(averageEL / destroyPortals * 10) / 10; + + var title = 'Stats\n' + + 'Selected portal(s)\t=\t' + destroyPortals + '\n' + + 'Total AP\t=\t' + destroyAP + '\n' + + 'Average EL\t=\t' + averageEL; + } + + $('#ap-list-misc-info').attr('title', title); +} + // MAIN LOGIC FUNCTIONS ////////////////////////////////////////////////////////// // Loop through portals and get playerApGain, then put in sortedPortals by side and sort them by AP. @@ -498,10 +521,10 @@ window.plugin.apList.getEffectiveLevel = function(portal) { } return { - effectiveLevel: effectiveLevel.toFixed(1), + effectiveLevel: Math.round(effectiveLevel * 10) / 10, effectiveEnergy: parseInt(effectiveEnergy), - effectOfShields: effectOfShields.toFixed(2), - effectOfResoDistance: effectOfResoDistance.toFixed(2), + effectOfShields: Math.round(effectOfShields * 100) / 100, + effectOfResoDistance: Math.round(effectOfResoDistance * 100) / 100, originLevel: portalLevel }; } @@ -821,7 +844,8 @@ window.plugin.apList.setupList = function() { + 'plugin.apList.hideReloadLabel();return false;">↻ R' + '' + '
' - + '
' + + '...' + + '' + ''; $('#sidebar').append(content);