Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Web/static/js/al_comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
18 changes: 9 additions & 9 deletions Web/static/js/al_feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
<table cellspacing="7" cellpadding="0" border="0" align="center">
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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(`
<tr>
Expand Down
65 changes: 35 additions & 30 deletions Web/static/js/al_music.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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(`
<div id='ajax_audio_player' class='ctx_place'>
<div id='aj_player'>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1426,7 +1431,7 @@ u(document).on("click", ".musicIcon.edit-icon", (e) => {

<div style="margin-top: 11px">
${tr("lyrics")}
<textarea name="lyrics" maxlength="5000" style="resize: vertical; max-height: 285px;">${lyrics ?? ""}</textarea>
<textarea name="lyrics" maxlength="5000" style="resize: vertical; max-height: 285px;">${lyrics || ""}</textarea>
</div>

<div style="margin-top: 11px">
Expand Down
2 changes: 1 addition & 1 deletion Web/static/js/al_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ u(`#search_box input[type='search']`).on('input', async (e) => {
<img src='${item['preview']}' class='search_tip_preview_block'>
<div class='search_tip_info_block'>
<b>${ovk_proc_strtr(item['name'].escapeHtml(), 50)}</b>
<span>${ovk_proc_strtr((item['description'] ?? '').escapeHtml(), 60)}</span>
<span>${ovk_proc_strtr((item['description'] || '').escapeHtml(), 60)}</span>
</div>
</a>
`)
Expand Down
2 changes: 1 addition & 1 deletion Web/static/js/al_photos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}])
}
}

Expand Down
24 changes: 14 additions & 10 deletions Web/static/js/al_wall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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: `
Expand Down Expand Up @@ -1575,9 +1575,9 @@ u(document).on('click', '#__videoAttachment', async (e) => {
</a>
<br>
<p>
<span class='video-desc'>${ovk_proc_strtr(escapeHtml(video.description ?? ""), 140)}</span>
<span class='video-desc'>${ovk_proc_strtr(escapeHtml(video.description || ""), 140)}</span>
</p>
<span><a href="/id${video.owner_id}" target="_blank">${ovk_proc_strtr(escapeHtml(author_name ?? ""), 100)}</a></span>
<span><a href="/id${video.owner_id}" target="_blank">${ovk_proc_strtr(escapeHtml(author_name || ""), 100)}</a></span>
</td>
<td valign="top" class="action_links">
<a class="profile_link" id="__attach_vid">${!is_attached ? tr("attach") : tr("detach")}</a>
Expand Down Expand Up @@ -2440,7 +2440,7 @@ async function __processPaginatorNextPage(page)
const showMoreObserver = new IntersectionObserver(entries => {
entries.forEach(async x => {
if(x.isIntersecting) {
if(Number(localStorage.getItem('ux.auto_scroll') ?? 1) == 0) {
if(Number(localStorage.getItem('ux.auto_scroll') || 1) == 0) {
return
}

Expand Down Expand Up @@ -2521,7 +2521,7 @@ u(document).on('click', '#__sourceAttacher', (e) => {
const nearest_textarea = _u_target.closest('#write')
const source_output = nearest_textarea.find(`input[name='source']`)
const source_input = u(`#source_flex_kunteynir input[type='text']`)
const source_value = source_input.nodes[0].value ?? ''
const source_value = source_input.nodes[0].value || ''
if(source_value.length < 1) {
return
}
Expand Down Expand Up @@ -2755,7 +2755,11 @@ u(document).on('click', "#__geoAttacher", async (e) => {
console.log(e.geocode.properties)
const lat = e.geocode.properties.lat
const lng = e.geocode.properties.lon
const name = e.geocode.properties?.display_name ? short_geo_name(e.geocode.properties?.address) : tr('geotag')
const name = e.geocode &&
e.geocode.properties &&
e.geocode.properties.display_name
? short_geo_name(e.geocode.properties.address)
: tr('geotag')

if(currentMarker) map.removeLayer(currentMarker)

Expand Down Expand Up @@ -2818,7 +2822,7 @@ function openGeo(data, owner_id, virtual_id) {
map.setView(target, 15);

let marker = L.marker(target).addTo(map);
marker.bindPopup(escapeHtml(data.name ?? tr("geotag"))).openPopup();
marker.bindPopup(escapeHtml(data.name || tr("geotag"))).openPopup();

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
Expand Down Expand Up @@ -3018,7 +3022,7 @@ u(document).on("submit", "#additional_fields_form", (e) => {
})
})

if(Number(localStorage.getItem('ux.gif_autoplay') ?? 0) == 1) {
if(Number(localStorage.getItem('ux.gif_autoplay') || 0) == 1) {
const showMoreObserver = new IntersectionObserver(entries => {
entries.forEach(async x => {
doc_item = x.target.closest(".docGalleryItem")
Expand Down
16 changes: 8 additions & 8 deletions Web/static/js/messagebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Function.noop = () => {};

class CMessageBox {
constructor(options = {}) {
const title = options.title ?? 'Untitled'
const body = options.body ?? '<hr>'
const buttons = options.buttons ?? []
const callbacks = options.callbacks ?? []
const close_on_buttons = options.close_on_buttons ?? true
const unique_name = options.unique_name ?? null
const warn_on_exit = options.warn_on_exit ?? false
const custom_template = options.custom_template ?? null
const title = options.title || 'Untitled'
const body = options.body || '<hr>'
const buttons = options.buttons || []
const callbacks = options.callbacks || []
const close_on_buttons = options.close_on_buttons || true
const unique_name = options.unique_name || null
const warn_on_exit = options.warn_on_exit || false
const custom_template = options.custom_template || null
if(unique_name && window.messagebox_stack.find(item => item.unique_name == unique_name) != null) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion Web/static/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ window.tweaks = [
u(".post").nodes.forEach(item => {
const post = u(item)
if (post.hasClass("hidden_because_of_word")) {return}
(window.hidden_words ?? []).forEach(word => {
(window.hidden_words || []).forEach(word => {
highlightText(word, '.scroll_container', [".post-author a", ".post:not(.comment) > tbody > tr > td > .post-content > .text .really_text"])
})
if (post.find(".highlight").length > 0) {post.addClass("hidden_because_of_word")}
Expand Down
12 changes: 6 additions & 6 deletions Web/static/js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ window.router = new class {
async __integratePage(scrolling = null) {
window.temp_y_scroll = null
u('.toTop').removeClass('has_down')
window.scrollTo(0, scrolling ?? 0)
window.scrollTo(0, scrolling || 0)
bsdnHydrate()

if(u('.paginator:not(.paginator-at-top)').length > 0) {
Expand Down Expand Up @@ -174,7 +174,7 @@ window.router = new class {
return false
}

if((localStorage.getItem('ux.disable_ajax_routing') ?? 0) == 1 || window.openvk.current_id == 0) {
if((localStorage.getItem('ux.disable_ajax_routing') || 0) == 1 || window.openvk.current_id == 0) {
return false
}

Expand Down Expand Up @@ -218,7 +218,7 @@ window.router = new class {
url = location.origin + url
}

if((localStorage.getItem('ux.disable_ajax_routing') ?? 0) == 1 || window.openvk.current_id == 0) {
if((localStorage.getItem('ux.disable_ajax_routing') || 0) == 1 || window.openvk.current_id == 0) {
window.location.assign(url)
return
}
Expand All @@ -227,7 +227,7 @@ window.router = new class {
this.prev_page_html = null
}

const push_url = params.push_state ?? true
const push_url = params.push_state || true
const next_page_url = new URL(url)
if(push_url) {
history.pushState({'from_router': 1}, '', url)
Expand Down Expand Up @@ -346,14 +346,14 @@ u(document).on('submit', 'form', async (e) => {
collect_attachments_node(target)
}

if((localStorage.getItem('ux.disable_ajax_routing') ?? 0) == 1 || window.openvk.current_id == 0) {
if((localStorage.getItem('ux.disable_ajax_routing') || 0) == 1 || window.openvk.current_id == 0) {
return false
}

u('#ajloader').addClass('shown')

const form = e.target
const method = form.method ?? 'get'
const method = form.method || 'get'
const url = form.action
if(form.onsubmit || url.indexOf('/settings?act=interface') != -1) {
u('#ajloader').removeClass('shown')
Expand Down