gallery/script/nsfw-warning.ts

20 lines
437 B
TypeScript

const nsfwOk = 'nsfw-ok';
const dialog = document.getElementById('nsfw-dialog')! as HTMLDialogElement;
function yes() {
localStorage.setItem(nsfwOk, '1');
dialog.close();
}
function setup() {
if (!localStorage.getItem(nsfwOk)) {
(dialog.querySelector('#nsfw-yes') as HTMLElement).onclick = yes;
// nsfw-no is a normal link
dialog.showModal();
}
}
document.addEventListener('DOMContentLoaded', setup);
export {};