diff --git a/CHANGELOG.md b/CHANGELOG.md index d6a8a2f..6884622 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Changes 4/14/2025 + +- Fix Gallery View: medium screen devices get 3 max columns and small screen devices 2 max columns. + ## Changes 4/13/2025 v1.1.3 - Decreased header height some more and clickable logo. diff --git a/js/fileListView.js b/js/fileListView.js index 3adfb23..9190df4 100644 --- a/js/fileListView.js +++ b/js/fileListView.js @@ -92,8 +92,8 @@ function toggleAdvancedSearch() { window.imageCache = window.imageCache || {}; function cacheImage(imgElem, key) { - // Save the current src for future renders. - window.imageCache[key] = imgElem.src; + // Save the current src for future renders. + window.imageCache[key] = imgElem.src; } window.cacheImage = cacheImage; @@ -105,28 +105,28 @@ window.cacheImage = cacheImage; */ function searchFiles(searchTerm) { if (!searchTerm) return fileData; - + // Define search keys. let keys = [ - { name: 'name', weight: 0.1 }, - { name: 'uploader', weight: 0.1 }, - { name: 'tags.name', weight: 0.1 } + { name: 'name', weight: 0.1 }, + { name: 'uploader', weight: 0.1 }, + { name: 'tags.name', weight: 0.1 } ]; if (window.advancedSearchEnabled) { - keys.push({ name: 'content', weight: 0.7 }); + keys.push({ name: 'content', weight: 0.7 }); } - + const options = { - keys: keys, - threshold: 0.4, - minMatchCharLength: 2, - ignoreLocation: true + keys: keys, + threshold: 0.4, + minMatchCharLength: 2, + ignoreLocation: true }; - + const fuse = new Fuse(fileData, options); let results = fuse.search(searchTerm); return results.map(result => result.item); - } +} /** * --- VIEW MODE TOGGLE BUTTON & Helpers --- @@ -134,43 +134,43 @@ function searchFiles(searchTerm) { export function createViewToggleButton() { let toggleBtn = document.getElementById("toggleViewBtn"); if (!toggleBtn) { - toggleBtn = document.createElement("button"); - toggleBtn.id = "toggleViewBtn"; - toggleBtn.classList.add("btn", "btn-toggleview"); - - // Set initial icon and tooltip based on current view mode. - if (window.viewMode === "gallery") { - toggleBtn.innerHTML = 'view_list'; - toggleBtn.title = t("switch_to_table_view"); - } else { - toggleBtn.innerHTML = 'view_module'; - toggleBtn.title = t("switch_to_gallery_view"); - } - - // Insert the button before the last button in the header. - const headerButtons = document.querySelector(".header-buttons"); - if (headerButtons && headerButtons.lastElementChild) { - headerButtons.insertBefore(toggleBtn, headerButtons.lastElementChild); - } else if (headerButtons) { - headerButtons.appendChild(toggleBtn); - } + toggleBtn = document.createElement("button"); + toggleBtn.id = "toggleViewBtn"; + toggleBtn.classList.add("btn", "btn-toggleview"); + + // Set initial icon and tooltip based on current view mode. + if (window.viewMode === "gallery") { + toggleBtn.innerHTML = 'view_list'; + toggleBtn.title = t("switch_to_table_view"); + } else { + toggleBtn.innerHTML = 'view_module'; + toggleBtn.title = t("switch_to_gallery_view"); + } + + // Insert the button before the last button in the header. + const headerButtons = document.querySelector(".header-buttons"); + if (headerButtons && headerButtons.lastElementChild) { + headerButtons.insertBefore(toggleBtn, headerButtons.lastElementChild); + } else if (headerButtons) { + headerButtons.appendChild(toggleBtn); + } } - + toggleBtn.onclick = () => { - window.viewMode = window.viewMode === "gallery" ? "table" : "gallery"; - localStorage.setItem("viewMode", window.viewMode); - loadFileList(window.currentFolder); - if (window.viewMode === "gallery") { - toggleBtn.innerHTML = 'view_list'; - toggleBtn.title = t("switch_to_table_view"); - } else { - toggleBtn.innerHTML = 'view_module'; - toggleBtn.title = t("switch_to_gallery_view"); - } + window.viewMode = window.viewMode === "gallery" ? "table" : "gallery"; + localStorage.setItem("viewMode", window.viewMode); + loadFileList(window.currentFolder); + if (window.viewMode === "gallery") { + toggleBtn.innerHTML = 'view_list'; + toggleBtn.title = t("switch_to_table_view"); + } else { + toggleBtn.innerHTML = 'view_module'; + toggleBtn.title = t("switch_to_gallery_view"); + } }; - + return toggleBtn; - } +} export function formatFolderName(folder) { if (folder === "root") return "(Root)"; @@ -283,7 +283,7 @@ export function renderFileTable(folder, container) { // Use Fuse.js search via our helper function. const filteredFiles = searchFiles(searchTerm); - + const totalFiles = filteredFiles.length; const totalPages = Math.ceil(totalFiles / itemsPerPageSetting); if (currentPage > totalPages) { @@ -302,7 +302,7 @@ export function renderFileTable(folder, container) { }); const combinedTopHTML = topControlsHTML; - + let headerHTML = buildFileTableHeader(sortOrder); const startIndex = (currentPage - 1) * itemsPerPageSetting; const endIndex = Math.min(startIndex + itemsPerPageSetting, totalFiles); @@ -392,32 +392,24 @@ export function renderFileTable(folder, container) { bindFileListContextMenu(); } -/** - * Similarly, update renderGalleryView to accept an optional container. - */ // A helper to compute the max image height based on the current column count. function getMaxImageHeight() { - // Use the slider value (default to 3 if undefined). const columns = parseInt(window.galleryColumns || 3, 10); - // Simple scaling: fewer columns yield bigger images. - // For instance, if columns === 6, max-height is 150px, - // and if columns === 1, max-height could be 150 * 6 = 900px. return 150 * (7 - columns); // adjust the multiplier as needed. - } - - export function renderGalleryView(folder, container) { +} + +export function renderGalleryView(folder, container) { const fileListContent = container || document.getElementById("fileList"); const searchTerm = (window.currentSearchTerm || "").toLowerCase(); const filteredFiles = searchFiles(searchTerm); const folderPath = folder === "root" - ? "uploads/" - : "uploads/" + folder.split("/").map(encodeURIComponent).join("/") + "/"; - + ? "uploads/" + : "uploads/" + folder.split("/").map(encodeURIComponent).join("/") + "/"; + // Use the current global column value (default to 3). const numColumns = window.galleryColumns || 3; - + // --- Insert slider controls --- - // Build the slider HTML. const sliderHTML = `
`; - - // Set up the grid container using the slider's value. + + // Set up the grid container using the slider's current value. const gridStyle = `display: grid; grid-template-columns: repeat(${numColumns}, 1fr); gap: 10px; padding: 10px;`; - - // Build the gallery container HTML and include the slider above it. + + // Build the gallery container HTML including the slider. let galleryHTML = sliderHTML; galleryHTML += `