use DOMContentLoaded
This commit is contained in:
parent
752dbbd1c4
commit
07d71de471
4 changed files with 24 additions and 18 deletions
|
@ -32,7 +32,7 @@ make' (GalleryInfo {title, prefix, filters, hidden}) infos = [b|@0
|
||||||
<link rel=stylesheet href=/style/shiny/gallery.css title=shiny>
|
<link rel=stylesheet href=/style/shiny/gallery.css title=shiny>
|
||||||
<link rel=alternate href=rss.xml type=application/rss+xml>
|
<link rel=alternate href=rss.xml type=application/rss+xml>
|
||||||
|
|
||||||
<script async src=/script/gallery.js></script>
|
<script src=/script/gallery.js></script>
|
||||||
|
|
||||||
<title>$*title</title>
|
<title>$*title</title>
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ make' nsfw dir info@(Info {date, title, artist}) = [b|@0
|
||||||
<meta name=viewport content="width=1200,viewport-fit=cover">
|
<meta name=viewport content="width=1200,viewport-fit=cover">
|
||||||
<link rel=stylesheet href=/style/shiny/single.css title=shiny>
|
<link rel=stylesheet href=/style/shiny/single.css title=shiny>
|
||||||
|
|
||||||
<script async src=/script/single.js></script>
|
<script src=/script/single.js></script>
|
||||||
|
|
||||||
$0.prefetches
|
$0.prefetches
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let items = Array.from(document.querySelectorAll('.item.post'));
|
let items;
|
||||||
|
let reqBoxes;
|
||||||
let reqBoxes = Array.from(document.querySelectorAll('#require input'));
|
let excBoxes;
|
||||||
let excBoxes = Array.from(document.querySelectorAll('#exclude input'));
|
let allBoxes;
|
||||||
let allBoxes = [...reqBoxes, ...excBoxes];
|
let tags;
|
||||||
|
|
||||||
let tags = new Map(items.map(item => [item, item.dataset.tags.split(';')]));
|
|
||||||
|
|
||||||
|
|
||||||
function fillSets() {
|
function fillSets() {
|
||||||
|
@ -104,15 +102,25 @@ function useFragment(firstLoad) {
|
||||||
|
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
|
items = Array.from(document.querySelectorAll('.item.post'));
|
||||||
|
|
||||||
|
reqBoxes = Array.from(document.querySelectorAll('#require input'));
|
||||||
|
excBoxes = Array.from(document.querySelectorAll('#exclude input'));
|
||||||
|
allBoxes = [...reqBoxes, ...excBoxes];
|
||||||
|
|
||||||
|
tags = new Map(items.map(item => [item, item.dataset.tags.split(';')]));
|
||||||
|
|
||||||
|
|
||||||
allBoxes.forEach(b => b.addEventListener('change', () => toggle(b)));
|
allBoxes.forEach(b => b.addEventListener('change', () => toggle(b)));
|
||||||
|
|
||||||
document.getElementById('clear').addEventListener('click', clear);
|
document.getElementById('clear').addEventListener('click', clear);
|
||||||
document.getElementById('reset').addEventListener('click', reset);
|
document.getElementById('reset').addEventListener('click', reset);
|
||||||
|
|
||||||
window.addEventListener('popstate', () => useFragment(false));
|
window.addEventListener('popstate', () => useFragment(false));
|
||||||
|
|
||||||
useFragment(true);
|
useFragment(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', setup);
|
window.addEventListener('DOMContentLoaded', setup);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function getById(id) { return document.getElementById(id); }
|
let mainfig = document.getElementById('mainfig');
|
||||||
|
let mainimg = document.getElementById('mainimg');
|
||||||
let mainfig = getById('mainfig');
|
let mainlink = document.getElementById('mainlink');
|
||||||
let mainimg = getById('mainimg');
|
|
||||||
let mainlink = getById('mainlink');
|
|
||||||
|
|
||||||
function openCW(caption, focusLink) {
|
function openCW(caption, focusLink) {
|
||||||
mainfig.removeChild(caption);
|
mainfig.removeChild(caption);
|
||||||
|
@ -22,7 +20,7 @@ function addCWListeners(caption) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setImage(src, href, cw) {
|
function setImage(src, href, cw) {
|
||||||
let caption = getById('cw');
|
let caption = document.getElementById('cw');
|
||||||
let cwText = `<span id=cw-text>cw: <b>${cw}</b></span>`;
|
let cwText = `<span id=cw-text>cw: <b>${cw}</b></span>`;
|
||||||
|
|
||||||
if (cw && caption) {
|
if (cw && caption) {
|
||||||
|
@ -54,9 +52,9 @@ function setup() {
|
||||||
button.onchange = e => { if (button.checked) activateButton(button); };
|
button.onchange = e => { if (button.checked) activateButton(button); };
|
||||||
}
|
}
|
||||||
|
|
||||||
addCWListeners(getById('cw'));
|
addCWListeners(document.getElementById('cw'));
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', setup);
|
window.addEventListener('DOMContentLoaded', setup);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue