add nsfw warning dialog
This commit is contained in:
parent
d671a4c01e
commit
c807895244
12 changed files with 346 additions and 102 deletions
35
script/nsfw-warning.js
Normal file
35
script/nsfw-warning.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
(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);
|
||||
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue