do something like this https://rdrama.net/post/18459/marseycapywalking-megathread-for-bugs-and-suggestions/4105303#context
parent
9e9899788f
commit
e8a6203329
|
@ -1,5 +1,24 @@
|
|||
let u_username = document.getElementById('u_username')
|
||||
|
||||
const anthem_button = document.getElementById('toggle-anthem')
|
||||
const anthem_button_mobile = document.getElementById('toggle-anthem-mobile')
|
||||
|
||||
function play_audio(audio) {
|
||||
audio.play()
|
||||
if (anthem_button && !audio.paused) {
|
||||
anthem_button.classList.add('text-primary')
|
||||
anthem_button_mobile.classList.add('text-primary')
|
||||
}
|
||||
}
|
||||
|
||||
function pause_audio(audio) {
|
||||
audio.pause()
|
||||
if (anthem_button && audio.paused) {
|
||||
anthem_button.classList.remove('text-primary')
|
||||
anthem_button_mobile.classList.remove('text-primary')
|
||||
}
|
||||
}
|
||||
|
||||
if (u_username)
|
||||
{
|
||||
u_username = u_username.innerHTML
|
||||
|
@ -9,18 +28,16 @@ if (u_username)
|
|||
|
||||
function toggle() {
|
||||
if (audio.paused) {
|
||||
audio.play();
|
||||
audio.play();
|
||||
play_audio(audio);
|
||||
}
|
||||
else {
|
||||
audio.pause();
|
||||
audio.pause();
|
||||
pause_audio(audio);
|
||||
}
|
||||
}
|
||||
|
||||
audio.play();
|
||||
play_audio(audio);
|
||||
document.addEventListener('click', () => {
|
||||
if (audio.paused) audio.play();
|
||||
if (audio.paused) play_audio(audio);
|
||||
}, {once : true});
|
||||
|
||||
prepare_to_pause(audio)
|
||||
|
@ -40,21 +57,21 @@ else
|
|||
function toggle() {
|
||||
if (audio.paused)
|
||||
{
|
||||
audio.play()
|
||||
play_audio(audio)
|
||||
localStorage.setItem("paused", "")
|
||||
}
|
||||
else
|
||||
{
|
||||
audio.pause()
|
||||
pause_audio(audio)
|
||||
localStorage.setItem("paused", "1")
|
||||
}
|
||||
}
|
||||
|
||||
if (!paused)
|
||||
{
|
||||
audio.play();
|
||||
play_audio(audio);
|
||||
document.addEventListener('click', () => {
|
||||
if (audio.paused) audio.play();
|
||||
if (audio.paused) play_audio(audio);
|
||||
}, {once : true});
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if FEATURES['USERS_PROFILE_SONG'] and u.song and v and (v.id == u.id or v.mute and not u.unmutable) %}
|
||||
<button type="button" class="btn btn-secondary" data-nonce="{{g.nonce}}" data-onclick="toggle()" {% if v.id == u.id %}style="margin-bottom:0!important;padding:0.3rem 0.75rem!important"{% endif %}><i class="fas fa-music mr-1"></i> Toggle Anthem</button>
|
||||
<button id="toggle-anthem" type="button" class="btn btn-secondary" data-nonce="{{g.nonce}}" data-onclick="toggle()" {% if v.id == u.id %}style="margin-bottom:0!important;padding:0.3rem 0.75rem!important"{% endif %}><i class="fas fa-music mr-1"></i> Profile Anthem</button>
|
||||
{% endif %}
|
||||
|
||||
{% if v and v.id == u.id %}
|
||||
|
@ -413,7 +413,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if FEATURES['USERS_PROFILE_SONG'] and u.song and v and (v.id == u.id or v.mute and not u.unmutable) %}
|
||||
<button type="button" class="btn btn-secondary" data-nonce="{{g.nonce}}" data-onclick="toggle()" {% if v.id == u.id %}style="margin-bottom:0!important;padding:0.3rem 0.75rem!important"{% endif %}><i class="fas fa-music mr-1"></i> Toggle Anthem</button>
|
||||
<button id="toggle-anthem-mobile" type="button" class="btn btn-secondary" data-nonce="{{g.nonce}}" data-onclick="toggle()" {% if v.id == u.id %}style="margin-bottom:0!important;padding:0.3rem 0.75rem!important"{% endif %}><i class="fas fa-music mr-1"></i> Profile Anthem</button>
|
||||
{% endif %}
|
||||
|
||||
{% if v and v.id == u.id %}
|
||||
|
|
Loading…
Reference in New Issue