reverse show order of portals

using MAX_PORTAL_LEVEL now for array
changed table layout to be more compact
cleaned up code
This commit is contained in:
YenkyK 2013-03-25 22:23:46 +01:00
parent 328360c7e7
commit 1cf3fbe15d

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @id iitc-plugin-portals-count@yenky
// @name IITC plugin: Show total counts of portals
// @version 0.0.3.@@DATETIMEVERSION@@
// @version 0.0.4.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -39,28 +39,13 @@ window.plugin.portalcounts.getPortals = function(){
window.plugin.portalcounts.neuP = 0;
window.plugin.portalcounts.PortalsEnl = new Array();
window.plugin.portalcounts.PortalsEnl[1] = 0;
window.plugin.portalcounts.PortalsEnl[2] = 0;
window.plugin.portalcounts.PortalsEnl[3] = 0;
window.plugin.portalcounts.PortalsEnl[4] = 0;
window.plugin.portalcounts.PortalsEnl[5] = 0;
window.plugin.portalcounts.PortalsEnl[6] = 0;
window.plugin.portalcounts.PortalsEnl[7] = 0;
window.plugin.portalcounts.PortalsEnl[8] = 0;
window.plugin.portalcounts.PortalsRes = new Array();
window.plugin.portalcounts.PortalsRes[1] = 0;
window.plugin.portalcounts.PortalsRes[2] = 0;
window.plugin.portalcounts.PortalsRes[3] = 0;
window.plugin.portalcounts.PortalsRes[4] = 0;
window.plugin.portalcounts.PortalsRes[5] = 0;
window.plugin.portalcounts.PortalsRes[6] = 0;
window.plugin.portalcounts.PortalsRes[7] = 0;
window.plugin.portalcounts.PortalsRes[8] = 0;
//get portals informations from IITC
var minlvl = getMinPortalLevel();
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
window.plugin.portalcounts.PortalsEnl[level] = 0;
window.plugin.portalcounts.PortalsRes[level] = 0;
}
$.each(window.portals, function(i, portal) {
retval=true;
var d = portal.options.details;
var team = portal.options.team;
@ -78,40 +63,34 @@ window.plugin.portalcounts.getPortals = function(){
window.plugin.portalcounts.neuP++;
break;
}
});
//get portals informations from IITC
var minlvl = getMinPortalLevel();
var counts = '<table>';
if(retval) {
counts += '<tr class="enl"><th colspan="2">Enlightment: '+window.plugin.portalcounts.enlP+' Portal(s)</th></tr>';
for (level in window.plugin.portalcounts.PortalsEnl) {
counts += '<tr><td class="L'+level+'">Level '+level+'</td><td>';
counts += '<tr><th></th><th class="enl">Enlightment</th><th class="res">Resistance</th></tr>'; //'+window.plugin.portalcounts.enlP+' Portal(s)</th></tr>';
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
counts += '<tr><td class="L'+level+'">Level '+level+'</td>';
if(minlvl > level)
counts += 'zoom in';
counts += '<td colspan="2">zoom in to see portals in this level</td>';
else
counts += window.plugin.portalcounts.PortalsEnl[level];
counts += '</td></tr>';
counts += '<td class="enl">'+window.plugin.portalcounts.PortalsEnl[level]+'</td><td class="res">'+window.plugin.portalcounts.PortalsRes[level]+'</td>';
counts += '</tr>';
}
counts += '<tr><td colspan="2">&nbsp</td></tr>';
counts += '<tr class="res"><th colspan="2">Resistance: '+window.plugin.portalcounts.resP+' Portal(s)</th></tr>';
for (level in window.plugin.portalcounts.PortalsRes) {
counts += '<tr><td class="L'+level+'">Level '+level+'</td><td>'
if(minlvl > level)
counts += 'zoom in';
else
counts += window.plugin.portalcounts.PortalsRes[level];
counts += '</td></tr>';
}
counts += '<tr><td colspan="2">&nbsp</td></tr>';
counts += '<tr class="neutral"><th colspan="2">Neutral: ';
counts += '<tr><td colspan="3">&nbsp</td></tr>';
counts += '<tr class="neutral"><td>Neutral:</td><td colspan="2">';
if(minlvl > 0)
counts += 'zoom in to see unclaimed';
else
counts += window.plugin.portalcounts.neuP;
counts += ' Portal(s)</th></tr>';
counts += ' Portal(s)</td></tr>';
counts += '<tr class="enl"><td colspan="2">Enlightment:</td><td>'+window.plugin.portalcounts.enlP+' Portal(s)</td></tr>';
counts += '<tr class="res"><td colspan="2">Resistance:</td><td>'+window.plugin.portalcounts.resP+' Portal(s)</td></tr>';
} else
counts += '<tr><td>No Portals in range !</td></tr>';
counts += '</table>';
counts += '<div class="disclaimer">Thanks to @teo96 for his plugin as base for me. Work done by <a href="https://plus.google.com/u/0/117983231123575373020">@yenky</a>. Be enlightened!</div>';
alert('<div id="portalcounts">'+counts+'</div>');
}
@ -137,7 +116,6 @@ var setup = function() {
'#portalcounts table td.L8 { background-color: #9627F4 !important;}' +
'#portalcounts table td:nth-child(1) { text-align: left;}' +
'#portalcounts table th:nth-child(1) { text-align: left;}' +
'#portalcounts .disclaimer { margin-top:10px; font-size:10px; }' +
'</style>');
}