diff --git a/Web/static/js/al_comments.js b/Web/static/js/al_comments.js index ad398637f..f4b13e387 100644 --- a/Web/static/js/al_comments.js +++ b/Web/static/js/al_comments.js @@ -9,7 +9,7 @@ u(document).on("click", ".comment-reply", function(e) { // Substitute pervious mention if present, prepend otherwise inputbox.nodes.forEach(node => { - node.value = node.value.replace(/(^\[([A-Za-z0-9]+)\|([\p{L} 0-9@]+)\], |^)/u, mention); + node.value = node.value.replace(/(^\[([A-Za-z0-9]+)\|([A-Za-zА-Яа-яЁё0-9 @]+)\], |^)/, mention); }) inputbox.trigger("focusin"); }); diff --git a/Web/static/js/al_feed.js b/Web/static/js/al_feed.js index d96779ca3..4ee350c43 100644 --- a/Web/static/js/al_feed.js +++ b/Web/static/js/al_feed.js @@ -127,10 +127,10 @@ u(document).on('click', '#__feed_settings_link', (e) => { switch(current_tab) { case 'main': const __temp_url = new URL(location.href) - const PAGES_COUNT = Number(e.target.dataset.pagescount ?? '10') - const CURRENT_PERPAGE = Number(__temp_url.searchParams.get('posts') ?? 10) - const CURRENT_PAGE = Number(__temp_url.searchParams.get('p') ?? 1) - const CURRENT_RETURN_BANNED = Number(__temp_url.searchParams.get('return_banned') ?? 0) + const PAGES_COUNT = Number(e.target.dataset.pagescount || '10') + const CURRENT_PERPAGE = Number(__temp_url.searchParams.get('posts') || 10) + const CURRENT_PAGE = Number(__temp_url.searchParams.get('p') || 1) + const CURRENT_RETURN_BANNED = Number(__temp_url.searchParams.get('return_banned') || 0) const COUNT = [1, 5, 10, 20, 30, 40, 50] u('#_feed_settings_container #__content').html(` @@ -173,9 +173,9 @@ u(document).on('click', '#__feed_settings_link', (e) => { `) u(`#_feed_settings_container #__content input[type='button']`).on('click', (e) => { - const INPUT_PAGES_COUNT = parseInt(u('#_feed_settings_container #__content #pageSelect').nodes[0].selectedOptions[0].value ?? '10') - const INPUT_PAGE = parseInt(u('#_feed_settings_container #__content #pageNumber').nodes[0].value ?? '1') - const INPUT_IGNORED = Number(u('#_feed_settings_container #__content #showIgnored').nodes[0].checked ?? false) + const INPUT_PAGES_COUNT = parseInt(u('#_feed_settings_container #__content #pageSelect').nodes[0].selectedOptions[0].value || '10') + const INPUT_PAGE = parseInt(u('#_feed_settings_container #__content #pageNumber').nodes[0].value || '1') + const INPUT_IGNORED = Number(u('#_feed_settings_container #__content #showIgnored').nodes[0].checked || false) const FINAL_URL = new URL(location.href) @@ -326,8 +326,8 @@ u(document).on('change', `input[data-act='localstorage_item']`, (e) => { }) function openJsSettings() { - const CURRENT_AUTO_SCROLL = Number(localStorage.getItem('ux.auto_scroll') ?? 1) - const CURRENT_DISABLE_AJAX = Number(localStorage.getItem('ux.disable_ajax_routing') ?? 0) + const CURRENT_AUTO_SCROLL = Number(localStorage.getItem('ux.auto_scroll') || 1) + const CURRENT_DISABLE_AJAX = Number(localStorage.getItem('ux.disable_ajax_routing') || 0) u("#_js_settings").append(` diff --git a/Web/static/js/al_music.js b/Web/static/js/al_music.js index d9b8a2ea8..499d46a6f 100644 --- a/Web/static/js/al_music.js +++ b/Web/static/js/al_music.js @@ -72,7 +72,7 @@ window.player = new class { // 0 - shows remaining time before end // 1 - shows full track time get timeType() { - return localStorage.getItem('audio.timeType') ?? 0 + return localStorage.getItem('audio.timeType') || 0 } set timeType(value) { @@ -216,7 +216,7 @@ window.player = new class { } } - this.audioPlayer.volume = Number(localStorage.getItem('audio.volume') ?? 1) + this.audioPlayer.volume = Number(localStorage.getItem('audio.volume') || 1) } async loadContext(page = 1, after = true) { @@ -290,7 +290,7 @@ window.player = new class { console.log('Audio | Resetting context because of ajax') this.__renewContext() - await this.loadContext(window.__current_page_audio_context.page ?? 1) + await this.loadContext(window.__current_page_audio_context.page || 1) if(!isNaN(parseInt(location.hash.replace('#', '')))) { const adp = parseInt(location.hash.replace('#', '')) await this.loadContext(adp) @@ -320,10 +320,11 @@ window.player = new class { u('.nowPlaying').removeClass('nowPlaying') this.__highlightActiveTrack() - - navigator.mediaSession.setPositionState({ - duration: this.currentTrack.length - }) + if ('mediaSession' in navigator) { + navigator.mediaSession.setPositionState({ + duration: this.currentTrack.length + }) + } this.__updateMediaSession() this.dashPlayer.initialize(this.audioPlayer, c_track.url, false); this.dashPlayer.setProtectionData(protData) @@ -382,7 +383,7 @@ window.player = new class { await this.audioPlayer.play() this.__setFavicon() this.__updateFace() - navigator.mediaSession.playbackState = "playing" + if ('mediaSession' in navigator) navigator.mediaSession.playbackState = "playing" } pause() { @@ -393,7 +394,7 @@ window.player = new class { this.audioPlayer.pause() this.__setFavicon('paused') this.__updateFace() - navigator.mediaSession.playbackState = "paused" + if ('mediaSession' in navigator) navigator.mediaSession.playbackState = "paused" } async playPreviousTrack() { @@ -573,17 +574,19 @@ window.player = new class { } __setMediaSessionActions() { - navigator.mediaSession.setActionHandler('play', async () => { - await window.player.play() - }); - navigator.mediaSession.setActionHandler('pause', () => { - window.player.pause() - }); - navigator.mediaSession.setActionHandler('previoustrack', async () => { await window.player.playPreviousTrack() }); - navigator.mediaSession.setActionHandler('nexttrack', async () => { await window.player.playNextTrack() }); - navigator.mediaSession.setActionHandler("seekto", async (details) => { - window.player.audioPlayer.currentTime = details.seekTime - }); + if ('mediaSession' in navigator) { + navigator.mediaSession.setActionHandler('play', async () => { + await window.player.play() + }); + navigator.mediaSession.setActionHandler('pause', () => { + window.player.pause() + }); + navigator.mediaSession.setActionHandler('previoustrack', async () => { await window.player.playPreviousTrack() }); + navigator.mediaSession.setActionHandler('nexttrack', async () => { await window.player.playNextTrack() }); + navigator.mediaSession.setActionHandler("seekto", async (details) => { + window.player.audioPlayer.currentTime = details.seekTime + }); + } } __appendTracks(list, after = true) { @@ -691,12 +694,14 @@ window.player = new class { __updateMediaSession() { const album = document.querySelector(".playlistBlock") const cur = this.currentTrack - navigator.mediaSession.metadata = new MediaMetadata({ - title: escapeHtml(cur.name), - artist: escapeHtml(cur.performer), - album: album == null ? "OpenVK Audios" : escapeHtml(album.querySelector(".playlistInfo h4").innerHTML), - artwork: [{ src: album == null ? "/assets/packages/static/openvk/img/song.jpg" : album.querySelector(".playlistCover img").src }], - }) + if ('mediaSession' in navigator) { + navigator.mediaSession.metadata = new MediaMetadata({ + title: escapeHtml(cur.name), + artist: escapeHtml(cur.performer), + album: album == null ? "OpenVK Audios" : escapeHtml(album.querySelector(".playlistInfo h4").innerHTML), + artwork: [{ src: album == null ? "/assets/packages/static/openvk/img/song.jpg" : album.querySelector(".playlistCover img").src }], + }) + } } async __countListen() { @@ -790,8 +795,8 @@ window.player = new class { } ajCreate() { - const previous_time_x = localStorage.getItem('audio.lastX') ?? 100 - const previous_time_y = localStorage.getItem('audio.lastY') ?? scrollY + const previous_time_x = localStorage.getItem('audio.lastX') || 100 + const previous_time_y = localStorage.getItem('audio.lastY') || scrollY const miniplayer_template = u(`
@@ -952,7 +957,7 @@ u(document).on('click', '.audioEntry .playerButton > .playIcon', async (e) => { }) } else if(!window.player.hasTrackWithId(id) && window.player.isAtAudiosPage()) { window.player.__renewContext() - await window.player.loadContext(window.__current_page_audio_context.page ?? 1) + await window.player.loadContext(window.__current_page_audio_context.page || 1) if(!isNaN(parseInt(location.hash.replace('#', '')))) { const adp = parseInt(location.hash.replace('#', '')) await window.player.loadContext(adp) @@ -1426,7 +1431,7 @@ u(document).on("click", ".musicIcon.edit-icon", (e) => {
${tr("lyrics")} - +
diff --git a/Web/static/js/al_navigation.js b/Web/static/js/al_navigation.js index 49ec43852..d3f0e62f9 100644 --- a/Web/static/js/al_navigation.js +++ b/Web/static/js/al_navigation.js @@ -142,7 +142,7 @@ u(`#search_box input[type='search']`).on('input', async (e) => {
${ovk_proc_strtr(item['name'].escapeHtml(), 50)} - ${ovk_proc_strtr((item['description'] ?? '').escapeHtml(), 60)} + ${ovk_proc_strtr((item['description'] || '').escapeHtml(), 60)}
`) diff --git a/Web/static/js/al_photos.js b/Web/static/js/al_photos.js index 335495018..0a816cb42 100644 --- a/Web/static/js/al_photos.js +++ b/Web/static/js/al_photos.js @@ -69,7 +69,7 @@ $(document).on("change", ".photo_ajax_upload_button", (e) => { document.getElementById("endUploading").style.display = "block" } else { u("#loader").remove() - MessageBox(tr("error"), escapeHtml(result.flash.message) ?? tr("error_uploading_photo"), [tr("ok")], [() => {Function.noop}]) + MessageBox(tr("error"), escapeHtml(result.flash.message) || tr("error_uploading_photo"), [tr("ok")], [() => {Function.noop}]) } } diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 26c2aef44..b8dafc75a 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -97,7 +97,7 @@ async function OpenMiniature(e, photo, post, photo_id, type = "post") { const albums_per_page = 20 let json; - let offset = type == 'album' ? (Number((new URL(location.href)).searchParams.get('p') ?? 1) - 1) * albums_per_page : 0 + let offset = type == 'album' ? (Number((new URL(location.href)).searchParams.get('p') || 1) - 1) * albums_per_page : 0 let shown_offset = 0 let imagesCount = 0; @@ -137,7 +137,7 @@ async function OpenMiniature(e, photo, post, photo_id, type = "post") { }); function __getIndex(photo_id = null) { - return Object.keys(json.body).findIndex(item => item == (photo_id ?? currentImageid)) + 1 + return Object.keys(json.body).findIndex(item => item == (photo_id || currentImageid)) + 1 } function __getByIndex(id) { @@ -1352,7 +1352,7 @@ u(document).on("drop", '#write', function(e) { u(document).on("click", "#__photoAttachment", async (e) => { const photos_per_page = 23 const form = u(e.target).closest('form') - const club = Number(e.currentTarget.dataset.club ?? 0) + const club = Number(e.currentTarget.dataset.club || 0) const msg = new CMessageBox({ title: tr('select_photo'), body: ` @@ -1575,9 +1575,9 @@ u(document).on('click', '#__videoAttachment', async (e) => {

- ${ovk_proc_strtr(escapeHtml(video.description ?? ""), 140)} + ${ovk_proc_strtr(escapeHtml(video.description || ""), 140)}

- ${ovk_proc_strtr(escapeHtml(author_name ?? ""), 100)} + ${ovk_proc_strtr(escapeHtml(author_name || ""), 100)}