fdsafdas
This commit is contained in:
+161
-47
@@ -1839,9 +1839,11 @@ window.cancelAnimFrame = (function () {
|
||||
window.applyBackgroundOpacitySettings(window.onaraTuning || null, true);
|
||||
}
|
||||
window._bgModeAutoSwitch = true;
|
||||
const onaraModeBtn = document.querySelector('#bg-mode-btn-onara');
|
||||
if (onaraModeBtn) onaraModeBtn.click();
|
||||
if (typeof window.setBgTunerMode === 'function') {
|
||||
window.setBgTunerMode('onara');
|
||||
}
|
||||
window._bgModeAutoSwitch = false;
|
||||
modal.scrollTop = 0;
|
||||
if (document.querySelector('.index-container') && window.scrollY !== 0) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
@@ -1878,18 +1880,18 @@ window.cancelAnimFrame = (function () {
|
||||
const scrollOnaraThumbIntoView = (thumb, forceCenter = false) => {
|
||||
if (!thumb) return;
|
||||
const container = thumb.closest('.index-container');
|
||||
if (container) {
|
||||
const cRect = container.getBoundingClientRect();
|
||||
const tRect = thumb.getBoundingClientRect();
|
||||
const navbarH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--navbar-h')) || 50;
|
||||
const vh = window.innerHeight || document.documentElement.clientHeight;
|
||||
const isVisible = tRect.bottom > navbarH && tRect.top < vh;
|
||||
if (!isVisible || forceCenter) {
|
||||
const navbarH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--navbar-h')) || 50;
|
||||
const vh = window.innerHeight || document.documentElement.clientHeight;
|
||||
const tRect = thumb.getBoundingClientRect();
|
||||
const isVisible = tRect.bottom > navbarH && tRect.top < vh;
|
||||
if (!isVisible || forceCenter) {
|
||||
if (container) {
|
||||
const cRect = container.getBoundingClientRect();
|
||||
const targetScrollTop = container.scrollTop + (tRect.top - cRect.top) - (container.clientHeight / 2) + (tRect.height / 2);
|
||||
container.scrollTop = Math.max(0, targetScrollTop);
|
||||
} else {
|
||||
thumb.scrollIntoView({ block: forceCenter ? 'center' : 'nearest', inline: 'nearest', behavior: 'instant' });
|
||||
}
|
||||
} else {
|
||||
thumb.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
|
||||
}
|
||||
if (document.querySelector('.index-container') && window.scrollY !== 0) {
|
||||
window.scrollTo(0, 0);
|
||||
@@ -1956,7 +1958,39 @@ window.cancelAnimFrame = (function () {
|
||||
if (extraMeta.dest && !targetThumb.dataset.file) {
|
||||
targetThumb.dataset.file = String(extraMeta.dest).replace(/^\/b\//, '');
|
||||
}
|
||||
if (extraMeta.numericId && !targetThumb.dataset.itemId) {
|
||||
targetThumb.dataset.itemId = String(extraMeta.numericId);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure thumbnail image is loaded and rendered immediately
|
||||
const numericId = targetThumb.dataset.itemId || extraMeta?.numericId || (typeof itemid === 'number' || (typeof itemid === 'string' && /^\d+$/.test(itemid)) ? itemid : null);
|
||||
let rawBg = targetThumb.dataset.bg || extraMeta?.thumb || (numericId ? `/t/${numericId}.webp` : null);
|
||||
if (rawBg) {
|
||||
let bg = rawBg;
|
||||
const mode = targetThumb.getAttribute('data-mode') || extraMeta?.mode;
|
||||
const blurNsfw = localStorage.getItem('blurNsfw') === 'true';
|
||||
const blurNsfl = localStorage.getItem('blurNsfl') === 'true';
|
||||
const blurSfw = localStorage.getItem('blurSfw') === 'true';
|
||||
const blurUntagged = localStorage.getItem('blurUntagged') === 'true';
|
||||
let shouldBlurThis = false;
|
||||
if (mode === 'nsfw') shouldBlurThis = blurNsfw;
|
||||
else if (mode === 'nsfl') shouldBlurThis = blurNsfl;
|
||||
else if (mode === 'sfw') shouldBlurThis = blurSfw;
|
||||
else if (mode === 'null' || !mode) shouldBlurThis = blurUntagged;
|
||||
if (shouldBlurThis && !targetThumb.classList.contains('revealed')) {
|
||||
bg = bg.replace('.webp', '_blur.webp');
|
||||
}
|
||||
const finalBg = typeof window.applyThumbCacheBust === 'function' ? window.applyThumbCacheBust(bg) : bg;
|
||||
targetThumb.dataset.bg = finalBg;
|
||||
targetThumb.style.setProperty('--thumb-bg', `url('${finalBg}')`);
|
||||
targetThumb.classList.add('loaded');
|
||||
targetThumb.classList.remove('lazy-thumb');
|
||||
if (window.loadedThumbs) window.loadedThumbs.add(finalBg);
|
||||
const img = new Image();
|
||||
img.src = finalBg;
|
||||
}
|
||||
|
||||
scrollOnaraThumbIntoView(targetThumb, forceScroll);
|
||||
}
|
||||
return targetThumb;
|
||||
@@ -2046,9 +2080,11 @@ window.cancelAnimFrame = (function () {
|
||||
const { numericId, thumb, mode, mime, user, dest } = resolveItemThumbInfo(itemid, slug, extraMeta);
|
||||
const synthThumb = document.createElement('a');
|
||||
synthThumb.href = url || `/${slug || itemid}`;
|
||||
synthThumb.className = 'thumb lazy-thumb onara-active onara-synth-thumb loaded';
|
||||
synthThumb.className = 'thumb onara-active onara-synth-thumb loaded';
|
||||
if (numericId) {
|
||||
synthThumb.dataset.itemId = numericId;
|
||||
synthThumb.dataset.itemId = String(numericId);
|
||||
} else if (typeof itemid === 'string' && /^\d+$/.test(itemid)) {
|
||||
synthThumb.dataset.itemId = itemid;
|
||||
}
|
||||
if (mime) {
|
||||
synthThumb.dataset.mime = mime;
|
||||
@@ -2060,12 +2096,28 @@ window.cancelAnimFrame = (function () {
|
||||
if (dest) {
|
||||
synthThumb.dataset.file = String(dest).replace(/^\/b\//, '');
|
||||
}
|
||||
const finalThumbUrl = thumb || (numericId ? `/t/${numericId}.webp` : `/t/${itemid}.webp`);
|
||||
let baseThumbUrl = thumb || (numericId ? `/t/${numericId}.webp` : `/t/${itemid}.webp`);
|
||||
const blurNsfw = localStorage.getItem('blurNsfw') === 'true';
|
||||
const blurNsfl = localStorage.getItem('blurNsfl') === 'true';
|
||||
const blurSfw = localStorage.getItem('blurSfw') === 'true';
|
||||
const blurUntagged = localStorage.getItem('blurUntagged') === 'true';
|
||||
let shouldBlurThis = false;
|
||||
if (mode === 'nsfw') shouldBlurThis = blurNsfw;
|
||||
else if (mode === 'nsfl') shouldBlurThis = blurNsfl;
|
||||
else if (mode === 'sfw') shouldBlurThis = blurSfw;
|
||||
else if (mode === 'null' || !mode) shouldBlurThis = blurUntagged;
|
||||
if (shouldBlurThis) {
|
||||
baseThumbUrl = baseThumbUrl.replace('.webp', '_blur.webp');
|
||||
}
|
||||
const finalThumbUrl = typeof window.applyThumbCacheBust === 'function' ? window.applyThumbCacheBust(baseThumbUrl) : baseThumbUrl;
|
||||
synthThumb.dataset.bg = finalThumbUrl;
|
||||
synthThumb.setAttribute('data-mode', mode || 'sfw');
|
||||
synthThumb.dataset.size = '1';
|
||||
synthThumb.style.setProperty('--thumb-bg', `url('${finalThumbUrl}')`);
|
||||
synthThumb.innerHTML = '<div class="thumb-indicators"></div><div class="thumb-select-check"><i class="fa-solid fa-check"></i></div><p></p>';
|
||||
if (window.loadedThumbs) window.loadedThumbs.add(finalThumbUrl);
|
||||
const img = new Image();
|
||||
img.src = finalThumbUrl;
|
||||
return synthThumb;
|
||||
};
|
||||
|
||||
@@ -2278,7 +2330,8 @@ window.cancelAnimFrame = (function () {
|
||||
return !p.match(/\/p\//) && (
|
||||
/^\/\d+/.test(p) ||
|
||||
/^\/[a-zA-Z0-9_-]{11}(?:[?#]|$)/.test(p) ||
|
||||
(parts.length >= 3 && (parts[0] === 'tag' || parts[0] === 'user' || parts[0] === 'h') && (/^\d+$/.test(parts[parts.length - 1]) || /^[a-zA-Z0-9_-]{11}$/.test(parts[parts.length - 1])))
|
||||
(parts.length >= 3 && (parts[0] === 'tag' || parts[0] === 'user' || parts[0] === 'h') && (/^\d+$/.test(parts[parts.length - 1]) || /^[a-zA-Z0-9_-]{11}$/.test(parts[parts.length - 1]))) ||
|
||||
(parts.length >= 2 && parts[0] === 'favs' && (/^\d+$/.test(parts[parts.length - 1]) || /^[a-zA-Z0-9_-]{11}$/.test(parts[parts.length - 1])))
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
@@ -2417,8 +2470,9 @@ window.cancelAnimFrame = (function () {
|
||||
window.applyBackgroundOpacitySettings(null, false);
|
||||
}
|
||||
window._bgModeAutoSwitch = true;
|
||||
const targetModeBtn = document.querySelector((typeof isCurrentItemAudio === 'function' && isCurrentItemAudio()) ? '#bg-mode-btn-audio' : '#bg-mode-btn-standard');
|
||||
if (targetModeBtn) targetModeBtn.click();
|
||||
if (typeof window.setBgTunerMode === 'function') {
|
||||
window.setBgTunerMode((typeof isCurrentItemAudio === 'function' && isCurrentItemAudio()) ? 'audio' : 'standard');
|
||||
}
|
||||
window._bgModeAutoSwitch = false;
|
||||
if (window.destroyBackgroundInstance) {
|
||||
window.destroyBackgroundInstance();
|
||||
@@ -2450,8 +2504,9 @@ window.cancelAnimFrame = (function () {
|
||||
window.applyBackgroundOpacitySettings(null, false);
|
||||
}
|
||||
window._bgModeAutoSwitch = true;
|
||||
const targetModeBtn = document.querySelector((typeof isCurrentItemAudio === 'function' && isCurrentItemAudio()) ? '#bg-mode-btn-audio' : '#bg-mode-btn-standard');
|
||||
if (targetModeBtn) targetModeBtn.click();
|
||||
if (typeof window.setBgTunerMode === 'function') {
|
||||
window.setBgTunerMode((typeof isCurrentItemAudio === 'function' && isCurrentItemAudio()) ? 'audio' : 'standard');
|
||||
}
|
||||
window._bgModeAutoSwitch = false;
|
||||
if (window.destroyBackgroundInstance) {
|
||||
window.destroyBackgroundInstance();
|
||||
@@ -5131,15 +5186,15 @@ window.cancelAnimFrame = (function () {
|
||||
window._bgModeAutoSwitch = true;
|
||||
const inOnara = (typeof isCurrentlyInOnara === 'function') ? isCurrentlyInOnara() : document.body.classList.contains('onara-modal-open');
|
||||
if (inOnara) {
|
||||
const btn = document.querySelector('#bg-mode-btn-onara');
|
||||
if (btn) btn.click();
|
||||
else if (typeof window.applyBackgroundOpacitySettings === 'function') {
|
||||
if (typeof window.setBgTunerMode === 'function') {
|
||||
window.setBgTunerMode('onara');
|
||||
} else if (typeof window.applyBackgroundOpacitySettings === 'function') {
|
||||
window.applyBackgroundOpacitySettings(window.onaraTuning, true);
|
||||
}
|
||||
} else if (elem.tagName === 'AUDIO') {
|
||||
const btn = document.querySelector('#bg-mode-btn-audio');
|
||||
if (btn) btn.click();
|
||||
else if (typeof window.applyBackgroundOpacitySettings === 'function') {
|
||||
if (typeof window.setBgTunerMode === 'function') {
|
||||
window.setBgTunerMode('audio');
|
||||
} else if (typeof window.applyBackgroundOpacitySettings === 'function') {
|
||||
window.applyBackgroundOpacitySettings(window.audioBgTuning, 'audio');
|
||||
}
|
||||
} else {
|
||||
@@ -5149,9 +5204,9 @@ window.cancelAnimFrame = (function () {
|
||||
mediaAmbientState.bottom = [25, 25, 35];
|
||||
mediaAmbientState.targetBottom = [25, 25, 35];
|
||||
mediaAmbientState.hasSampled = false;
|
||||
const btn = document.querySelector('#bg-mode-btn-standard');
|
||||
if (btn) btn.click();
|
||||
else if (typeof window.applyBackgroundOpacitySettings === 'function') {
|
||||
if (typeof window.setBgTunerMode === 'function') {
|
||||
window.setBgTunerMode('standard');
|
||||
} else if (typeof window.applyBackgroundOpacitySettings === 'function') {
|
||||
window.applyBackgroundOpacitySettings(window.audioVisualizerTuning, false);
|
||||
}
|
||||
}
|
||||
@@ -7504,28 +7559,34 @@ window.cancelAnimFrame = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
panel.querySelector('#bg-mode-btn-standard')?.addEventListener('click', () => {
|
||||
activeBgTunerMode = 'standard';
|
||||
window.setBgTunerMode = (mode) => {
|
||||
activeBgTunerMode = mode;
|
||||
syncBgSlidersDisplay();
|
||||
applyBackgroundOpacitySettings(window.audioVisualizerTuning, false);
|
||||
if (mode === 'onara') {
|
||||
applyBackgroundOpacitySettings(window.onaraTuning, true);
|
||||
} else if (mode === 'audio') {
|
||||
applyBackgroundOpacitySettings(window.audioBgTuning, 'audio');
|
||||
} else {
|
||||
applyBackgroundOpacitySettings(window.audioVisualizerTuning, false);
|
||||
}
|
||||
};
|
||||
|
||||
panel.querySelector('#bg-mode-btn-standard')?.addEventListener('click', () => {
|
||||
window.setBgTunerMode('standard');
|
||||
if (!window._bgModeAutoSwitch && typeof window.flashMessage === 'function') {
|
||||
window.flashMessage('Tuning Standard Background', 1500, 'info');
|
||||
}
|
||||
});
|
||||
|
||||
panel.querySelector('#bg-mode-btn-onara')?.addEventListener('click', () => {
|
||||
activeBgTunerMode = 'onara';
|
||||
syncBgSlidersDisplay();
|
||||
applyBackgroundOpacitySettings(window.onaraTuning, true);
|
||||
window.setBgTunerMode('onara');
|
||||
if (!window._bgModeAutoSwitch && typeof window.flashMessage === 'function') {
|
||||
window.flashMessage('Tuning Onara Mode Background', 1500, 'info');
|
||||
}
|
||||
});
|
||||
|
||||
panel.querySelector('#bg-mode-btn-audio')?.addEventListener('click', () => {
|
||||
activeBgTunerMode = 'audio';
|
||||
syncBgSlidersDisplay();
|
||||
applyBackgroundOpacitySettings(window.audioBgTuning, 'audio');
|
||||
window.setBgTunerMode('audio');
|
||||
if (!window._bgModeAutoSwitch && typeof window.flashMessage === 'function') {
|
||||
window.flashMessage('Tuning Audio Background', 1500, 'info');
|
||||
}
|
||||
@@ -11019,7 +11080,10 @@ window.cancelAnimFrame = (function () {
|
||||
// Immediately restore scrollability and hide modals
|
||||
if (window.resetGlobalScrollState) window.resetGlobalScrollState();
|
||||
if (window.hideAllModals) window.hideAllModals();
|
||||
if (window.closeOnaraModal) window.closeOnaraModal({ skipHistory: true });
|
||||
const willNavigateToItem = typeof isItemPath === 'function' ? isItemPath(url) : false;
|
||||
if (!isOnaraActive() || !willNavigateToItem) {
|
||||
if (window.closeOnaraModal) window.closeOnaraModal({ skipHistory: true });
|
||||
}
|
||||
|
||||
isNavigating = true;
|
||||
|
||||
@@ -14615,6 +14679,7 @@ window.cancelAnimFrame = (function () {
|
||||
const btns = document.querySelectorAll('#nav-search-btn');
|
||||
|
||||
let debounceTimer = null;
|
||||
let closeTimer = null;
|
||||
let highlightIdx = -1;
|
||||
|
||||
const doSearch = () => {
|
||||
@@ -14753,6 +14818,10 @@ window.cancelAnimFrame = (function () {
|
||||
fetch(`/api/v2/tags/suggest?q=${encodeURIComponent(q)}`).then(r => r.json()).catch(() => ({ success: false })),
|
||||
fetch(`/api/v2/items/suggest?q=${encodeURIComponent(q)}`).then(r => r.json()).catch(() => ({ success: false }))
|
||||
]);
|
||||
if (!overlay.classList.contains('visible') || !input.value.trim()) {
|
||||
suggestions.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
const tagSuggestions = (tagRes.success && tagRes.suggestions) ? tagRes.suggestions.slice(0, 6) : [];
|
||||
const titleSuggestions = (titleRes.success && titleRes.suggestions) ? titleRes.suggestions.slice(0, 4) : [];
|
||||
if (tagSuggestions.length || titleSuggestions.length) {
|
||||
@@ -14797,18 +14866,42 @@ window.cancelAnimFrame = (function () {
|
||||
const savedStrict = localStorage.getItem('search_strict') === 'true';
|
||||
if (strict) strict.checked = savedStrict;
|
||||
|
||||
const clearSearchState = () => {
|
||||
if (debounceTimer) {
|
||||
clearTimeout(debounceTimer);
|
||||
debounceTimer = null;
|
||||
}
|
||||
input.value = '';
|
||||
suggestions.innerHTML = '';
|
||||
suggestions.style.display = 'none';
|
||||
highlightIdx = -1;
|
||||
};
|
||||
|
||||
const toggleSearch = (show) => {
|
||||
if (show) {
|
||||
if (closeTimer) {
|
||||
clearTimeout(closeTimer);
|
||||
closeTimer = null;
|
||||
}
|
||||
clearSearchState();
|
||||
overlay.style.display = 'flex';
|
||||
// Force reflow
|
||||
overlay.offsetHeight;
|
||||
overlay.classList.add('visible');
|
||||
if (window.innerWidth > 768) input.focus();
|
||||
input.focus();
|
||||
} else {
|
||||
if (closeTimer) {
|
||||
clearTimeout(closeTimer);
|
||||
}
|
||||
overlay.classList.remove('visible');
|
||||
suggestions.style.display = 'none';
|
||||
setTimeout(() => {
|
||||
if (document.activeElement === input) {
|
||||
input.blur();
|
||||
}
|
||||
closeTimer = setTimeout(() => {
|
||||
overlay.style.display = 'none';
|
||||
clearSearchState();
|
||||
closeTimer = null;
|
||||
}, 200);
|
||||
}
|
||||
};
|
||||
@@ -14883,7 +14976,7 @@ window.cancelAnimFrame = (function () {
|
||||
toggleSearch(false);
|
||||
}
|
||||
// "k" to open
|
||||
if (e.key === 'k' && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && !overlay.classList.contains('visible')) {
|
||||
if ((e.key === 'k' || e.key === 'K') && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && !e.target.isContentEditable && !overlay.classList.contains('visible')) {
|
||||
e.preventDefault();
|
||||
toggleSearch(true);
|
||||
}
|
||||
@@ -14935,8 +15028,8 @@ window.cancelAnimFrame = (function () {
|
||||
const titleItems = suggestions.querySelectorAll('.tag-suggestion-item[data-type="title"]');
|
||||
suggestions.style.display = 'none';
|
||||
if (tagItems.length === 0 && titleItems.length > 0) {
|
||||
toggleSearch(false);
|
||||
const q = input.value.trim();
|
||||
toggleSearch(false);
|
||||
const target = `/tag/title:${encodeURIComponent(q)}/`;
|
||||
if (typeof loadPageAjax === 'function') {
|
||||
loadPageAjax(target, true);
|
||||
@@ -18839,11 +18932,14 @@ class NotificationSystem {
|
||||
const ghost = document.createElement('a');
|
||||
ghost.href = `${linkBase}${itemKey}`;
|
||||
ghost.className = 'thumb lazy-thumb filtered-upload-ghost loaded';
|
||||
ghost.dataset.itemId = String(data.id);
|
||||
ghost.dataset.file = data.dest;
|
||||
ghost.dataset.mime = data.mime;
|
||||
ghost.dataset.user = data.display_name || data.username;
|
||||
ghost.dataset.mode = mode;
|
||||
ghost.style.setProperty('--thumb-bg', `url('/t/${data.id}.webp')`);
|
||||
const ghostBg = typeof window.applyThumbCacheBust === 'function' ? window.applyThumbCacheBust(`/t/${data.id}.webp`) : `/t/${data.id}.webp`;
|
||||
ghost.dataset.bg = ghostBg;
|
||||
ghost.style.setProperty('--thumb-bg', `url('${ghostBg}')`);
|
||||
ghost.style.opacity = '0';
|
||||
ghost.style.transform = 'scale(0.9)';
|
||||
ghost.innerHTML = `
|
||||
@@ -18881,19 +18977,37 @@ class NotificationSystem {
|
||||
const nsflId = window.f0ckSession?.nsfl_tag_id || 3;
|
||||
const mode = data.tag_id ? (data.tag_id === 1 ? 'sfw' : (data.tag_id === 2 ? 'nsfw' : (data.tag_id == nsflId ? 'nsfl' : 'null'))) : 'null';
|
||||
|
||||
let baseBg = `/t/${data.id}.webp`;
|
||||
const blurNsfw = localStorage.getItem('blurNsfw') === 'true';
|
||||
const blurNsfl = localStorage.getItem('blurNsfl') === 'true';
|
||||
const blurSfw = localStorage.getItem('blurSfw') === 'true';
|
||||
const blurUntagged = localStorage.getItem('blurUntagged') === 'true';
|
||||
let shouldBlurThis = false;
|
||||
if (mode === 'nsfw') shouldBlurThis = blurNsfw;
|
||||
else if (mode === 'nsfl') shouldBlurThis = blurNsfl;
|
||||
else if (mode === 'sfw') shouldBlurThis = blurSfw;
|
||||
else if (mode === 'null' || !mode) shouldBlurThis = blurUntagged;
|
||||
if (shouldBlurThis) {
|
||||
baseBg = baseBg.replace('.webp', '_blur.webp');
|
||||
}
|
||||
const finalBg = typeof window.applyThumbCacheBust === 'function' ? window.applyThumbCacheBust(baseBg) : baseBg;
|
||||
|
||||
const thumb = document.createElement('a');
|
||||
thumb.href = `${linkBase}${itemKey}`;
|
||||
thumb.className = 'thumb lazy-thumb';
|
||||
thumb.className = 'thumb loaded';
|
||||
thumb.dataset.itemId = String(data.id);
|
||||
thumb.dataset.file = data.dest;
|
||||
thumb.dataset.mime = data.mime;
|
||||
thumb.dataset.user = data.display_name || data.username;
|
||||
thumb.dataset.ext = data.mime.split('/')[1].replace('youtube', 'yt').toUpperCase();
|
||||
thumb.dataset.mode = mode;
|
||||
thumb.dataset.bg = `/t/${data.id}.webp`;
|
||||
thumb.dataset.bg = finalBg;
|
||||
thumb.dataset.size = '1'; // New items start with no contributions → tier 1
|
||||
thumb.style.setProperty('--thumb-bg', `url('/t/${data.id}.webp')`);
|
||||
thumb.classList.add('loaded');
|
||||
thumb.style.setProperty('--thumb-bg', `url('${finalBg}')`);
|
||||
thumb.style.transform = 'scale(0.9)';
|
||||
if (window.loadedThumbs) window.loadedThumbs.add(finalBg);
|
||||
const img = new Image();
|
||||
img.src = finalBg;
|
||||
|
||||
// Build thumb-indicators (matches server-rendered template structure)
|
||||
let indicatorsHtml = '';
|
||||
|
||||
+61
-4
@@ -36,6 +36,8 @@
|
||||
const filterResetBtn = document.getElementById('filter-reset-btn');
|
||||
const filterApplyBtn = document.getElementById('filter-apply-btn');
|
||||
const filterSummary = document.getElementById('filter-active-summary');
|
||||
let filterSummaryText = document.getElementById('filter-active-summary-text');
|
||||
let filterClearBtn = document.getElementById('filter-active-clear');
|
||||
const tagInput = document.getElementById('filter-tag-input');
|
||||
const tagClear = document.getElementById('filter-tag-clear');
|
||||
const tagSuggestEl = document.getElementById('tag-suggestions');
|
||||
@@ -3182,10 +3184,59 @@
|
||||
|
||||
filterResetBtn.addEventListener('click', () => { pending = { mode: defaultMode, mime: scrollerSingleMime || '', order: 'random', tags: [] }; syncPanelUI(); tagInput.value = ''; tagClear.classList.remove('show'); tagSuggestEl.innerHTML = ''; lastSugg = []; renderActiveTags(); });
|
||||
|
||||
function clearActiveFilters() {
|
||||
applied = { mode: defaultMode, mime: scrollerSingleMime || '', order: 'random', tags: [], externalUrl: null };
|
||||
pending = { ...applied, tags: [] };
|
||||
if (externalUrlInput) externalUrlInput.value = '';
|
||||
if (galleryOpen) toggleGallery();
|
||||
if (chanGalleryBtn) chanGalleryBtn.style.display = 'none';
|
||||
if (tagInput) tagInput.value = '';
|
||||
if (tagClear) tagClear.classList.remove('show');
|
||||
if (tagSuggestEl) tagSuggestEl.innerHTML = '';
|
||||
lastSugg = [];
|
||||
renderActiveTags();
|
||||
syncPanelUI();
|
||||
renderPresets();
|
||||
reloadFeed();
|
||||
}
|
||||
|
||||
function setupFilterSummary() {
|
||||
if (!filterSummary) return;
|
||||
if (!filterSummaryText || !filterClearBtn) {
|
||||
if (!filterSummary.querySelector('#filter-active-summary-text')) {
|
||||
const txt = document.createElement('span');
|
||||
txt.id = 'filter-active-summary-text';
|
||||
const btn = document.createElement('button');
|
||||
btn.id = 'filter-active-clear';
|
||||
btn.type = 'button';
|
||||
btn.title = (window.f0ckI18n && window.f0ckI18n.clear_filter) || 'Clear filter';
|
||||
btn.setAttribute('aria-label', (window.f0ckI18n && window.f0ckI18n.clear_filter) || 'Clear filter');
|
||||
btn.innerHTML = '<i class="fa-solid fa-xmark"></i>';
|
||||
filterSummary.innerHTML = '';
|
||||
filterSummary.appendChild(txt);
|
||||
filterSummary.appendChild(btn);
|
||||
}
|
||||
filterSummaryText = document.getElementById('filter-active-summary-text');
|
||||
filterClearBtn = document.getElementById('filter-active-clear');
|
||||
}
|
||||
if (filterClearBtn && !filterClearBtn._hasListener) {
|
||||
filterClearBtn._hasListener = true;
|
||||
filterClearBtn.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
clearActiveFilters();
|
||||
});
|
||||
}
|
||||
}
|
||||
setupFilterSummary();
|
||||
|
||||
function updateFilterSummary() {
|
||||
if (!filterSummary) return;
|
||||
setupFilterSummary();
|
||||
const is4chan = !!applied.externalUrl;
|
||||
const isDef = applied.mode === defaultMode && applied.mime === '' && applied.order === 'random' && applied.tags.length === 0 && !is4chan;
|
||||
filterOpenBtn.classList.toggle('has-filter', !isDef); filterSummary.classList.toggle('show', !isDef);
|
||||
const isDef = applied.mode === defaultMode && applied.mime === (scrollerSingleMime || '') && applied.order === 'random' && applied.tags.length === 0 && !is4chan;
|
||||
if (filterOpenBtn) filterOpenBtn.classList.toggle('has-filter', !isDef);
|
||||
filterSummary.classList.toggle('show', !isDef);
|
||||
if (!isDef) {
|
||||
// Check if current filters exactly match a saved preset
|
||||
const tagsKey = t => [...t].map(s => s.toLowerCase()).sort().join(',');
|
||||
@@ -3195,8 +3246,9 @@
|
||||
p.order === applied.order &&
|
||||
tagsKey(p.tags) === tagsKey(applied.tags)
|
||||
);
|
||||
let summaryText = '';
|
||||
if (matchedPreset && !is4chan) {
|
||||
filterSummary.textContent = matchedPreset.name;
|
||||
summaryText = matchedPreset.name;
|
||||
} else {
|
||||
const parts = [];
|
||||
if (is4chan) parts.push('4chan');
|
||||
@@ -3204,7 +3256,12 @@
|
||||
if (applied.mime) parts.push(applied.mime);
|
||||
if (applied.order !== 'random') parts.push(applied.order);
|
||||
parts.push(...applied.tags);
|
||||
filterSummary.textContent = parts.join(' · ');
|
||||
summaryText = parts.join(' · ');
|
||||
}
|
||||
if (filterSummaryText) {
|
||||
filterSummaryText.textContent = summaryText;
|
||||
} else {
|
||||
filterSummary.textContent = summaryText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3004,6 +3004,22 @@ window.initUploadForm = (selector) => {
|
||||
|
||||
// URL uploads: redirect or stay based on user preference (pending/async jobs skip redirect)
|
||||
if (!lastData?.pending && !lastData?.manual_approval) {
|
||||
if (lastData?.itemid && window.NotificationSystemInstance && typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
||||
window.NotificationSystemInstance.handleNewItem({
|
||||
id: lastData.itemid,
|
||||
dest: lastData.dest,
|
||||
mime: lastData.mime,
|
||||
username: lastData.username || window.f0ckSession?.user || '',
|
||||
display_name: lastData.display_name || window.f0ckSession?.display_name || null,
|
||||
tag_id: lastData.tag_id ?? 0,
|
||||
is_oc: !!lastData.is_oc,
|
||||
slug: lastData.slug,
|
||||
visibility: lastData.visibility || 0,
|
||||
is_album: !!lastData.is_album,
|
||||
album_count: lastData.album_count || 0
|
||||
});
|
||||
}
|
||||
|
||||
const shouldRedirectToItem = redirectCheckbox
|
||||
? redirectCheckbox.checked
|
||||
: (localStorage.getItem('upload_redirect_to_item') !== 'false');
|
||||
|
||||
@@ -891,6 +891,7 @@ class v0ck {
|
||||
|
||||
// Close menu/panel when clicking outside
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!e.isTrusted) return;
|
||||
const isFlashYankUI = e.target.closest('#flash-yank-ui');
|
||||
const isInsidePlayer = player.contains(e.target);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user