aboutsummaryrefslogtreecommitdiffstats
path: root/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'main.js')
-rw-r--r--main.js105
1 files changed, 55 insertions, 50 deletions
diff --git a/main.js b/main.js
index 9840746..8d95f5b 100644
--- a/main.js
+++ b/main.js
@@ -3663,9 +3663,9 @@ const infoMetadataAccordions = [];
});
const btn = document.getElementById('map-legend-button');
if (Object.values(STYLES).some((v) => Object.values(v).some((v2) => v2 != null))) {
- btn.classList.remove('disabled');
+ btn?.classList.remove('disabled');
} else {
- btn.classList.add('disabled');
+ btn?.classList.add('disabled');
}
};
const onClickFunction = function(layerList, event) {
@@ -4213,21 +4213,23 @@ const infoMetadataAccordions = [];
})();
const button_menu = document.getElementById('measure-button')
- .getElementsByTagName('button')[0];
- button_menu.addEventListener('click', function(event) {
- if (event.currentTarget.getAttribute('aria-expanded') === 'true') {
- disposePopover();
- setup(getMeasureMode());
- } else {
- setup(null);
- /* XXX workaround for https://github.com/twbs/bootstrap/issues/41005#issuecomment-2585390544 */
- const activeElement = document.activeElement;
- if (activeElement.isEqualNode(btn_close)) {
- activeElement.blur();
+ ?.getElementsByTagName('button')?.[0];
+ if (button_menu != null) {
+ button_menu.addEventListener('click', function(event) {
+ if (event.currentTarget.getAttribute('aria-expanded') === 'true') {
+ disposePopover();
+ setup(getMeasureMode());
+ } else {
+ setup(null);
+ /* XXX workaround for https://github.com/twbs/bootstrap/issues/41005#issuecomment-2585390544 */
+ const activeElement = document.activeElement;
+ if (activeElement.isEqualNode(btn_close)) {
+ activeElement.blur();
+ }
}
- }
- });
- btn_close.onclick = () => button_menu.click();
+ });
+ btn_close.onclick = () => button_menu.click();
+ }
})();
/* popup and feature overlays */
@@ -5422,9 +5424,9 @@ const disposePopover = (function() {
header.appendChild(btnClose);
const measureButton = document.getElementById('measure-button')
- .getElementsByTagName('button')[0];
+ ?.getElementsByTagName('button')?.[0];
MAP.on('singleclick', function(event) {
- if (measureButton.getAttribute('aria-expanded') === 'true') {
+ if (measureButton?.getAttribute('aria-expanded') === 'true') {
/* skip popover while measuring */
return;
}
@@ -6028,40 +6030,43 @@ const ageFilterSetActive = (function() {
modal.hide();
};
- const btn = document.getElementById('age-filter-button').getElementsByTagName('button')[0];
- if (ageFilterSettings.active) {
- btn.classList.replace('btn-light', 'btn-dark');
- }
- panel.addEventListener('show.bs.modal', function() {
- backdrop.classList.add('modal-backdrop', 'show');
- btn.setAttribute('aria-expanded', 'true');
- btn.classList.replace('btn-light', 'btn-dark');
- });
- panel.addEventListener('hide.bs.modal', function() {
- /* XXX workaround for https://github.com/twbs/bootstrap/issues/41005#issuecomment-2585390544 */
- const activeElement = document.activeElement;
- if (activeElement instanceof HTMLElement) {
- activeElement.blur();
- }
- });
- panel.addEventListener('hidden.bs.modal', function() {
- if (!ageFilterSettings.active) {
- btn.classList.replace('btn-dark', 'btn-light');
- }
- if (updateHelpTextTimeoutID != null) {
- clearTimeout(updateHelpTextTimeoutID);
- updateHelpTextState.value = null;
- updateHelpTextTimeoutID = null;
+ const btn = document.getElementById('age-filter-button')
+ ?.getElementsByTagName('button')?.[0];
+ if (btn != null) {
+ if (ageFilterSettings.active) {
+ btn.classList.replace('btn-light', 'btn-dark');
}
- btn.setAttribute('aria-expanded', 'false');
- backdrop.classList.remove('modal-backdrop', 'show');
- });
+ panel.addEventListener('show.bs.modal', function() {
+ backdrop.classList.add('modal-backdrop', 'show');
+ btn.setAttribute('aria-expanded', 'true');
+ btn.classList.replace('btn-light', 'btn-dark');
+ });
+ panel.addEventListener('hide.bs.modal', function() {
+ /* XXX workaround for https://github.com/twbs/bootstrap/issues/41005#issuecomment-2585390544 */
+ const activeElement = document.activeElement;
+ if (activeElement instanceof HTMLElement) {
+ activeElement.blur();
+ }
+ });
+ panel.addEventListener('hidden.bs.modal', function() {
+ if (!ageFilterSettings.active) {
+ btn.classList.replace('btn-dark', 'btn-light');
+ }
+ if (updateHelpTextTimeoutID != null) {
+ clearTimeout(updateHelpTextTimeoutID);
+ updateHelpTextState.value = null;
+ updateHelpTextTimeoutID = null;
+ }
+ btn.setAttribute('aria-expanded', 'false');
+ backdrop.classList.remove('modal-backdrop', 'show');
+ });
- btn.onclick = function() {
- disposePopover();
- dialog_setup();
- modal.show();
- };
+ btn.onclick = function() {
+ disposePopover();
+ dialog_setup();
+ modal.show();
+ };
+ }
return (function() { /* setter for ageFilterSettings.active */
let timeoutID = null;