diff --git a/brutaldon/static/js/brutaldon-enhancements.js b/brutaldon/static/js/brutaldon-enhancements.js index 9dc95e5..592a251 100644 --- a/brutaldon/static/js/brutaldon-enhancements.js +++ b/brutaldon/static/js/brutaldon-enhancements.js @@ -1,9 +1,3 @@ -function scrollTop() -{ - window.scrollTo(0,0); - return true; -} - function setTitle(user, page) { document.title = `Brutaldon (${user}) – ${page}`; @@ -72,28 +66,32 @@ function expandCWButtonPrepare() 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; + var title = document.querySelector('#title'); + if (title) + { + 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'); - }); - }; + } + } } } @@ -132,13 +130,15 @@ function fileButtonUpdaters() function characterCountSetup() { - $("#status_count").text(characterCount()); - $("#id_status").keyup(function(){ + if ($("#id_status").length) { $("#status_count").text(characterCount()); - }); - $("#id_spoiler_text").keyup(function(){ - $("#status_count").text(characterCount()); - }); + $("#id_status").keyup(function(){ + $("#status_count").text(characterCount()); + }); + $("#id_spoiler_text").keyup(function(){ + $("#status_count").text(characterCount()); + }); + } } function characterCount()