From 33be739566a076bbe0eccf4784a78272d1fc4a46 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 26 Sep 2022 14:35:16 +0100 Subject: [PATCH] sections --- app/static/js/ascroll.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js index aadfa98..8dae309 100644 --- a/app/static/js/ascroll.js +++ b/app/static/js/ascroll.js @@ -124,6 +124,26 @@ function formatInfo(config, ascroll) { if (!config.annotations.length && config.body) { var div = document.createElement('div') div.innerHTML = config.body + var activate + var part = document.location.hash.slice(1) || 'part1' + div.querySelectorAll("h3.toggle").forEach(title => { + var section = title.nextElementSibling + if (part == title.id && section.style.display == "none") { + activate = title + } + title.onclick = event => { + section.style.display = section.style.display == "none" ? "block" : "none" + div.querySelectorAll("h3.toggle").forEach(other => { + if (other != title) { + var osection = other.nextElementSibling + osection.style.display = "none" + } + }) + } + }) + if (activate) { + activate.click() + } ascroll.appendChild(div) } return info