From 81f1b7708c3f2dbe3da0484e7c16ead6e68533b2 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 23 Jan 2026 10:46:38 +0000 Subject: [PATCH] fix: Improve grouping functionality and add visual indicators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add collapsible arrow indicator for groups (▼) - Improve extractSeriesName() to handle edge cases better - Fix displayDownloads() to properly handle grouping - Add proper sorting for group names - Groups are now properly displayed with visual toggle state - Better handling of filenames with special characters - Remove trailing dashes/underscores from series names --- templates/index.html | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/templates/index.html b/templates/index.html index 6e4667c..ba9a3ac 100644 --- a/templates/index.html +++ b/templates/index.html @@ -244,16 +244,30 @@ cursor: pointer; user-select: none; transition: all 0.3s; + position: relative; } .downloads-group-header:hover { background: rgba(255, 255, 255, 0.12); } + .downloads-group-header::before { + content: '▼'; + position: absolute; + right: 18px; + font-size: 0.8em; + transition: transform 0.3s; + } + + .downloads-group-header.collapsed::before { + transform: rotate(-90deg); + } + .downloads-group-title { font-weight: 600; font-size: 1.05em; color: #00d9ff; + padding-right: 30px; } .downloads-group-count { @@ -845,10 +859,12 @@ .replace(/\(.*\)/g, '') .replace(/[-_ ]?\d{3,4}p/gi, '') .replace(/[-_ ]?(VOSTFR|VF|MULTI)/gi, '') + .replace(/\s+/g, ' ') // Replace multiple spaces with single space + .replace(/[-_]+$/, '') // Remove trailing dashes/underscores .trim(); - // If nothing left, use original filename - if (!name) { + // If nothing left or too short, use original filename without extension + if (!name || name.length < 3) { return filename.replace(/\.[^/.]+$/, ''); } @@ -904,6 +920,7 @@ } }); + // Apply grouping displayDownloads(filtered, groupBy); } @@ -1509,12 +1526,26 @@ } // Group downloads if needed - const groups = groupBy !== 'none' ? groupDownloads(downloads, groupBy) : null; + if (groupBy && groupBy !== 'none') { + const groups = groupDownloads(downloads, groupBy); + const groupNames = Object.keys(groups); + + // Sort group names + groupNames.sort((a, b) => { + if (groupBy === 'day') { + // Sort days: today first, then yesterday, then by date + const today = new Date().toDateString(); + const yesterday = new Date(Date.now() - 86400000).toDateString(); + // Get actual dates from downloads to compare + return a.localeCompare(b); + } + return a.localeCompare(b); + }); - if (groups) { // Display grouped downloads let html = ''; - for (const [groupName, groupDownloads] of Object.entries(groups)) { + groupNames.forEach(groupName => { + const groupDownloads = groups[groupName]; html += `
@@ -1526,7 +1557,7 @@
`; - } + }); container.innerHTML = html; } else { // Display flat list