forked from maxnet/pico-webserver
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from HerrZatacke/main
UI improvements and additional GIF options
- Loading branch information
Showing
11 changed files
with
345 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { LOCALSTORAGE_GIF_DIR_KEY, LOCALSTORAGE_FPS_KEY, LOCALSTORAGE_SCALE_KEY, Direction } from '../../consts.ts'; | ||
|
||
const settingsMenu = document.getElementById('settings') as HTMLDivElement; | ||
const settingsBackdrop = document.getElementById('settings_backdrop') as HTMLButtonElement; | ||
const settingsCloseBtn = document.getElementById('settings_close') as HTMLButtonElement; | ||
const scaleSelect = document.getElementById('download_size') as HTMLSelectElement; | ||
const fpsSelect = document.getElementById('download_fps') as HTMLSelectElement; | ||
const gifDirection = document.getElementById('gif_direction') as HTMLSelectElement; | ||
const settingsBtn = document.getElementById('open_settings') as HTMLButtonElement; | ||
|
||
const updateSettings = () => { | ||
scaleSelect.value = localStorage.getItem(LOCALSTORAGE_SCALE_KEY) || '1'; | ||
fpsSelect.value = localStorage.getItem(LOCALSTORAGE_FPS_KEY) || '12'; | ||
gifDirection.value = localStorage.getItem(LOCALSTORAGE_GIF_DIR_KEY) || Direction.FORWARD; | ||
} | ||
|
||
export const initSettings = () => { | ||
updateSettings(); | ||
|
||
scaleSelect.addEventListener('change', () => { | ||
const scale = parseInt(scaleSelect.value || '0', 10) || 1; | ||
localStorage.setItem(LOCALSTORAGE_SCALE_KEY, scale.toString(10)); | ||
}); | ||
|
||
fpsSelect.addEventListener('change', () => { | ||
const fps = parseInt(fpsSelect.value || '0', 10) || 12; | ||
localStorage.setItem(LOCALSTORAGE_FPS_KEY, fps.toString(10)); | ||
}); | ||
|
||
gifDirection.addEventListener('change', () => { | ||
const dir = gifDirection.value || Direction.FORWARD; | ||
localStorage.setItem(LOCALSTORAGE_GIF_DIR_KEY, dir); | ||
}); | ||
|
||
|
||
settingsBtn.addEventListener('click', () => { | ||
document.body.classList.add('fixed'); | ||
settingsMenu.classList.add('visible'); | ||
settingsBackdrop.classList.add('visible'); | ||
}); | ||
|
||
settingsBackdrop.addEventListener('click', () => { | ||
document.body.classList.remove('fixed'); | ||
settingsMenu.classList.remove('visible'); | ||
settingsBackdrop.classList.remove('visible'); | ||
}); | ||
|
||
settingsCloseBtn.addEventListener('click', () => { | ||
document.body.classList.remove('fixed'); | ||
settingsMenu.classList.remove('visible'); | ||
settingsBackdrop.classList.remove('visible'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const toastTarget = document.querySelector('.toast-target') as HTMLDivElement; | ||
|
||
export const showToast = (message: string) => { | ||
const toast = document.createElement('div'); | ||
toast.classList.add('toast'); | ||
toast.innerText = message; | ||
toastTarget.appendChild(toast); | ||
|
||
const closeTimeout = setTimeout(() => { | ||
toastTarget.removeChild(toast); | ||
}, 10000); | ||
|
||
toast.addEventListener('click', () => { | ||
clearTimeout(closeTimeout); | ||
toastTarget.removeChild(toast); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.