Style tweak and new highligher

This commit is contained in:
vita10gy 2013-04-12 23:57:53 -05:00
parent 135d4b893d
commit f0f621acb6
2 changed files with 96 additions and 1 deletions

View File

@ -31,7 +31,8 @@ window.portalHighlighterControl = function() {
});
$("#portal_highlight_select").val(_current_highlighter);
$("#portal_highlight_select").change(function(){ changePortalHighlights($(this).val());});
$(".leaflet-top.leaflet-left").css('margin-top','25px');
$(".leaflet-top.leaflet-left").css('padding-top','25px');
$(".leaflet-control-scale-line").css('margin-top','25px');
}
}

View File

@ -0,0 +1,94 @@
// ==UserScript==
// @id iitc-plugin-highlight-portals-upgrade@vita10gy
// @name IITC plugin: highlight portals you can upgrade to a specific level
// @version 0.1.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Uses the fill color of the portals to highlight portals you can upgrade to a specific level.
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.portalHighligherPortalsCanMakeLevel = function() {};
window.plugin.portalHighligherPortalsCanMakeLevel.highlight = function(data,highlight_level) {
var d = data.portal.options.details;
var current_level = Math.floor(getPortalLevel(d));
var potential_level = Math.floor(window.potentialPortalLevel(d));
var opacity = .7;
console.log(current_level + ' ' + potential_level+ ' ' + highlight_level);
if( potential_level > current_level && potential_level === highlight_level) {
color = 'red';
data.portal.setStyle({fillColor: color, fillOpacity: opacity});
} else {
data.portal.setStyle({color: COLORS[getTeam(data.portal.options.details)],
fillOpacity: 0.5});
}
window.COLOR_SELECTED_PORTAL = '#f0f';
}
//determines the level of poral a user can make all on their own
window.plugin.portalHighligherPortalsCanMakeLevel.playerCanSoloLevel = function(lvl) {
var renators_total = 0;
var renators_placed = 0;
var resonator_level = PLAYER.level
while(renators_placed < 8) {
for(var i = 0; i<MAX_RESO_PER_PLAYER[resonator_level]; i++) {
if(renators_placed < 8) {
renators_total += resonator_level;
renators_placed++;
}
}
resonator_level--;
}
return(Math.floor(renators_total/8));
}
window.plugin.portalHighligherPortalsCanMakeLevel.getHighlighter = function(lvl) {
return(function(data){
console.log(lvl);
window.plugin.portalHighligherPortalsCanMakeLevel.highlight(data,lvl);
});
}
var setup = function() {
// This is the maximum level of a portal a user can be the "last peice of"
// yes, even a level 1 can be the difference in bumping a portal up to level 7
var max_can_complete = 7;
if(PLAYER.level === 8) {
max_can_complete = 8;
}
// The rational behind the "minimum" level below is that showing a level 7 player, for example, all the portals they can make
// a level 5 would be silly, as they can make ANY portal a level 5.
for(var ptl_lvl = window.plugin.portalHighligherPortalsCanMakeLevel.playerCanSoloLevel()+1; ptl_lvl<=max_can_complete; ptl_lvl++) {
window.addPortalHighlighter('Can Make Level ' + ptl_lvl, window.plugin.portalHighligherPortalsCanMakeLevel.getHighlighter(ptl_lvl));
}
}
// PLUGIN END //////////////////////////////////////////////////////////
if(window.iitcLoaded && typeof setup === 'function') {
setup();
} else {
if(window.bootPlugins)
window.bootPlugins.push(setup);
else
window.bootPlugins = [setup];
}
} // wrapper end
// inject code into site context
var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script);