|
1 | | -<script lang="ts"> |
2 | | - import { onMount } from "svelte"; |
3 | | - import { isDev } from "../scripts/devMode"; |
4 | | - import { switchTab } from "../scripts/tabsController"; |
5 | | - import ToastSystem from "../scripts/toastSystem"; |
6 | | -
|
7 | | - let devMenu: HTMLDivElement; |
8 | | - let defaultTabInput: HTMLInputElement; |
9 | | - let notificationInfoInput: HTMLInputElement; |
10 | | - let notificationWarningInput: HTMLInputElement; |
11 | | - let notificationErrorInput: HTMLInputElement; |
12 | | - let removeNotificationsCheckbox: HTMLInputElement; |
13 | | -
|
14 | | - onMount(() => { |
15 | | - isDev().then((isDEV) => { |
16 | | - if (!isDEV) { |
17 | | - return; |
18 | | - } |
19 | | -
|
20 | | - devMenu.classList.remove("disabled"); |
21 | | -
|
22 | | - // ? default tab |
23 | | - const defaultTab = localStorage.getItem("default-tab"); |
24 | | - if (defaultTab != null) { |
25 | | - switchTab(defaultTab); |
26 | | - } |
27 | | -
|
28 | | - // ? remove notifications |
29 | | - const isNotificationsRemoved = localStorage.getItem("remove-notifications") == "true"; |
30 | | - ToastSystem.enabled = !isNotificationsRemoved; |
31 | | - removeNotificationsCheckbox.checked = isNotificationsRemoved; |
32 | | - }); |
33 | | - }); |
34 | | -</script> |
35 | | - |
36 | | -<div class="dev-menu disabled" bind:this={devMenu}> |
37 | | - <input type="checkbox" class="open-dev-menu" /> |
38 | | - |
39 | | - <h3>Developer mode settings</h3> |
40 | | - <hr /> |
41 | | - <span>Default tab</span> |
42 | | - <input type="text" name="default tab (id)" class="dev-set-default-tab-input" bind:this={defaultTabInput} /> |
43 | | - <button |
44 | | - class="dev-set-default-tab-button" |
45 | | - onclick={() => { |
46 | | - const tabName = defaultTabInput!.value; |
47 | | - if (tabName.length === 0) { |
48 | | - return; |
49 | | - } |
50 | | - |
51 | | - localStorage.setItem("default-tab", tabName); |
52 | | - ToastSystem.addToQueue("Set default tab to " + tabName, ToastSystem.ToastType.INFO); |
53 | | - console.log("Set default tab to " + tabName); |
54 | | - }}>Set default tab</button |
55 | | - > |
56 | | - |
57 | | - <hr /> |
58 | | - |
59 | | - <span>Notification testing</span> |
60 | | - <input type="text" name="notification text" value="This is a info notification" bind:this={notificationInfoInput} /> |
61 | | - <button onclick={() => ToastSystem.addToQueue(notificationInfoInput!.value.toString(), ToastSystem.ToastType.INFO)}>Test info notification</button> |
62 | | - |
63 | | - <input type="text" name="notification text" value="This is a warning notification" bind:this={notificationWarningInput} /> |
64 | | - <button onclick={() => ToastSystem.addToQueue(notificationWarningInput!.value.toString(), ToastSystem.ToastType.WARNING)}>Test warning notification</button> |
65 | | - |
66 | | - <input type="text" name="notification text" value="This is a error notification" bind:this={notificationErrorInput} /> |
67 | | - <button onclick={() => ToastSystem.addToQueue(notificationErrorInput!.value.toString(), ToastSystem.ToastType.ERROR)}>Test error notification</button> |
68 | | - |
69 | | - <hr /> |
70 | | - |
71 | | - <label> |
72 | | - <input |
73 | | - type="checkbox" |
74 | | - class="dev-remove-notifications" |
75 | | - bind:this={removeNotificationsCheckbox} |
76 | | - onchange={(event: Event) => localStorage.setItem("remove-notifications", (event.target as HTMLInputElement).checked.toString())} |
77 | | - /> |
78 | | - Remove all notifications |
79 | | - </label> |
80 | | -</div> |
81 | | - |
82 | | -<style lang="scss"> |
83 | | - .dev-menu { |
84 | | - position: absolute; |
85 | | - bottom: 20px; |
86 | | - left: -215px; |
87 | | - background-color: #121717; |
88 | | - padding: 10px; |
89 | | - border-radius: 10px; |
90 | | - width: 220px; |
91 | | - transition: left 0.3s ease; |
92 | | -
|
93 | | - .open-dev-menu { |
94 | | - position: absolute; |
95 | | - top: 5px; |
96 | | - right: 5px; |
97 | | - } |
98 | | -
|
99 | | - button { |
100 | | - margin-bottom: 10px; |
101 | | - } |
102 | | - } |
103 | | - .dev-menu:has(.open-dev-menu[type="checkbox"]:checked) { |
104 | | - left: 20px; |
105 | | - } |
106 | | -</style> |
| 1 | +<script lang="ts"> |
| 2 | + import { onMount } from "svelte"; |
| 3 | + import { isDev } from "../../../scripts/devMode"; |
| 4 | + import { switchTab } from "../../../scripts/tabsController"; |
| 5 | + import ToastSystem from "../../../scripts/toastSystem"; |
| 6 | +
|
| 7 | + let devMenu: HTMLDivElement; |
| 8 | + let defaultTabInput: HTMLInputElement; |
| 9 | + let notificationInfoInput: HTMLInputElement; |
| 10 | + let notificationWarningInput: HTMLInputElement; |
| 11 | + let notificationErrorInput: HTMLInputElement; |
| 12 | + let removeNotificationsCheckbox: HTMLInputElement; |
| 13 | +
|
| 14 | + onMount(() => { |
| 15 | + isDev().then((isDEV) => { |
| 16 | + if (!isDEV) { |
| 17 | + return; |
| 18 | + } |
| 19 | +
|
| 20 | + devMenu.classList.remove("disabled"); |
| 21 | +
|
| 22 | + // ? default tab |
| 23 | + const defaultTab = localStorage.getItem("default-tab"); |
| 24 | + if (defaultTab != null) { |
| 25 | + switchTab(defaultTab); |
| 26 | + } |
| 27 | +
|
| 28 | + // ? remove notifications |
| 29 | + const isNotificationsRemoved = localStorage.getItem("remove-notifications") == "true"; |
| 30 | + ToastSystem.enabled = !isNotificationsRemoved; |
| 31 | + removeNotificationsCheckbox.checked = isNotificationsRemoved; |
| 32 | + }); |
| 33 | + }); |
| 34 | +</script> |
| 35 | + |
| 36 | +<div class="dev-menu disabled" bind:this={devMenu}> |
| 37 | + <input type="checkbox" class="open-dev-menu" /> |
| 38 | + |
| 39 | + <h3>Developer mode settings</h3> |
| 40 | + <hr /> |
| 41 | + <span>Default tab</span> |
| 42 | + <input type="text" name="default tab (id)" class="dev-set-default-tab-input" bind:this={defaultTabInput} /> |
| 43 | + <button |
| 44 | + class="dev-set-default-tab-button" |
| 45 | + onclick={() => { |
| 46 | + const tabName = defaultTabInput.value; |
| 47 | + if (tabName.length === 0) { |
| 48 | + return; |
| 49 | + } |
| 50 | + |
| 51 | + localStorage.setItem("default-tab", tabName); |
| 52 | + ToastSystem.addToQueue("Set default tab to " + tabName, ToastSystem.ToastType.INFO); |
| 53 | + console.log("Set default tab to " + tabName); |
| 54 | + }} |
| 55 | + >Set default tab |
| 56 | + </button> |
| 57 | + |
| 58 | + <hr /> |
| 59 | + |
| 60 | + <span>Notification testing</span> |
| 61 | + <input type="text" name="notification text" value="This is a info notification" bind:this={notificationInfoInput} /> |
| 62 | + <button onclick={() => ToastSystem.addToQueue(notificationInfoInput!.value.toString(), ToastSystem.ToastType.INFO)}>Test info notification</button> |
| 63 | + |
| 64 | + <input type="text" name="notification text" value="This is a warning notification" bind:this={notificationWarningInput} /> |
| 65 | + <button onclick={() => ToastSystem.addToQueue(notificationWarningInput!.value.toString(), ToastSystem.ToastType.WARNING)}>Test warning notification</button> |
| 66 | + |
| 67 | + <input type="text" name="notification text" value="This is a error notification" bind:this={notificationErrorInput} /> |
| 68 | + <button onclick={() => ToastSystem.addToQueue(notificationErrorInput!.value.toString(), ToastSystem.ToastType.ERROR)}>Test error notification</button> |
| 69 | + |
| 70 | + <hr /> |
| 71 | + |
| 72 | + <label> |
| 73 | + <input |
| 74 | + type="checkbox" |
| 75 | + class="dev-remove-notifications" |
| 76 | + bind:this={removeNotificationsCheckbox} |
| 77 | + onchange={(event: Event) => localStorage.setItem("remove-notifications", (event.target as HTMLInputElement).checked.toString())} |
| 78 | + /> |
| 79 | + Remove all notifications |
| 80 | + </label> |
| 81 | +</div> |
| 82 | + |
| 83 | +<style lang="scss"> |
| 84 | + .dev-menu { |
| 85 | + position: absolute; |
| 86 | + bottom: 20px; |
| 87 | + left: -200px; |
| 88 | + background-color: #121717; |
| 89 | + padding: 10px; |
| 90 | + border-radius: 10px; |
| 91 | + width: 220px; |
| 92 | + transition: left 0.3s ease; |
| 93 | +
|
| 94 | + .open-dev-menu { |
| 95 | + position: absolute; |
| 96 | + top: 5px; |
| 97 | + right: 5px; |
| 98 | + } |
| 99 | +
|
| 100 | + input { |
| 101 | + background-color: #4b4b4b; |
| 102 | + border-radius: 5px; |
| 103 | + } |
| 104 | +
|
| 105 | + button { |
| 106 | + background-color: #4b4b4b; |
| 107 | + margin-bottom: 10px; |
| 108 | + margin-top: 10px; |
| 109 | + border-radius: 5px; |
| 110 | + } |
| 111 | + } |
| 112 | + .dev-menu:has(.open-dev-menu[type="checkbox"]:checked) { |
| 113 | + left: 20px; |
| 114 | + } |
| 115 | +</style> |
0 commit comments