Code restructure
This commit is contained in:
parent
1ed2ee8e8c
commit
eab812fbf6
@ -339,26 +339,25 @@ window.renderResonators = function(ent, portalLayer) {
|
|||||||
var resoGuid = portalResonatorGuid(ent[0], i);
|
var resoGuid = portalResonatorGuid(ent[0], i);
|
||||||
|
|
||||||
// the resonator
|
// the resonator
|
||||||
var reso = L.circleMarker(Rlatlng, {
|
var resoProperty = $.extend({
|
||||||
radius: ent[0] == selectedPortal ? RADIUS_SELECTED_PORTAL_RESONATOR: RADIUS_NON_SELECTED_PORTAL_RESONATOR,
|
|
||||||
// #AAAAAA outline seems easier to see the fill opacity
|
|
||||||
color: ent[0] == selectedPortal ? COLOR_SELECTED_PORTAL_RESONATOR : COLOR_NON_SELECTED_PORTAL_RESONATOR,
|
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
weight: ent[0] == selectedPortal ? WEIGHT_SELECTED_PORTAL_RESONATOR : WEIGHT_NON_SELECTED_PORTAL_RESONATOR,
|
|
||||||
fillColor: COLORS_LVL[rdata.level],
|
fillColor: COLORS_LVL[rdata.level],
|
||||||
fillOpacity: rdata.energyTotal/RESO_NRG[rdata.level],
|
fillOpacity: rdata.energyTotal/RESO_NRG[rdata.level],
|
||||||
clickable: false,
|
clickable: false,
|
||||||
guid: resoGuid // need this here as well for add/remove events
|
guid: resoGuid
|
||||||
});
|
}, ent[0] == selectedPortal ? OPTIONS_RESONATOR_SELECTED : OPTIONS_RESONATOR_NON_SELECTED);
|
||||||
|
|
||||||
|
var reso = L.circleMarker(Rlatlng, resoProperty);
|
||||||
|
|
||||||
// line connecting reso to portal
|
// line connecting reso to portal
|
||||||
var conn = L.polyline([portalLatLng, Rlatlng], {
|
var connProperty = $.extend({
|
||||||
weight: ent[0] == selectedPortal ? WEIGHT_SELECTED_PORTAL_RESONATOR_LINE : WEIGHT_NON_SELECTED_PORTAL_RESONATOR_LINE,
|
|
||||||
color: '#FFA000',
|
color: '#FFA000',
|
||||||
opacity: ent[0] == selectedPortal ? OPACITY_SELECTED_PORTAL_RESONATOR_LINE : OPACITY_NON_SELECTED_PORTAL_RESONATOR_LINE,
|
|
||||||
dashArray: '0,10,8,4,8,4,8,4,8,4,8,4,8,4,8,4,8,4,8,4',
|
dashArray: '0,10,8,4,8,4,8,4,8,4,8,4,8,4,8,4,8,4,8,4',
|
||||||
fill: false,
|
fill: false,
|
||||||
clickable: false});
|
clickable: false
|
||||||
|
}, ent[0] == selectedPortal ? OPTIONS_RESONATOR_LINE_SELECTED : OPTIONS_RESONATOR_LINE_NON_SELECTED);
|
||||||
|
|
||||||
|
var conn = L.polyline([portalLatLng, Rlatlng], connProperty);
|
||||||
|
|
||||||
|
|
||||||
// put both in one group, so they can be handled by the same logic.
|
// put both in one group, so they can be handled by the same logic.
|
||||||
@ -413,16 +412,14 @@ window.portalResetColor = function(portal) {
|
|||||||
window.resonatorsResetStyle = function(portalGuid) {
|
window.resonatorsResetStyle = function(portalGuid) {
|
||||||
for(var i = 0; i < 8; i++) {
|
for(var i = 0; i < 8; i++) {
|
||||||
resonatorLayerGroup = resonators[portalResonatorGuid(portalGuid, i)];
|
resonatorLayerGroup = resonators[portalResonatorGuid(portalGuid, i)];
|
||||||
//console.log('reset:'+i+','+resonatorLayerGroup);
|
|
||||||
if(!resonatorLayerGroup) continue;
|
if(!resonatorLayerGroup) continue;
|
||||||
resonatorLayerGroup.eachLayer(function(layer) {
|
resonatorLayerGroup.eachLayer(function(layer) {
|
||||||
if (layer.options.guid) {
|
if (layer.options.guid) {
|
||||||
layer.setStyle({color: COLOR_NON_SELECTED_PORTAL_RESONATOR,
|
// Resonator
|
||||||
radius: RADIUS_NON_SELECTED_PORTAL_RESONATOR,
|
layer.setStyle(OPTIONS_RESONATOR_NON_SELECTED);
|
||||||
weight: WEIGHT_NON_SELECTED_PORTAL_RESONATOR});
|
|
||||||
} else {
|
} else {
|
||||||
layer.setStyle({opacity: OPACITY_NON_SELECTED_PORTAL_RESONATOR_LINE,
|
// Resonator line
|
||||||
weight: WEIGHT_NON_SELECTED_PORTAL_RESONATOR_LINE});
|
layer.setStyle(OPTIONS_RESONATOR_LINE_NON_SELECTED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -434,12 +431,11 @@ window.resonatorsSetSelectStyle = function(portalGuid) {
|
|||||||
if(!resonatorLayerGroup) continue;
|
if(!resonatorLayerGroup) continue;
|
||||||
resonatorLayerGroup.eachLayer(function(layer) {
|
resonatorLayerGroup.eachLayer(function(layer) {
|
||||||
if (layer.options.guid) {
|
if (layer.options.guid) {
|
||||||
layer.bringToFront().setStyle({color: COLOR_SELECTED_PORTAL_RESONATOR,
|
// Resonator
|
||||||
radius: RADIUS_SELECTED_PORTAL_RESONATOR,
|
layer.bringToFront().setStyle(OPTIONS_RESONATOR_SELECTED);
|
||||||
weight: WEIGHT_SELECTED_PORTAL_RESONATOR});
|
|
||||||
} else {
|
} else {
|
||||||
layer.bringToFront().setStyle({opacity: OPACITY_SELECTED_PORTAL_RESONATOR_LINE,
|
// Resonator line
|
||||||
weight: WEIGHT_SELECTED_PORTAL_RESONATOR_LINE});
|
layer.bringToFront().setStyle(OPTIONS_RESONATOR_LINE_SELECTED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -109,10 +109,7 @@ window.setPortalIndicators = function(d) {
|
|||||||
window.selectPortal = function(guid) {
|
window.selectPortal = function(guid) {
|
||||||
var update = selectedPortal === guid;
|
var update = selectedPortal === guid;
|
||||||
var oldPortal = portals[selectedPortal];
|
var oldPortal = portals[selectedPortal];
|
||||||
if(!update && oldPortal) {
|
if(!update && oldPortal) portalResetColor(oldPortal);
|
||||||
resonatorsResetStyle(oldPortal.options.guid);
|
|
||||||
portalResetColor(oldPortal);
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedPortal = guid;
|
selectedPortal = guid;
|
||||||
|
|
||||||
@ -127,10 +124,7 @@ window.selectPortal = function(guid) {
|
|||||||
|
|
||||||
window.unselectOldPortal = function() {
|
window.unselectOldPortal = function() {
|
||||||
var oldPortal = portals[selectedPortal];
|
var oldPortal = portals[selectedPortal];
|
||||||
if(oldPortal) {
|
if(oldPortal) portalResetColor(oldPortal);
|
||||||
resonatorsResetStyle(oldPortal.options.guid);
|
|
||||||
oldPortal.setStyle({color: oldPortal.options.fillColor});
|
|
||||||
}
|
|
||||||
selectedPortal = null;
|
selectedPortal = null;
|
||||||
$('#portaldetails').html('');
|
$('#portaldetails').html('');
|
||||||
}
|
}
|
||||||
|
15
main.js
15
main.js
@ -146,16 +146,11 @@ window.COLORS = ['#FFCE00', '#0088FF', '#03FE03']; // none, res, enl
|
|||||||
window.COLORS_LVL = ['#000', '#FECE5A', '#FFA630', '#FF7315', '#E40000', '#FD2992', '#EB26CD', '#C124E0', '#9627F4'];
|
window.COLORS_LVL = ['#000', '#FECE5A', '#FFA630', '#FF7315', '#E40000', '#FD2992', '#EB26CD', '#C124E0', '#9627F4'];
|
||||||
window.COLORS_MOD = {VERY_RARE: '#F78AF6', RARE: '#AD8AFF', COMMON: '#84FBBD'};
|
window.COLORS_MOD = {VERY_RARE: '#F78AF6', RARE: '#AD8AFF', COMMON: '#84FBBD'};
|
||||||
|
|
||||||
window.COLOR_SELECTED_PORTAL_RESONATOR = '#FFFFFF';
|
window.OPTIONS_RESONATOR_SELECTED = { color: '#fff', weight: 2, radius: 4};
|
||||||
window.COLOR_NON_SELECTED_PORTAL_RESONATOR = '#AAAAAA';
|
window.OPTIONS_RESONATOR_NON_SELECTED = { color: '#aaa', weight: 1, radius: 3};
|
||||||
window.OPACITY_SELECTED_PORTAL_RESONATOR_LINE = 0.7;
|
|
||||||
window.OPACITY_NON_SELECTED_PORTAL_RESONATOR_LINE = 0.25;
|
window.OPTIONS_RESONATOR_LINE_SELECTED = {opacity: 0.7, weight: 3};
|
||||||
window.RADIUS_SELECTED_PORTAL_RESONATOR = 4;
|
window.OPTIONS_RESONATOR_LINE_NON_SELECTED = {opacity: 0.25, weight: 2};
|
||||||
window.RADIUS_NON_SELECTED_PORTAL_RESONATOR = 3;
|
|
||||||
window.WEIGHT_SELECTED_PORTAL_RESONATOR_LINE = 3;
|
|
||||||
window.WEIGHT_NON_SELECTED_PORTAL_RESONATOR_LINE = 2;
|
|
||||||
window.WEIGHT_SELECTED_PORTAL_RESONATOR = 2;
|
|
||||||
window.WEIGHT_NON_SELECTED_PORTAL_RESONATOR = 1;
|
|
||||||
|
|
||||||
// circles around a selected portal that show from where you can hack
|
// circles around a selected portal that show from where you can hack
|
||||||
// it and how far the portal reaches (i.e. how far links may be made
|
// it and how far the portal reaches (i.e. how far links may be made
|
||||||
|
Loading…
x
Reference in New Issue
Block a user