From 22d3e5e494a04436c7b3b1b575fcd772d3ae5376 Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:49:15 +0300 Subject: [PATCH] add beforeUnload event --- Web/static/css/audios.css | 2 +- Web/static/js/al_music.js | 8 ++++++++ Web/static/js/al_wall.js | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Web/static/css/audios.css b/Web/static/css/audios.css index 1bbcf5e6..b0a9e8ca 100644 --- a/Web/static/css/audios.css +++ b/Web/static/css/audios.css @@ -553,7 +553,7 @@ } .audioEntry .buttons .report-icon { - background-position: -50px -67px; + background-position: -51px -67px; } .audioEntry .buttons .remove-icon { diff --git a/Web/static/js/al_music.js b/Web/static/js/al_music.js index 3f3ebf25..a5bc8a6a 100644 --- a/Web/static/js/al_music.js +++ b/Web/static/js/al_music.js @@ -409,6 +409,10 @@ window.player = new class { return u('.bigPlayer').length > 0 } + isAtCurrentContextPage() { + return this.isAtAudiosPage() && this.context.object.url == location.pathname + location.search + } + dump() { const final = { context: this.context, @@ -776,6 +780,10 @@ document.addEventListener("DOMContentLoaded", async () => { } }) +window.addEventListener('beforeunload', (e) => { + window.player.dump() +}) + u(document).on('click', '.audioEntry .playerButton > .playIcon', async (e) => { const audioPlayer = u(e.target).closest('.audioEmbed') const id = Number(audioPlayer.attr('data-realid')) diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 6f0fe28d..f0b26209 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -2360,7 +2360,7 @@ async function __processPaginatorNextPage(page) container.nodes[0].append(u(`.paginator:not(.paginator-at-top)`).nodes[0].parentNode) } - if(window.player && window.player.isAtAudiosPage()) { + if(window.player && window.player.isAtAudiosPage() && window.player.isAtCurrentContextPage()) { window.player.loadContext(page) }