Portal Highlighter - Initial Check in
This commit is contained in:
@ -149,12 +149,14 @@ window.handlePortalsRender = function(portals) {
|
||||
// Preserve selectedPortal because it will get lost on re-rendering
|
||||
// the portal
|
||||
var oldSelectedPortal = selectedPortal;
|
||||
|
||||
runHooks('portalDataLoaded', {portals : portals});
|
||||
$.each(portals, function(ind, portal) {
|
||||
//~ if(selectedPortal === portal[0]) portalUpdateAvailable = true;
|
||||
if(urlPortal && portal[0] === urlPortal) portalInUrlAvailable = true;
|
||||
renderPortal(portal);
|
||||
if(window.portals[portal[0]]) {
|
||||
highlightPortal(window.portals[portal[0]]);
|
||||
}
|
||||
renderPortal(portal);
|
||||
});
|
||||
|
||||
// restore selected portal if still available
|
||||
@ -256,7 +258,7 @@ window.renderPortal = function(ent) {
|
||||
// do nothing if portal did not change
|
||||
var layerGroup = portalsLayers[parseInt(portalLevel)];
|
||||
var old = findEntityInLeaflet(layerGroup, window.portals, ent[0]);
|
||||
if(old) {
|
||||
if(!changing_highlighters && old) {
|
||||
var oo = old.options;
|
||||
|
||||
// Default checks to see if a portal needs to be re-rendered
|
||||
@ -304,6 +306,7 @@ window.renderPortal = function(ent) {
|
||||
clickable: true,
|
||||
level: portalLevel,
|
||||
team: team,
|
||||
ent: ent,
|
||||
details: ent[2],
|
||||
guid: ent[0]});
|
||||
|
||||
@ -341,7 +344,7 @@ window.renderPortal = function(ent) {
|
||||
});
|
||||
|
||||
window.renderResonators(ent, null);
|
||||
|
||||
highlightPortal(p);
|
||||
window.runHooks('portalAdded', {portal: p});
|
||||
p.addTo(layerGroup);
|
||||
}
|
||||
|
55
code/portal_highlighter.js
Normal file
55
code/portal_highlighter.js
Normal file
@ -0,0 +1,55 @@
|
||||
// Portal Highlighter //////////////////////////////////////////////////////////
|
||||
// these functions handle portal highlighters
|
||||
|
||||
|
||||
window._highlighters = null;
|
||||
window._current_highlighter = localStorage.portal_highlighter;
|
||||
window.changing_highlighters = false;
|
||||
|
||||
window.addPortalHighlighter = function(name, callback) {
|
||||
console.log("Regisering Portal Highlighter: " + name);
|
||||
if(_highlighters === null) {
|
||||
_highlighters = {};
|
||||
}
|
||||
_highlighters[name] = callback;
|
||||
portalHighlighterControl();
|
||||
}
|
||||
|
||||
window.portalHighlighterControl = function() {
|
||||
if(_highlighters !== null) {
|
||||
if($('#portal_highlight_select').length === 0) {
|
||||
$("body").append("<select id='portal_highlight_select'></select>");
|
||||
}
|
||||
$("#portal_highlight_select").html('');
|
||||
$("#portal_highlight_select").append($("<option>").attr('value','No Highlights').text('No Highlights'));
|
||||
$.each(_highlighters, function(name, callback) {
|
||||
$("#portal_highlight_select").append($("<option>").attr('value',name).text(name));
|
||||
});
|
||||
$("#portal_highlight_select").val(localStorage.portal_highlighter);
|
||||
$("#portal_highlight_select").change(function(){ changePortalHighlights($(this).val());});
|
||||
}
|
||||
}
|
||||
|
||||
window.changePortalHighlights = function(name) {
|
||||
changing_highlighters = true;
|
||||
_current_highlighter = name;
|
||||
resetHighlightedPortals();
|
||||
changing_highlighters = false;
|
||||
localStorage.portal_highlighter = name;
|
||||
}
|
||||
|
||||
window.highlightPortal = function(p) {
|
||||
if(_highlighters !== null && _highlighters[_current_highlighter] !== undefined) {
|
||||
p.options.highligher = _current_highlighter;
|
||||
_highlighters[_current_highlighter]({portal: p});
|
||||
}
|
||||
}
|
||||
|
||||
window.resetHighlightedPortals = function() {
|
||||
$.each(portals, function(ind, portal) {
|
||||
try {
|
||||
renderPortal(portal.options.ent);
|
||||
}
|
||||
catch(e) {}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user