rearrange some element lookup stuff
This commit is contained in:
parent
069a65ab71
commit
a73271c0b5
2 changed files with 14 additions and 7 deletions
|
@ -98,10 +98,15 @@ function useFragment() {
|
|||
|
||||
|
||||
function setup() {
|
||||
items = Array.from(document.querySelectorAll('.item.post'));
|
||||
items = Array.from(document.getElementsByClassName('post'));
|
||||
|
||||
reqBoxes = Array.from(document.querySelectorAll('#require input'));
|
||||
excBoxes = Array.from(document.querySelectorAll('#exclude input'));
|
||||
function inputs(id) {
|
||||
let iter = document.getElementById(id).getElementsByTagName('input');
|
||||
return Array.from(iter);
|
||||
}
|
||||
|
||||
reqBoxes = inputs('require');
|
||||
excBoxes = inputs('exclude');
|
||||
allBoxes = [...reqBoxes, ...excBoxes];
|
||||
|
||||
tags = new Map(items.map(item => [item, item.dataset.tags.split(';')]));
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
let mainfig;
|
||||
let mainimg;
|
||||
let mainlink;
|
||||
let altButtons;
|
||||
|
||||
let opened = new Set;
|
||||
|
||||
|
@ -58,12 +59,12 @@ function activateButton(button, doPush = true, firstLoad = false) {
|
|||
}
|
||||
|
||||
function useFragment(firstLoad = false) {
|
||||
let button = document.querySelector('#alts input');
|
||||
let button;
|
||||
|
||||
let frag = location.hash.replace(/^#/, '');
|
||||
if (frag) {
|
||||
let button0 = document.getElementById(frag);
|
||||
if (button0) button = button0;
|
||||
let selected = document.getElementById(frag);
|
||||
button = selected ? selected : altButtons[0];
|
||||
}
|
||||
|
||||
let id;
|
||||
|
@ -81,8 +82,9 @@ function setup() {
|
|||
mainfig = document.getElementById('mainfig');
|
||||
mainimg = document.getElementById('mainimg');
|
||||
mainlink = document.getElementById('mainlink');
|
||||
altButtons = document.getElementById('alts').getElementsByTagName('input');
|
||||
|
||||
for (let button of document.querySelectorAll('#alts input')) {
|
||||
for (let button of altButtons) {
|
||||
button.onchange = e => { if (button.checked) activateButton(button); };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue