From ce93e4f3bce5ff446c78ffda8beabbf187d91a56 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 19 Dec 2022 04:18:48 +0200 Subject: [PATCH] dont play profile songs during event --- files/assets/js/profile_song.js | 57 +++++++++++++++++++++++++ files/assets/js/userpage.js | 58 -------------------------- files/templates/userpage/userpage.html | 3 ++ 3 files changed, 60 insertions(+), 58 deletions(-) create mode 100644 files/assets/js/profile_song.js diff --git a/files/assets/js/profile_song.js b/files/assets/js/profile_song.js new file mode 100644 index 000000000..b88bbfa2f --- /dev/null +++ b/files/assets/js/profile_song.js @@ -0,0 +1,57 @@ +let u_username = document.getElementById('u_username') + +if (u_username) +{ + u_username = u_username.innerHTML + + let audio = new Audio(`/@${u_username}/song`); + audio.loop=true; + + function toggle() { + if (audio.paused) audio.play() + else audio.pause() + } + + audio.play(); + window.addEventListener('click', () => { + if (audio.paused) audio.play(); + }, {once : true}); + + prepare_to_pause(audio) +} +else +{ + let v_username = document.getElementById('v_username') + if (v_username) + { + v_username = v_username.innerHTML + + const paused = localStorage.getItem("paused") + + let audio = new Audio(`/@${v_username}/song`); + audio.loop=true; + + function toggle() { + if (audio.paused) + { + audio.play() + localStorage.setItem("paused", "") + } + else + { + audio.pause() + localStorage.setItem("paused", "1") + } + } + + if (!paused) + { + audio.play(); + window.addEventListener('click', () => { + if (audio.paused) audio.play(); + }, {once : true}); + } + + prepare_to_pause(audio) + } +} diff --git a/files/assets/js/userpage.js b/files/assets/js/userpage.js index eb2a0890a..cfbe1b170 100644 --- a/files/assets/js/userpage.js +++ b/files/assets/js/userpage.js @@ -1,61 +1,3 @@ -let u_username = document.getElementById('u_username') - -if (u_username) -{ - u_username = u_username.innerHTML - - let audio = new Audio(`/@${u_username}/song`); - audio.loop=true; - - function toggle() { - if (audio.paused) audio.play() - else audio.pause() - } - - audio.play(); - window.addEventListener('click', () => { - if (audio.paused) audio.play(); - }, {once : true}); - - prepare_to_pause(audio) -} -else -{ - let v_username = document.getElementById('v_username') - if (v_username) - { - v_username = v_username.innerHTML - - const paused = localStorage.getItem("paused") - - let audio = new Audio(`/@${v_username}/song`); - audio.loop=true; - - function toggle() { - if (audio.paused) - { - audio.play() - localStorage.setItem("paused", "") - } - else - { - audio.pause() - localStorage.setItem("paused", "1") - } - } - - if (!paused) - { - audio.play(); - window.addEventListener('click', () => { - if (audio.paused) audio.play(); - }, {once : true}); - } - - prepare_to_pause(audio) - } -} - function badge_timestamp(t) { const date = formatDate(new Date(t.dataset.until*1000)); const text = t.getAttribute("data-bs-original-title") diff --git a/files/templates/userpage/userpage.html b/files/templates/userpage/userpage.html index 06fa76fcd..e4b15c41d 100644 --- a/files/templates/userpage/userpage.html +++ b/files/templates/userpage/userpage.html @@ -35,6 +35,9 @@
{{u.username}}
{% endif %} +{% if not HOLIDAY_EVENT %} + +{% endif %} {% endblock %} {% block pagenav %}