const instead of let where possible
This commit is contained in:
parent
0de54d15d4
commit
b2e2db77dd
3 changed files with 39 additions and 41 deletions
|
@ -4,7 +4,7 @@ let mainlink: HTMLAnchorElement;
|
|||
let altButtons: HTMLInputElement[];
|
||||
let skipAll: HTMLInputElement;
|
||||
|
||||
let opened: Set<string> = new Set;
|
||||
const opened: Set<string> = new Set;
|
||||
|
||||
function openCW(id: string | null, caption: HTMLElement | null,
|
||||
focusLink = false) {
|
||||
|
@ -27,13 +27,11 @@ function setImage(id: string | null,
|
|||
src: string,
|
||||
href: string,
|
||||
cw: string) {
|
||||
let caption = document.getElementById('cw');
|
||||
let newCaption: HTMLElement | null = null;
|
||||
|
||||
let checked = skipAll ? skipAll.checked : false;
|
||||
const caption = document.getElementById('cw');
|
||||
const checked = skipAll ? skipAll.checked : false;
|
||||
|
||||
if (!checked && !opened.has(id) && cw) {
|
||||
let template = document.getElementById('cw-template') as HTMLTemplateElement;
|
||||
const template = document.getElementById('cw-template') as HTMLTemplateElement;
|
||||
newCaption = template.content.firstElementChild!.cloneNode(true) as HTMLElement;
|
||||
newCaption.querySelector('#cw-text')!.innerHTML = cw;
|
||||
addCWListeners(id, newCaption);
|
||||
|
@ -62,9 +60,9 @@ function activateButton(button: HTMLInputElement, doPush = true): void {
|
|||
function useFragment(firstLoad = false): void {
|
||||
let button = altButtons[0];
|
||||
|
||||
let frag = decodeURIComponent(location.hash).replace(/^#/, '');
|
||||
const frag = decodeURIComponent(location.hash).replace(/^#/, '');
|
||||
if (frag) {
|
||||
let selected = document.getElementById(frag) as HTMLInputElement;
|
||||
const selected = document.getElementById(frag) as HTMLInputElement;
|
||||
if (selected) button = selected;
|
||||
}
|
||||
|
||||
|
@ -85,21 +83,21 @@ function setup() {
|
|||
mainlink = document.getElementById('mainlink') as HTMLAnchorElement;
|
||||
skipAll = document.getElementById('skipAll') as HTMLInputElement;
|
||||
|
||||
let alts = document.getElementById('alts');
|
||||
const alts = document.getElementById('alts');
|
||||
if (alts) {
|
||||
let inputs = Array.from(alts.getElementsByTagName('input'));
|
||||
const inputs = Array.from(alts.getElementsByTagName('input'));
|
||||
altButtons = inputs.filter(e => e.name == 'variant');
|
||||
} else {
|
||||
altButtons = [];
|
||||
}
|
||||
|
||||
for (let button of altButtons) {
|
||||
for (const button of altButtons) {
|
||||
button.onchange = _e => { if (button.checked) activateButton(button); };
|
||||
}
|
||||
|
||||
if (skipAll) {
|
||||
skipAll.onchange = _e => { if (skipAll.checked) {
|
||||
let caption = document.getElementById('cw');
|
||||
const caption = document.getElementById('cw');
|
||||
if (caption) { openCW(null, caption, false); }
|
||||
} };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue