Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/map_select_dialog.js')
-rw-r--r--src/modules/map_select_dialog.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/modules/map_select_dialog.js b/src/modules/map_select_dialog.js
index 24215f6..359477d 100644
--- a/src/modules/map_select_dialog.js
+++ b/src/modules/map_select_dialog.js
@@ -6,17 +6,17 @@ export function init() {
selectEl = mapDialog.querySelector('select'),
confirmBtn = mapDialog.querySelector('#confirm-btn');
- Object.keys(scenarios).forEach(scenario => {
+ Object.keys(scenarios).reverse().forEach(scenario => {
const option = document.createElement('option');
option.setAttribute('value', scenario);
- option.textContent = scenarios[scenario];
- selectEl.appendChild(option);
+ option.textContent = scenarios[scenario].title;
+ selectEl.prepend(option);
});
return {
selectCurrentOptionOnPageLoad() {
- mapDialog.querySelectorAll('option').forEach(option =>
- option.value === localStorage.getItem('map') && (option.selected = true)
+ mapDialog.querySelectorAll('option').forEach((option, index) =>
+ option.selected = option.value === localStorage.getItem('map') || index === 0
);
return this;
@@ -43,8 +43,7 @@ export function init() {
e.preventDefault();
localStorage.removeItem('pan-zoom');
localStorage.setItem('map', selectEl.value);
- // loadFn(`assets/images/${selectEl.value}.svg`);
- loadFn(selectEl.value);
+ loadFn(scenarios[selectEl.value]?.hashed || `assets/images/${selectEl.value}.svg`);
mapDialog.close();
});
}