From 35796e92fcfd0350a6c74820a4be2d3584d9c205 Mon Sep 17 00:00:00 2001 From: Ben McMath Date: Mon, 2 Dec 2024 10:24:07 -0500 Subject: [PATCH] Adding support for list view and links to tinfoil.media for more details --- app/static/style.css | 9 +++++ app/templates/index.html | 85 +++++++++++++++++++++++++++++++++------- 2 files changed, 80 insertions(+), 14 deletions(-) diff --git a/app/static/style.css b/app/static/style.css index 6252a67..a674d37 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -44,6 +44,15 @@ color: white; } +.game-link { + font-size: 1em; + margin-right: 5px; +} + +.game-link img { + height: 15px; +} + p.game-description { margin-bottom: 0; font-size: 0.875rem; diff --git a/app/templates/index.html b/app/templates/index.html index f5afbe8..88face3 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -75,7 +75,7 @@ class="bi bi-card-heading"> - @@ -145,6 +145,8 @@ } else if (currentView === 'icon') { renderIconView(); adjustIconSizes(); + } else if (currentView === 'list') { + renderListView(); } // Set slider to show 3 columns by default @@ -188,13 +190,24 @@ const typeBadge = $('').text(game.type); tagsContainer.append(typeBadge); + // link to tinfoil + const tinfoilLink = $(''); + tagsContainer.append(tinfoilLink); + if (game.has_latest_version !== undefined) { - const versionBadge = $('').addClass(`text-bg-${game.has_latest_version ? 'success' : 'warning'}`).html(``); + const versionBadge = $(''). + addClass(`text-bg-${game.has_latest_version ? 'success' : 'warning'}`). + prop('title', game.has_latest_version ? 'Latest Version' : 'Missing Latest Update'). + html(``); tagsContainer.append(versionBadge); } if (game.has_all_dlcs !== undefined) { - const dlcBadge = $('').addClass(`text-bg-${game.has_all_dlcs ? 'success' : 'warning'}`).html(''); + const dlcBadge = $(''). + addClass(`text-bg-${game.has_all_dlcs ? 'success' : 'warning'}`). + prop('title', game.has_all_dlcs ? 'Has all DLC' : 'Missing DLC'). + html(''); tagsContainer.append(dlcBadge); } @@ -229,6 +242,59 @@ updatePaginationControls(baseGames.length) } + function renderListView() { + // Render icon view logic... + const gameGrid = $('#gameGrid'); + gameGrid.empty(); // Clear existing games + // Get games for the current page + start = (currentPage - 1) * itemsPerPage + end = start + itemsPerPage + baseGames = filteredGames.filter(game => game.type === 'BASE'); + paginatedGames = baseGames.slice(start, end); + + paginatedGames.forEach(game => { + const container = $('
'); + const image = $('
'+game.name+'
'); + const title = $('
' + + (game.title_id_name || game.name) + + '
'); + const tagsContainer = $('
'); + + const typeBadge = $('').text(game.type); + tagsContainer.append(typeBadge); + + // link to tinfoil + const tinfoilLink = $(''); + tagsContainer.append(tinfoilLink); + + + if (game.has_latest_version !== undefined) { + const versionBadge = $(''). + addClass(`text-bg-${game.has_latest_version ? 'success' : 'warning'}`). + prop('title', game.has_latest_version ? 'Latest Version' : 'Missing Latest Update'). + html(``); + tagsContainer.append(versionBadge); + } + + if (game.has_all_dlcs !== undefined) { + const dlcBadge = $(''). + addClass(`text-bg-${game.has_all_dlcs ? 'success' : 'warning'}`). + prop('title', game.has_all_dlcs ? 'Has all DLC' : 'Missing DLC'). + html(''); + tagsContainer.append(dlcBadge); + } + + gameGrid.append(container.append(image, title, tagsContainer)); + }); + + // Adjust icon sizes based on the slider value + adjustIconSizes(cardSize); + // Update pagination + updatePaginationControls(baseGames.length); + + } + function getColumnsForCardSize(size) { switch (size) { case 1: return 1; // 2 columns @@ -338,12 +404,8 @@ $('.view-toggle-btn').click(function () { $('.view-toggle-btn').removeClass("active"); $(this).addClass("active"); - const view = $(this).data('view'); - if (view === 'card') { - currentView = 'card'; - } else if (view === 'icon') { - currentView = 'icon'; - } + currentView = $(this).data('view'); + renderGames(games); }); @@ -483,11 +545,6 @@ } - // $('#btnApplyFilters').on('click', function () { - // updateFilter(); - // applyFilters(); - // }); - {% endblock %} \ No newline at end of file