diff --git a/make-pages/GalleryPage.hs b/make-pages/GalleryPage.hs
index e22bd51..890d341 100644
--- a/make-pages/GalleryPage.hs
+++ b/make-pages/GalleryPage.hs
@@ -32,7 +32,7 @@ make' (GalleryInfo {title, prefix, filters, hidden}) infos = [b|@0
-
+
$*title
diff --git a/make-pages/SinglePage.hs b/make-pages/SinglePage.hs
index cd45ba1..d9e93aa 100644
--- a/make-pages/SinglePage.hs
+++ b/make-pages/SinglePage.hs
@@ -34,7 +34,7 @@ make' nsfw dir info@(Info {date, title, artist}) = [b|@0
-
+
$0.prefetches
diff --git a/script/gallery.js b/script/gallery.js
index c1021be..d0c45ae 100644
--- a/script/gallery.js
+++ b/script/gallery.js
@@ -1,13 +1,11 @@
(function() {
'use strict';
-let items = Array.from(document.querySelectorAll('.item.post'));
-
-let reqBoxes = Array.from(document.querySelectorAll('#require input'));
-let excBoxes = Array.from(document.querySelectorAll('#exclude input'));
-let allBoxes = [...reqBoxes, ...excBoxes];
-
-let tags = new Map(items.map(item => [item, item.dataset.tags.split(';')]));
+let items;
+let reqBoxes;
+let excBoxes;
+let allBoxes;
+let tags;
function fillSets() {
@@ -104,15 +102,25 @@ function useFragment(firstLoad) {
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)));
document.getElementById('clear').addEventListener('click', clear);
document.getElementById('reset').addEventListener('click', reset);
window.addEventListener('popstate', () => useFragment(false));
+
useFragment(true);
}
-window.addEventListener('load', setup);
+window.addEventListener('DOMContentLoaded', setup);
})();
diff --git a/script/single.js b/script/single.js
index b920374..7e1f885 100644
--- a/script/single.js
+++ b/script/single.js
@@ -1,11 +1,9 @@
(function() {
'use strict';
-function getById(id) { return document.getElementById(id); }
-
-let mainfig = getById('mainfig');
-let mainimg = getById('mainimg');
-let mainlink = getById('mainlink');
+let mainfig = document.getElementById('mainfig');
+let mainimg = document.getElementById('mainimg');
+let mainlink = document.getElementById('mainlink');
function openCW(caption, focusLink) {
mainfig.removeChild(caption);
@@ -22,7 +20,7 @@ function addCWListeners(caption) {
}
function setImage(src, href, cw) {
- let caption = getById('cw');
+ let caption = document.getElementById('cw');
let cwText = `cw: ${cw}`;
if (cw && caption) {
@@ -54,9 +52,9 @@ function setup() {
button.onchange = e => { if (button.checked) activateButton(button); };
}
- addCWListeners(getById('cw'));
+ addCWListeners(document.getElementById('cw'));
}
-window.addEventListener('load', setup);
+window.addEventListener('DOMContentLoaded', setup);
})();