add button to skip all cws
This commit is contained in:
parent
1e7a58359d
commit
ccb4c2eabd
4 changed files with 60 additions and 32 deletions
|
@ -5,10 +5,11 @@ let mainfig;
|
|||
let mainimg;
|
||||
let mainlink;
|
||||
let altButtons;
|
||||
let skipAll;
|
||||
|
||||
let opened = new Set;
|
||||
|
||||
function openCW(id, caption, focusLink) {
|
||||
function openCW(id, caption, focusLink = false) {
|
||||
if (id) opened.add(id);
|
||||
mainfig.removeChild(caption);
|
||||
mainlink.tabIndex = 0;
|
||||
|
@ -27,7 +28,7 @@ function setImage(id, src, width, height, href, cw, firstLoad) {
|
|||
let caption = document.getElementById('cw');
|
||||
let newCaption;
|
||||
|
||||
if (!opened.has(id) && cw) {
|
||||
if (!skipAll.checked && !opened.has(id) && cw) {
|
||||
newCaption = document.getElementById('cw-template')
|
||||
.content.firstElementChild.cloneNode(true);
|
||||
newCaption.querySelector('#cw-text').innerHTML = cw;
|
||||
|
@ -81,14 +82,25 @@ function setup() {
|
|||
mainfig = document.getElementById('mainfig');
|
||||
mainimg = document.getElementById('mainimg');
|
||||
mainlink = document.getElementById('mainlink');
|
||||
skipAll = document.getElementById('skipAll');
|
||||
|
||||
let alts = document.getElementById('alts');
|
||||
altButtons = alts ? Array.from(alts.getElementsByTagName('input')) : [];
|
||||
if (alts) {
|
||||
let inputs = Array.from(alts.getElementsByTagName('input'));
|
||||
altButtons = inputs.filter(e => e.name == 'variant');
|
||||
} else {
|
||||
altButtons = [];
|
||||
}
|
||||
|
||||
for (let button of altButtons) {
|
||||
button.onchange = e => { if (button.checked) activateButton(button); };
|
||||
}
|
||||
|
||||
skipAll.onchange = e => { if (skipAll.checked) {
|
||||
let caption = document.getElementById('cw');
|
||||
if (caption) { openCW(null, caption, false); }
|
||||
} };
|
||||
|
||||
window.addEventListener('popstate', useFragment);
|
||||
useFragment(true);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue