switch title based on the page

This commit is contained in:
Karl 2025-06-30 13:16:45 +01:00
parent 96deba17de
commit eeb82a9a3a

View File

@ -198,7 +198,7 @@
<a href="/" class="button-link home-button">Home</a> <a href="/" class="button-link home-button">Home</a>
<button class="button-link favourites-button" id="favourites-button" onclick="toggleFavouritesView()">Show Favourites</button> <button class="button-link favourites-button" id="favourites-button" onclick="toggleFavouritesView()">Show Favourites</button>
<h1>Image Archive</h1> <h1 id="page-title">Image Archive</h1>
<!-- Empty gallery container; images will be loaded incrementally --> <!-- Empty gallery container; images will be loaded incrementally -->
<div class="gallery" id="gallery"></div> <div class="gallery" id="gallery"></div>
@ -215,11 +215,11 @@
<!-- Pass image filenames from Flask to JS --> <!-- Pass image filenames from Flask to JS -->
<script> <script>
let allImages = [ let allImages = JSON.parse(`[
{% for image in images %} {% for image in images %}
{ filename: "{{ image.filename }}", favourited: {{ 'true' if image.favourited else 'false' }} }, { "filename": "{{ image.filename }}", "favourited": {{ 'true' if image.favourited else 'false' }} }{% if not loop.last %},{% endif %}
{% endfor %} {% endfor %}
]; ]`);
</script> </script>
<script> <script>
@ -263,12 +263,15 @@
function toggleFavouritesView() { function toggleFavouritesView() {
showingFavourites = !showingFavourites; showingFavourites = !showingFavourites;
const button = document.getElementById('favourites-button'); const button = document.getElementById('favourites-button');
const pageTitle = document.getElementById('page-title');
if (showingFavourites) { if (showingFavourites) {
filteredImages = allImages.filter(img => img.favourited); filteredImages = allImages.filter(img => img.favourited);
button.textContent = 'Show All'; button.textContent = 'Show All';
pageTitle.textContent = 'Favourites';
} else { } else {
filteredImages = allImages; filteredImages = allImages;
button.textContent = 'Show Favourites'; button.textContent = 'Show Favourites';
pageTitle.textContent = 'Image Archive';
} }
renderGallery(); renderGallery();
} }