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:
parent
328360c7e7
commit
1cf3fbe15d
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @id iitc-plugin-portals-count@yenky
|
// @id iitc-plugin-portals-count@yenky
|
||||||
// @name IITC plugin: Show total counts of portals
|
// @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
|
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||||
// @updateURL @@UPDATEURL@@
|
// @updateURL @@UPDATEURL@@
|
||||||
// @downloadURL @@DOWNLOADURL@@
|
// @downloadURL @@DOWNLOADURL@@
|
||||||
@ -27,99 +27,78 @@ if(typeof window.plugin !== 'function') window.plugin = function() {};
|
|||||||
|
|
||||||
// use own namespace for plugin
|
// use own namespace for plugin
|
||||||
window.plugin.portalcounts = function() {};
|
window.plugin.portalcounts = function() {};
|
||||||
window.VIEWPORT_PAD_RATIO = 0.1;
|
window.VIEWPORT_PAD_RATIO = 0.1;
|
||||||
|
|
||||||
//count portals for each level avalaible on the map
|
//count portals for each level avalaible on the map
|
||||||
window.plugin.portalcounts.getPortals = function(){
|
window.plugin.portalcounts.getPortals = function(){
|
||||||
//console.log('** getPortals');
|
//console.log('** getPortals');
|
||||||
// just count portals in viewport, default: 0.3
|
// just count portals in viewport, default: 0.3
|
||||||
var retval=false;
|
var retval=false;
|
||||||
window.plugin.portalcounts.enlP = 0;
|
window.plugin.portalcounts.enlP = 0;
|
||||||
window.plugin.portalcounts.resP = 0;
|
window.plugin.portalcounts.resP = 0;
|
||||||
window.plugin.portalcounts.neuP = 0;
|
window.plugin.portalcounts.neuP = 0;
|
||||||
|
|
||||||
window.plugin.portalcounts.PortalsEnl = new Array();
|
window.plugin.portalcounts.PortalsEnl = new Array();
|
||||||
window.plugin.portalcounts.PortalsEnl[1] = 0;
|
window.plugin.portalcounts.PortalsRes = new Array();
|
||||||
window.plugin.portalcounts.PortalsEnl[2] = 0;
|
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
|
||||||
window.plugin.portalcounts.PortalsEnl[3] = 0;
|
window.plugin.portalcounts.PortalsEnl[level] = 0;
|
||||||
window.plugin.portalcounts.PortalsEnl[4] = 0;
|
window.plugin.portalcounts.PortalsRes[level] = 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();
|
|
||||||
|
|
||||||
$.each(window.portals, function(i, portal) {
|
$.each(window.portals, function(i, portal) {
|
||||||
|
retval=true;
|
||||||
retval=true;
|
var d = portal.options.details;
|
||||||
var d = portal.options.details;
|
var team = portal.options.team;
|
||||||
var team = portal.options.team;
|
var level = Math.floor(getPortalLevel(d));
|
||||||
var level = Math.floor(getPortalLevel(d));
|
switch (team){
|
||||||
switch (team){
|
case 1 :
|
||||||
case 1 :
|
window.plugin.portalcounts.resP++;
|
||||||
window.plugin.portalcounts.resP++;
|
window.plugin.portalcounts.PortalsRes[level]++;
|
||||||
window.plugin.portalcounts.PortalsRes[level]++;
|
break;
|
||||||
break;
|
case 2 :
|
||||||
case 2 :
|
window.plugin.portalcounts.enlP++;
|
||||||
window.plugin.portalcounts.enlP++;
|
window.plugin.portalcounts.PortalsEnl[level]++;
|
||||||
window.plugin.portalcounts.PortalsEnl[level]++;
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
window.plugin.portalcounts.neuP++;
|
||||||
window.plugin.portalcounts.neuP++;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
});
|
//get portals informations from IITC
|
||||||
var counts = '<table>';
|
var minlvl = getMinPortalLevel();
|
||||||
if(retval) {
|
|
||||||
counts += '<tr class="enl"><th colspan="2">Enlightment: '+window.plugin.portalcounts.enlP+' Portal(s)</th></tr>';
|
var counts = '<table>';
|
||||||
for (level in window.plugin.portalcounts.PortalsEnl) {
|
if(retval) {
|
||||||
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>';
|
||||||
if(minlvl > level)
|
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
|
||||||
counts += 'zoom in';
|
counts += '<tr><td class="L'+level+'">Level '+level+'</td>';
|
||||||
else
|
if(minlvl > level)
|
||||||
counts += window.plugin.portalcounts.PortalsEnl[level];
|
counts += '<td colspan="2">zoom in to see portals in this level</td>';
|
||||||
counts += '</td></tr>';
|
else
|
||||||
}
|
counts += '<td class="enl">'+window.plugin.portalcounts.PortalsEnl[level]+'</td><td class="res">'+window.plugin.portalcounts.PortalsRes[level]+'</td>';
|
||||||
counts += '<tr><td colspan="2"> </td></tr>';
|
counts += '</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 colspan="3"> </td></tr>';
|
||||||
counts += '<tr><td class="L'+level+'">Level '+level+'</td><td>'
|
counts += '<tr class="neutral"><td>Neutral:</td><td colspan="2">';
|
||||||
if(minlvl > level)
|
if(minlvl > 0)
|
||||||
counts += 'zoom in';
|
counts += 'zoom in to see unclaimed';
|
||||||
else
|
else
|
||||||
counts += window.plugin.portalcounts.PortalsRes[level];
|
counts += window.plugin.portalcounts.neuP;
|
||||||
counts += '</td></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><td colspan="2"> </td></tr>';
|
counts += '<tr class="res"><td colspan="2">Resistance:</td><td>'+window.plugin.portalcounts.resP+' Portal(s)</td></tr>';
|
||||||
counts += '<tr class="neutral"><th colspan="2">Neutral: ';
|
} else
|
||||||
if(minlvl > 0)
|
counts += '<tr><td>No Portals in range !</td></tr>';
|
||||||
counts += 'zoom in to see unclaimed';
|
counts += '</table>';
|
||||||
else
|
alert('<div id="portalcounts">'+counts+'</div>');
|
||||||
counts += window.plugin.portalcounts.neuP;
|
|
||||||
counts += ' Portal(s)</th></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>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var setup = function() {
|
var setup = function() {
|
||||||
$('body').append('<div id="portalcounts" style="display:none;"></div>');
|
$('body').append('<div id="portalcounts" style="display:none;"></div>');
|
||||||
$('#toolbox').append('<a onclick="window.plugin.portalcounts.getPortals()">Portalcounts</a>');
|
$('#toolbox').append('<a onclick="window.plugin.portalcounts.getPortals()">Portalcounts</a>');
|
||||||
$('head').append('<style>' +
|
$('head').append('<style>' +
|
||||||
'#portalcounts table {margin-top:5px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
|
'#portalcounts table {margin-top:5px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
|
||||||
'#portalcounts table td, #portalcounts table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' +
|
'#portalcounts table td, #portalcounts table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' +
|
||||||
'#portalcounts table tr.res th { background-color: #005684; }' +
|
'#portalcounts table tr.res th { background-color: #005684; }' +
|
||||||
'#portalcounts table tr.enl th { background-color: #017f01; }' +
|
'#portalcounts table tr.enl th { background-color: #017f01; }' +
|
||||||
@ -137,7 +116,6 @@ var setup = function() {
|
|||||||
'#portalcounts table td.L8 { background-color: #9627F4 !important;}' +
|
'#portalcounts table td.L8 { background-color: #9627F4 !important;}' +
|
||||||
'#portalcounts table td:nth-child(1) { text-align: left;}' +
|
'#portalcounts table td:nth-child(1) { text-align: left;}' +
|
||||||
'#portalcounts table th:nth-child(1) { text-align: left;}' +
|
'#portalcounts table th:nth-child(1) { text-align: left;}' +
|
||||||
'#portalcounts .disclaimer { margin-top:10px; font-size:10px; }' +
|
|
||||||
'</style>');
|
'</style>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user