fix cw handling again, maybe???

This commit is contained in:
Rhiannon Morris 2020-09-14 01:34:45 +02:00
parent 2a9e9cfa7b
commit 046dc59834

View file

@ -25,21 +25,23 @@ function addCWListeners(id, caption) {
function setImage(id, src, width, height, href, cw, firstLoad) {
let caption = document.getElementById('cw');
let cwText = `<span id=cw-text>cw: <b>${cw}</b></span>`;
let newCaption;
if (!opened.has(id) && cw && caption) {
caption.innerHTML = cwText;
} else if (caption) {
openCW(id, caption);
} else if (!opened.has(id) && cw) {
if (!opened.has(id) && cw) {
let template = document.createElement('template');
template.innerHTML = `
<figcaption id=cw aria-role=button tabindex=0>
${cwText}
<span id=cw-text>cw: <b>${cw}</b></span>
</figcaption>`;
let content = template.content;
addCWListeners(id, content.getElementById('cw'));
mainfig.insertBefore(content, mainlink);
newCaption = template.content;
addCWListeners(id, newCaption.getElementById('cw'));
}
if (caption) {
openCW(null, caption);
}
if (newCaption) {
mainfig.insertBefore(newCaption, mainlink);
mainlink.tabIndex = -1;
}