aboutsummaryrefslogtreecommitdiffstats
path: root/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'main.js')
-rw-r--r--main.js53
1 files changed, 25 insertions, 28 deletions
diff --git a/main.js b/main.js
index b595c3b..c21392c 100644
--- a/main.js
+++ b/main.js
@@ -405,29 +405,27 @@ if (window.location === window.parent.location) {
return [x.id, btn]
}));
- Object.keys(buttons).forEach(function(id) {
+ Object.entries(buttons).forEach(function([id, btn]) {
const panel = document.getElementById(id + '-panel');
- if (panel == null) {
- return;
+ if (panel != null) {
+ btn.onclick = function() {
+ if (btn.getAttribute('aria-expanded') === 'true') {
+ panel.setAttribute('aria-hidden', 'true');
+ btn.setAttribute('aria-expanded', 'false');
+ btn.classList.replace('btn-dark', 'btn-light');
+ } else {
+ Object.values(buttons).forEach(function(btn2) {
+ /* close all other panels */
+ if (!btn.isEqualNode(btn2) && btn2.getAttribute('aria-expanded') === 'true') {
+ btn2.click();
+ }
+ });
+ panel.setAttribute('aria-hidden', 'false');
+ btn.setAttribute('aria-expanded', 'true');
+ btn.classList.replace('btn-light', 'btn-dark');
+ }
+ };
}
- const btn = buttons[id];
- btn.onclick = function() {
- if (btn.getAttribute('aria-expanded') === 'true') {
- panel.setAttribute('aria-hidden', 'true');
- btn.setAttribute('aria-expanded', 'false');
- btn.classList.replace('btn-dark', 'btn-light');
- } else {
- Object.values(buttons).forEach(function(btn2) {
- /* close all other panels */
- if (!btn.isEqualNode(btn2) && btn2.getAttribute('aria-expanded') === 'true') {
- btn2.click();
- }
- });
- panel.setAttribute('aria-hidden', 'false');
- btn.setAttribute('aria-expanded', 'true');
- btn.classList.replace('btn-light', 'btn-dark');
- }
- };
});
}
@@ -1189,12 +1187,11 @@ const layerHierarchy = [
const styles = (function() {
const searchParams = new URLSearchParams(location.hash.substring(1));
const layersParams = searchParams.has('layers') ? searchParams.get('layers').split(' ') : [];
- return Object.keys(layers).reduce(function(result, key) {
- if (layersParams.includes(key)) {
- result[key] = layers[key].style;
- }
- return result;
- }, {});
+ return Object.fromEntries(
+ Object.entries(layers)
+ .filter(([key]) => layersParams.includes(key))
+ .map(([key, lyr]) => [key, lyr.style])
+ );
})();
const mapLayers = (function() {
@@ -1483,7 +1480,7 @@ const infoMetadataAccordions = [];
});
};
const fixLayerVisibility = function() {
- const result = {}
+ const result = {};
const nodata = [ 0, 0, 0, .0];
const kskog_palette = [nodata, nodata, nodata, nodata, nodata];
Object.keys(layers).forEach(function(lyr) {