gallery/script/nsfw-warning.js

36 lines
596 B
JavaScript
Raw Normal View History

2020-10-06 16:07:39 -04:00
(function () {
'use strict';
let nsfwOk = 'nsfw-ok';
function alreadyYes() {
return sessionStorage.getItem(nsfwOk);
}
function dismiss() {
let dialog = document.getElementById('nsfw-dialog');
dialog.parentElement.removeChild(dialog);
}
function yes() {
sessionStorage.setItem(nsfwOk, 1);
dismiss();
}
function no() {
history.go(-1);
}
function setup() {
if (alreadyYes()) {
dismiss();
} else {
document.getElementById('nsfw-yes').onclick = yes;
document.getElementById('nsfw-no').onclick = no;
}
}
document.addEventListener('DOMContentLoaded', setup);
})();