diff --git a/eslint.config.mjs b/eslint.config.mjs index cd9ee3251..fddda6ca1 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -53,7 +53,6 @@ const jsConfig = defineConfig([ generateForever: 'readonly', showContributors: 'readonly', opts: 'writable', - monitorOption: 'readonly', sortUIElements: 'readonly', all_gallery_buttons: 'readonly', selected_gallery_button: 'readonly', diff --git a/javascript/gallery.js b/javascript/gallery.js index 2707e7418..54131386f 100644 --- a/javascript/gallery.js +++ b/javascript/gallery.js @@ -21,7 +21,7 @@ const el = { search: undefined, status: undefined, btnSend: undefined, - clearCache: undefined, + clearCacheFolder: undefined, }; const SUPPORTED_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'tiff', 'jp2', 'jxl', 'gif', 'mp4', 'mkv', 'avi', 'mjpeg', 'mpg', 'avr']; @@ -1022,30 +1022,39 @@ async function thumbCacheCleanup(folder, imgCount, controller, force = false) { }); } -function addCacheClearButton() { // Don't use async - const div = document.createElement('div'); - div.style.cssText = 'margin-top: 1.5rem; margin-bottom: 0.5rem;'; - const btn = document.createElement('button'); - btn.style.cssText = 'margin: auto; display: block;'; - btn.innerText = 'Clear Folder Thumbnails (double click/tap)'; - btn.addEventListener('dblclick', () => { - if (!currentGalleryFolder) return; - const controller = resetController('Clearing thumbnails'); - galleryHashes.clear(); - galleryProgressBar.clear(); - resetGallerySelection(); - el.files.innerHTML = ''; - thumbCacheCleanup(currentGalleryFolder, 0, controller, true); - }); - div.append(btn); - el.files.insertAdjacentElement('afterend', div); - el.clearCache = div; +function clearGalleryFolderCache(evt) { + evt.preventDefault(); + evt.stopPropagation(); + if (!currentGalleryFolder) return; + el.clearCacheFolder.style.color = 'var(--color-green)'; + setTimeout(() => { + el.clearCacheFolder.style.color = 'var(--color-blue)'; + }, 1000); + const controller = resetController('Clearing thumbnails'); + galleryHashes.clear(); + galleryProgressBar.clear(); + resetGallerySelection(); + el.files.innerHTML = ''; + thumbCacheCleanup(currentGalleryFolder, 0, controller, true); } -async function updateGalleryAdvDisplay(newval, oldval = undefined) { - if (el.clearCache) { - el.clearCache.style.display = newval ? 'block' : 'none'; +function addCacheClearLabel() { // Don't use async + const setting = document.querySelector('#setting_browser_cache'); + if (setting) { + const div = document.createElement('div'); + div.style.marginBlock = '0.75rem'; + + const span = document.createElement('span'); + span.style.cssText = 'font-weight:bold; text-decoration:underline; cursor:pointer; color:var(--color-blue); user-select: none;'; + span.innerText = '