script fixes

This commit is contained in:
rhiannon morris 2024-07-11 15:04:55 +02:00
parent 411f2feb44
commit cd5801dd7d
2 changed files with 3 additions and 7 deletions

View file

@ -1,12 +1,8 @@
const nsfwOk = 'nsfw-ok'; const nsfwOk = 'nsfw-ok';
function alreadyYes() {
return localStorage.getItem(nsfwOk) == '1';
}
function dismiss() { function dismiss() {
const dialog = document.getElementById('nsfw-dialog')!; const dialog = document.getElementById('nsfw-dialog')!;
dialog.parentElement?.removeChild(dialog); dialog.parentElement!.removeChild(dialog);
} }
function yes() { function yes() {
@ -15,7 +11,7 @@ function yes() {
} }
function setup() { function setup() {
if (alreadyYes()) { if (localStorage.getItem(nsfwOk)) {
dismiss(); dismiss();
} else { } else {
document.getElementById('nsfw-yes')!.onclick = yes; document.getElementById('nsfw-yes')!.onclick = yes;

View file

@ -47,7 +47,7 @@ function setImage(id: string, src: string, href: string, cw: string): void {
function activateButton(button: HTMLInputElement, doPush = true): void { function activateButton(button: HTMLInputElement, doPush = true): void {
setImage(button.id, button.value, setImage(button.id, button.value,
button.dataset.link!, button.dataset.link!,
button.dataset.warning!); button.dataset.warning ?? '');
if (doPush) history.pushState(null, '', '#' + button.id); if (doPush) history.pushState(null, '', '#' + button.id);
} }