add beforeUnload event

This commit is contained in:
mrilyew 2024-12-05 18:49:15 +03:00
parent 178cefede9
commit 22d3e5e494
3 changed files with 10 additions and 2 deletions

View file

@ -553,7 +553,7 @@
}
.audioEntry .buttons .report-icon {
background-position: -50px -67px;
background-position: -51px -67px;
}
.audioEntry .buttons .remove-icon {

View file

@ -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'))

View file

@ -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)
}