Big progress update!
This commit is contained in:
parent
4645561d33
commit
9348cb1926
11 changed files with 761 additions and 6 deletions
53
src/public/assets/js/modules/events.module.js
Normal file
53
src/public/assets/js/modules/events.module.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
export const preInit = () => {
|
||||
switch112Listener();
|
||||
};
|
||||
|
||||
export const init = () => { };
|
||||
|
||||
const switch112Listener = () => {
|
||||
const switch112 = document.getElementById('switch-112-mode');
|
||||
|
||||
if (!localStorage.getItem('112-mode')) {
|
||||
localStorage.setItem('112-mode', 'true');
|
||||
}
|
||||
|
||||
const storedState = localStorage.getItem('112-mode');
|
||||
|
||||
if (storedState == 'true') {
|
||||
switch112.setAttribute('checked', '');
|
||||
}
|
||||
|
||||
switch112.addEventListener('click', () => {
|
||||
localStorage.setItem('112-mode', `${switch112.checked}`);
|
||||
location.href = location.href;
|
||||
});
|
||||
};
|
||||
|
||||
export const initYListeners = (yMinEl, yMaxEl) => {
|
||||
yMinEl.addEventListener('change', () => {
|
||||
if (yMinEl.value < 0) {
|
||||
yMinEl.value = 0;
|
||||
} else if (yMinEl.value > 255) {
|
||||
yMinEl.value = 255;
|
||||
}
|
||||
|
||||
if (yMinEl.value >= yMaxEl.value) {
|
||||
yMinEl.value = (parseInt(yMaxEl.value) - 1);
|
||||
}
|
||||
});
|
||||
|
||||
yMaxEl.addEventListener('change', () => {
|
||||
if (yMaxEl.value < 0) {
|
||||
yMaxEl.value = 0;
|
||||
} else if (yMaxEl.value > 255) {
|
||||
yMaxEl.value = 255;
|
||||
}
|
||||
|
||||
if (yMaxEl.value <= yMinEl.value) {
|
||||
yMaxEl.value = (parseInt(yMinEl.value) + 1);
|
||||
if (yMaxEl.value > 255) {
|
||||
yMinEl.value = (parseInt(yMaxEl.value) - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Loading…
Reference in a new issue