diff --git a/code/utils_misc.js b/code/utils_misc.js index dede2f01..dc9c6a6f 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -359,16 +359,21 @@ window.updateDisplayedLayerGroup = function(name, display) { // Read layerGroup status from window.overlayStatus if it was added to map, // read from cookie if it has not added to map yet. -// return true if both overlayStatus and cookie didn't have the record -window.isLayerGroupDisplayed = function(name) { +// return 'defaultDisplay' if both overlayStatus and cookie didn't have the record +window.isLayerGroupDisplayed = function(name, defaultDisplay) { if(typeof(overlayStatus[name]) !== 'undefined') return overlayStatus[name]; var layersJSON = readCookie('ingress.intelmap.layergroupdisplayed'); - if(!layersJSON) return true; + if(!layersJSON) return defaultDisplay; var layers = JSON.parse(layersJSON); // keep latest overlayStatus overlayStatus = $.extend(layers, overlayStatus); - if(typeof(overlayStatus[name]) === 'undefined') return true; + if(typeof(overlayStatus[name]) === 'undefined') return defaultDisplay; return overlayStatus[name]; } + +window.addLayerGroup = function(name, layerGroup, defaultDisplay) { + if(isLayerGroupDisplayed(name, defaultDisplay)) map.addLayer(layerGroup); + layerChooser.addOverlay(layerGroup, name); +} diff --git a/plugins/keys-on-map.user.js b/plugins/keys-on-map.user.js index 0cf301b5..43aa1338 100644 --- a/plugins/keys-on-map.user.js +++ b/plugins/keys-on-map.user.js @@ -106,9 +106,7 @@ window.plugin.keysOnMap.setupCSS = function() { } window.plugin.keysOnMap.setupLayer = function() { - window.layerChooser.addOverlay(window.plugin.keysOnMap.keyLayerGroup, 'Keys'); - if(isLayerGroupDisplayed('Keys')) - map.addLayer(window.plugin.keysOnMap.keyLayerGroup); + window.addLayerGroup('Keys', window.plugin.keysOnMap.keyLayerGroup, false); } var setup = function() { diff --git a/style.css b/style.css index 712afe6b..915baecc 100644 --- a/style.css +++ b/style.css @@ -45,7 +45,7 @@ body { margin-top: -31px; /* -(toggle height / 2) */ line-height: 10px; position: absolute; - top: 325px; /* (sidebar height / 2) */ + top: 108px; z-index: 3001; background-color: rgba(8, 48, 78, 0.9); color: #FFCE00; @@ -53,7 +53,7 @@ body { border-right: none; border-radius: 5px 0 0 5px; text-decoration: none; - right: 301px; /* overwritten later by the script with SIDEBAR_WIDTH */ + right: -50px; /* overwritten later by the script with SIDEBAR_WIDTH */ } .enl { @@ -652,7 +652,7 @@ h3 { * content when first selecting a portal) */ #portaldetails { - min-height: 485px; + min-height: 63px; position: relative; /* so the below '#portaldetails .close' is relative to this */ }