From f75327772f21c1fcf335c4e7029dd3465eca72c8 Mon Sep 17 00:00:00 2001 From: kruschen Date: Wed, 28 Aug 2024 23:08:35 +0000 Subject: [PATCH] options available through button again --- src/main.ts | 1 - src/modules/ui/options.ts | 10 +++++----- src/scripts/listeners.ts | 9 +++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index 57973304..58dfed02 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,6 @@ import {defineSvg} from "./modules/define-svg"; import {clearLegend} from "./modules/legend"; // @ts-expect-error js-module import {Rulers} from "./modules/measurers"; -// @ts-expect-error js-module import {applyStoredOptions} from "./modules/ui/options"; import {addGlobalListeners} from "./scripts/listeners"; import {checkForUpdates} from "./scripts/updater"; diff --git a/src/modules/ui/options.ts b/src/modules/ui/options.ts index 2c823f87..9d592711 100644 --- a/src/modules/ui/options.ts +++ b/src/modules/ui/options.ts @@ -95,7 +95,7 @@ if (stored("disable_click_arrow_tooltip")) { } // Show options pane on trigger click -function showOptions(event: MouseEvent) { +export function showOptions(event: MouseEvent) { if (!stored("disable_click_arrow_tooltip")) { clearMainTip(); localStorage.setItem("disable_click_arrow_tooltip", "true"); @@ -563,8 +563,8 @@ function changeZoomExtent(value: string) { if (Number(zoomExtentMin.value) > Number(zoomExtentMax.value)) { [zoomExtentMin.value, zoomExtentMax.value] = [zoomExtentMax.value, zoomExtentMin.value]; } - const min = Math.max(Number(zoomExtentMin.value, 0.01); - const max = Math.min(Number(zoomExtentMax.value, 200); + const min = Math.max(Number(zoomExtentMin.value), 0.01); + const max = Math.min(Number(zoomExtentMax.value), 200); zoomExtentMin.value = min.toString(); zoomExtentMax.value = max.toString(); const scale = minmax(Number(value), 0.01, 200); @@ -609,7 +609,7 @@ export function applyStoredOptions() { .getItem("winds")! .split(",") .map(w => Number(w)); - if (stored("military") options.military = JSON.parse(stored("military")!); // MARKER: ! + if (stored("military")) options.military = JSON.parse(stored("military")!); // MARKER: ! if (stored("tooltipSize")) changeTooltipSize(stored("tooltipSize")!); if (stored("regions")) changeStatesNumber(stored("regions")!); @@ -633,7 +633,7 @@ export function applyStoredOptions() { changeDialogsTheme(themeColor, transparency); setRendering(shapeRendering.value); - options.stateLabelsMode = stateLabelsModeInput.value; + options.stateLabelsMode = stateLabelsModeInput.value as "auto" | "short" | "full"; // MARKER: as conversion } // randomize options if randomization is allowed (not locked or options='default') diff --git a/src/scripts/listeners.ts b/src/scripts/listeners.ts index c28b09f3..99ca4223 100644 --- a/src/scripts/listeners.ts +++ b/src/scripts/listeners.ts @@ -3,8 +3,7 @@ import {addOnLoadListener} from "./loading"; import {assignLockBehavior} from "./options/lock"; import {addTooptipListers} from "./tooltips"; import {assignSpeakerBehavior} from "./speaker"; -// @ts-ignore -import {addResizeListener} from "modules/ui/options"; +import {addResizeListener, hideOptions, showOptions} from "modules/ui/options"; // @ts-ignore import {addDragToUpload} from "modules/io/load"; import {addHotkeyListeners} from "scripts/hotkeys"; @@ -25,6 +24,7 @@ export function addGlobalListeners() { assignSpeakerBehavior(); addDragToUpload(); addFindAll(); + addOptionsListeners(); } function registerServiceWorker() { @@ -54,3 +54,8 @@ function addInstallationPrompt() { function addBeforeunloadListener() { window.onbeforeunload = () => "Are you sure you want to navigate away?"; } + +function addOptionsListeners() { + document.querySelector("#optionsTrigger")!.on("click", (evt) => showOptions(evt as MouseEvent)); + document.querySelector("#optionsHide")!.on("click", (evt) => hideOptions(evt as MouseEvent)); +} \ No newline at end of file