From 046dc59834096d2957f97edd6fe3395adbd44339 Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Mon, 14 Sep 2020 01:34:45 +0200 Subject: [PATCH] fix cw handling again, maybe??? --- script/single.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/script/single.js b/script/single.js index 5d63b5f..5e3347f 100644 --- a/script/single.js +++ b/script/single.js @@ -25,21 +25,23 @@ function addCWListeners(id, caption) { function setImage(id, src, width, height, href, cw, firstLoad) { let caption = document.getElementById('cw'); - let cwText = `cw: ${cw}`; + 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 = `
- ${cwText} + cw: ${cw}
`; - 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; }