diff --git a/plugins/ap-list.css b/plugins/ap-list.css index 1ccb441c..c54365f6 100644 --- a/plugins/ap-list.css +++ b/plugins/ap-list.css @@ -46,11 +46,16 @@ } .ap-list-td-link-eny { - width: 80%; + width: 70%; } .ap-list-td-link-frd { - width: 85%; + width: 75%; +} + +.ap-list-td-ap { + width: 18%; + white-space:nowrap; } .ap-list-checkbox-outer { diff --git a/plugins/ap-list.user.js b/plugins/ap-list.user.js index 7185b3cf..d94203f7 100644 --- a/plugins/ap-list.user.js +++ b/plugins/ap-list.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @id iitc-plugin-ap-list@xelio // @name IITC plugin: AP List -// @version 0.4.2.@@DATETIMEVERSION@@ +// @version 0.4.3.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -33,6 +33,7 @@ window.plugin.apList.playerApGainFunc = new Array(2); window.plugin.apList.topMaxCount = 10; window.plugin.apList.sideLabelClass = {}; +window.plugin.apList.tableColumns = new Array(2); window.plugin.apList.useCachedPortals = false; window.plugin.apList.cacheBounds; @@ -52,32 +53,51 @@ window.plugin.apList.handleUpdate = function() { // Generate html table from top portals window.plugin.apList.updatePortalTable = function(side) { - var displayEnemy = (plugin.apList.displaySide === window.plugin.apList.SIDE_ENEMY); - - var content = ''; + var table = '
' + + '' + + plugin.apList.tableHeaderBuilder(side) + + ''; + for(var i = 0; i < plugin.apList.topMaxCount; i++) { var portal = plugin.apList.sortedPortals[side][i]; - content += ''; - // Only enemy portal list will display destroy checkbox - if(displayEnemy) { - content += ''; - } - content += '' - + '' - + '' - + ''; + table += '' + + plugin.apList.tableRowBuilder(side, portal) + + ''; } - content += "
' - + (portal ? plugin.apList.getPortalDestroyCheckbox(portal) : ' ') - + '' - + (portal ? plugin.apList.getPortalApText(portal) : ' ') - + '' - + (portal ? plugin.apList.getPortalEffectiveLvText(portal) : ' ') - + '
"; - $('div#ap-list-table').html(content); + + table += ""; + $('div#ap-list-table').html(table); +} + +window.plugin.apList.tableHeaderBuilder = function(side) { + var headerRow = ''; + + $.each(plugin.apList.tableColumns[side], function(ind, column){ + var cssClass = column.headerTooltip ? (column.cssClass + ' help') : column.cssClass; + var title = column.headerTooltip ? column.headerTooltip : ''; + headerRow += '' + + column.header + + ''; + }); + + headerRow += ''; + return headerRow; +} + +window.plugin.apList.tableRowBuilder = function(side,portal) { + var row = ""; + + $.each(plugin.apList.tableColumns[side], function(ind, column){ + var content = portal ? column.contentFunction(portal) : ' '; + row += '' + + content + + ''; + }); + + row += ''; + return row; } window.plugin.apList.getPortalDestroyCheckbox = function(portal) { @@ -152,7 +172,8 @@ window.plugin.apList.getPortalEffectiveLvText = function(portal) { window.plugin.apList.getPortalEffectiveLvTitle = function(portal) { var t = 'Effective energy:\t' + portal.effectiveLevel.effectiveEnergy + '\n' + 'Effect of Shields:\t' + portal.effectiveLevel.effectOfShields + '\n' - + 'Effect of resos dist:\t' + portal.effectiveLevel.effectOfResoDistance + '\n'; + + 'Effect of resos dist:\t' + portal.effectiveLevel.effectOfResoDistance + '\n' + + 'Origin Level:\t' + portal.effectiveLevel.originLevel; return t; } @@ -469,7 +490,8 @@ window.plugin.apList.getEffectiveLevel = function(portal) { effectiveLevel: effectiveLevel.toFixed(1), effectiveEnergy: parseInt(effectiveEnergy), effectOfShields: effectOfShields.toFixed(2), - effectOfResoDistance: effectOfResoDistance.toFixed(2) + effectOfResoDistance: effectOfResoDistance.toFixed(2), + originLevel: portalLevel }; } @@ -597,6 +619,52 @@ window.plugin.apList.setupVar = function() { = "#ap-list-eny"; } +// Setup table columns for header builder and row builder +window.plugin.apList.setupTableColumns = function() { + var enemyColumns = new Array(); + var friendlyColumns = new Array(); + + // AP and Eff. LV columns are same in enemy and friendly table + var apColumn = { + header: 'AP', + cssClass: 'ap-list-td-ap', + contentFunction: plugin.apList.getPortalApText + }; + var effectiveLevelColumn = { + header: 'EL', + headerTooltip: 'Effective Level', + cssClass: 'ap-list-td-eff-lv', + contentFunction: plugin.apList.getPortalEffectiveLvText + }; + + // Columns: Checkbox | Portal | AP | Eff. LV + enemyColumns.push({ + header: '', + headerTooltip: 'Select checkbox to \nsimulating destruction', + cssClass: 'ap-list-td-checkbox', + contentFunction: plugin.apList.getPortalDestroyCheckbox + }); + enemyColumns.push({ + header: 'Portal', + cssClass: 'ap-list-td-link ap-list-td-link-eny', + contentFunction: plugin.apList.getPortalLink + }); + enemyColumns.push(apColumn); + enemyColumns.push(effectiveLevelColumn); + + // Columns: Portal | AP | Eff. LV + friendlyColumns.push({ + header: 'Portal', + cssClass: 'ap-list-td-link ap-list-td-link-frd', + contentFunction: plugin.apList.getPortalLink + }); + friendlyColumns.push(apColumn); + friendlyColumns.push(effectiveLevelColumn); + + plugin.apList.tableColumns[plugin.apList.SIDE_ENEMY] = enemyColumns; + plugin.apList.tableColumns[plugin.apList.SIDE_FRIENDLY] = friendlyColumns; +} + window.plugin.apList.setupCSS = function() { $("