diff --git a/brutaldon/static/js/brutaldon-enhancements.js b/brutaldon/static/js/brutaldon-enhancements.js index defdaf3..6d7099d 100644 --- a/brutaldon/static/js/brutaldon-enhancements.js +++ b/brutaldon/static/js/brutaldon-enhancements.js @@ -67,31 +67,35 @@ function menuPrepare() { function expandCWButtonPrepare() { - var theButton = document.createElement('p'); - theButton.textContent = "Expand CWs"; - theButton.classList.toggle('button'); - document.querySelector('#title').insertAdjacentElement('afterend', theButton); - var details = document.querySelectorAll('details'); - var openState = false; + var theButton = document.querySelector('#expandCWs'); + if (!theButton) { + theButton = document.createElement('p'); + theButton.id = "expandCWs"; + theButton.textContent = "Expand CWs"; + theButton.classList.toggle('button'); + document.querySelector('#title').insertAdjacentElement('afterend', theButton); + var details = document.querySelectorAll('details'); + var openState = false; - if (details != null) { - theButton.addEventListener('click', function() { - openState = details.item(0).hasAttribute('open'); - details.forEach(function ($el) { - if (openState) - { - $el.removeAttribute('open'); - } else - { - $el.setAttribute('open', ''); - } + if (details != null) { + theButton.addEventListener('click', function() { + openState = details.item(0).hasAttribute('open'); + details.forEach(function ($el) { + if (openState) + { + $el.removeAttribute('open'); + } else + { + $el.setAttribute('open', ''); + } + }); + openState = !openState; + if (openState) { theButton.textContent = 'Collapse CWs'; } + else { theButton.textContent = "Expand CWs"; }; + theButton.classList.toggle('is-active'); }); - openState = !openState; - if (openState) { theButton.textContent = 'Collapse CWs'; } - else { theButton.textContent = "Expand CWs"; }; - theButton.classList.toggle('is-active'); - }); - }; + }; + } } function fileButtonUpdaters() diff --git a/brutaldon/templates/main/thread.html b/brutaldon/templates/main/thread.html index fd432b1..cc54b5f 100644 --- a/brutaldon/templates/main/thread.html +++ b/brutaldon/templates/main/thread.html @@ -36,8 +36,3 @@ mastodon.status_context() {% endif %} {% endblock %} -{% block page_scripts_inline %} - -{% endblock %}