mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
Compare commits
3 commits
1faa250d6f
...
3bb69b2a10
Author | SHA1 | Date | |
---|---|---|---|
|
3bb69b2a10 | ||
|
9a81e354ea | ||
|
7474d46743 |
6 changed files with 349 additions and 247 deletions
|
@ -912,7 +912,7 @@
|
|||
width: 500px;
|
||||
height: 37px;
|
||||
position: fixed;
|
||||
z-index: 99;
|
||||
z-index: 1025;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ window.player = new class {
|
|||
u(this.audioPlayer).trigger('volumechange')
|
||||
}
|
||||
|
||||
async setTrack(id) {
|
||||
async setTrack(id, ref = null) {
|
||||
if(!this.tracks || this.tracks.length < 1) {
|
||||
makeError('Context is not loaded yet', 'Red', 5000, 1489)
|
||||
return
|
||||
|
@ -313,6 +313,10 @@ window.player = new class {
|
|||
}
|
||||
|
||||
this.is_closed = false
|
||||
if(ref != 'localstorage') {
|
||||
this.dump()
|
||||
}
|
||||
|
||||
this.__updateFace()
|
||||
u(this.audioPlayer).trigger('volumechange')
|
||||
}
|
||||
|
@ -405,6 +409,35 @@ window.player = new class {
|
|||
return u('.bigPlayer').length > 0
|
||||
}
|
||||
|
||||
dump() {
|
||||
const final = {
|
||||
context: this.context,
|
||||
current_track_id: this.current_track_id,
|
||||
tracks: this.tracks,
|
||||
time: this.audioPlayer.currentTime,
|
||||
}
|
||||
|
||||
localStorage.setItem('audio.lastDump', JSON.stringify(final))
|
||||
console.log('Audio | Tracks was dumped')
|
||||
}
|
||||
|
||||
undump() {
|
||||
localStorage.setItem('audio.lastDump', null)
|
||||
}
|
||||
|
||||
async loadDump(dump_object) {
|
||||
this.context = dump_object.context
|
||||
this.current_track_id = dump_object.current_track_id
|
||||
this.tracks = dump_object.tracks
|
||||
if(this.current_track_id) {
|
||||
await this.setTrack(this.current_track_id, 'localstorage')
|
||||
}
|
||||
|
||||
if(dump_object.time) {
|
||||
this.audioPlayer.currentTime = dump_object.time
|
||||
}
|
||||
}
|
||||
|
||||
// Добавляем ощущение продуманности.
|
||||
__highlightActiveTrack() {
|
||||
u(`.audiosContainer .audioEmbed[data-realid='${this.current_track_id}'] .audioEntry, .audios_padding .audioEmbed[data-realid='${this.current_track_id}'] .audioEntry`).addClass('nowPlaying')
|
||||
|
@ -432,7 +465,6 @@ window.player = new class {
|
|||
}
|
||||
|
||||
async _handlePageTransition() {
|
||||
console.log('Audio | Switched page :3')
|
||||
const state = this.isAtAudiosPage()
|
||||
if(!state) {
|
||||
// AJAX audio player
|
||||
|
@ -721,7 +753,22 @@ window.player = new class {
|
|||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
let parsed = null
|
||||
try {
|
||||
parsed = JSON.parse(localStorage.getItem('audio.lastDump'))
|
||||
} catch(e) {}
|
||||
|
||||
if(parsed) {
|
||||
await window.player.init(null)
|
||||
await window.player.loadDump(parsed)
|
||||
if(!window.player.isAtAudiosPage()) {
|
||||
window.player.ajReveal()
|
||||
window.player.__updateFace()
|
||||
u(window.player.audioPlayer).trigger('timeupdate')
|
||||
}
|
||||
} else {
|
||||
await window.player.init(window.__current_page_audio_context)
|
||||
}
|
||||
})
|
||||
|
||||
u(document).on('click', '.audioEntry .playerButton > .playIcon', async (e) => {
|
||||
|
@ -1190,8 +1237,10 @@ u(document).on('contextmenu', '.bigPlayer, .audioEmbed, #ajax_audio_player', (e)
|
|||
ctx_u.find('#audio_ctx_clear_context').on('click', (ev) => {
|
||||
const old_url = window.player.context.object.url
|
||||
window.player.pause()
|
||||
window.player.ajClose()
|
||||
window.player.__resetContext()
|
||||
window.player.__updateFace()
|
||||
window.player.undump()
|
||||
window.router.route(old_url)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -424,7 +424,7 @@ async function OpenVideo(video_arr = [], init_player = true)
|
|||
|
||||
u('body').append(miniplayer)
|
||||
miniplayer.find('.miniplayer-body').nodes[0].append(msgbox.getNode().find('.center-part > *').nodes[0])
|
||||
miniplayer.attr('style', `left:100px;top:${scrollY}px;`)
|
||||
miniplayer.attr('style', `left:100px;top:0px;`)
|
||||
miniplayer.find('#__miniplayer_return').on('click', (e) => {
|
||||
msgbox.reveal()
|
||||
msgbox.getNode().find('.center-part').nodes[0].append(miniplayer.find('.miniplayer-body > *').nodes[0])
|
||||
|
@ -2218,7 +2218,6 @@ $(document).on("click", "#add_image", (e) => {
|
|||
let video = document.querySelector("#_takeSelfieFrame video")
|
||||
|
||||
if(!navigator.mediaDevices) {
|
||||
// ех вот бы месседжбоксы были бы классами
|
||||
u("body").removeClass("dimmed");
|
||||
document.querySelector("html").style.overflowY = "scroll"
|
||||
u(".ovk-diag-cont").remove();
|
||||
|
@ -2365,6 +2364,10 @@ async function __processPaginatorNextPage(page)
|
|||
window.player.loadContext(page)
|
||||
}
|
||||
|
||||
/*if(window.router) {
|
||||
window.router.savePreviousPage()
|
||||
}*/
|
||||
|
||||
const new_url = new URL(location.href)
|
||||
new_url.hash = page
|
||||
history.replaceState(null, null, new_url)
|
||||
|
|
|
@ -82,7 +82,7 @@ class CMessageBox {
|
|||
|
||||
__exitDialog() {
|
||||
this.getNode().remove()
|
||||
if(u('.ovk-msg-all').length < 1) {
|
||||
if(u('.ovk-msg-all:not(.msgbox-hidden)').length < 1) {
|
||||
u('body').removeClass('dimmed')
|
||||
u('html').attr('style', 'overflow-y:scroll')
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class CMessageBox {
|
|||
hide() {
|
||||
u('body').removeClass('dimmed')
|
||||
u('html').attr('style', 'overflow-y:scroll')
|
||||
this.getNode().attr('style', 'display: none;')
|
||||
this.getNode().attr('style', 'display: none;').addClass('msgbox-hidden')
|
||||
this.hidden = true
|
||||
}
|
||||
|
||||
|
|
|
@ -107,8 +107,8 @@ window.router = new class {
|
|||
})
|
||||
}
|
||||
|
||||
async __integratePage() {
|
||||
window.scrollTo(0, 0)
|
||||
async __integratePage(scrolling = null) {
|
||||
window.scrollTo(0, scrolling ?? 0)
|
||||
bsdnHydrate()
|
||||
|
||||
if(u('.paginator:not(.paginator-at-top)').length > 0) {
|
||||
|
@ -120,6 +120,7 @@ window.router = new class {
|
|||
}
|
||||
|
||||
if(window.player) {
|
||||
window.player.dump()
|
||||
await window.player._handlePageTransition()
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +159,14 @@ window.router = new class {
|
|||
return true
|
||||
}
|
||||
|
||||
savePreviousPage() {
|
||||
this.prev_page_html = {
|
||||
url: location.href,
|
||||
pathname: location.pathname,
|
||||
html: u('.page_body').html(),
|
||||
}
|
||||
}
|
||||
|
||||
async route(params = {}) {
|
||||
if(typeof params == 'string') {
|
||||
params = {
|
||||
|
@ -176,6 +185,10 @@ window.router = new class {
|
|||
return
|
||||
}
|
||||
|
||||
if(this.prev_page_html && this.prev_page_html.pathname != location.pathname) {
|
||||
this.prev_page_html = null
|
||||
}
|
||||
|
||||
const push_url = params.push_state ?? true
|
||||
const next_page_url = new URL(url)
|
||||
if(push_url) {
|
||||
|
@ -342,6 +355,14 @@ u(document).on('submit', 'form', async (e) => {
|
|||
|
||||
window.addEventListener('popstate', (e) => {
|
||||
e.preventDefault();
|
||||
/*if(window.router.prev_page_html) {
|
||||
u('.page_body').html(window.router.prev_page_html.html)
|
||||
history.replaceState({'from_router': 1}, '', window.router.prev_page_html.url)
|
||||
window.router.prev_page_html = null
|
||||
window.router.__integratePage()
|
||||
return
|
||||
}*/
|
||||
|
||||
window.router.route({
|
||||
url: location.href,
|
||||
push_state: false,
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue