diff --git a/static/app.css b/static/app.css index 01e36d8..69fd905 100644 --- a/static/app.css +++ b/static/app.css @@ -198,3 +198,32 @@ footer { padding: 10px; overflow-x: auto; } + + +/* Center the reload control */ +#directory-controls { + text-align: center; + margin-top: 20px; +} + +/* Style the button (remove border, background, etc.) */ +#reload-button { + background: none; + border: none; + cursor: pointer; + padding: 0; +} + +/* Add a rotation animation */ +@keyframes rotate-icon { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(180deg); } +} + +#reload-button svg { + animation: none; +} + +#reload-button svg.rotate { + animation: rotate-icon 0.5s linear; +} \ No newline at end of file diff --git a/static/app.js b/static/app.js index bf23e84..7315586 100644 --- a/static/app.js +++ b/static/app.js @@ -323,6 +323,26 @@ window.addEventListener('popstate', function (event) { }); +function reloadDirectory() { + // Extract the current path from the URL, similar to your initial load code. + let currentSubpath = ''; + if (window.location.pathname.indexOf('/path/') === 0) { + currentSubpath = window.location.pathname.substring(6); // Remove "/path/" + } + loadDirectory(currentSubpath); + + // Get the SVG element (assuming it's a child of the button) + const reloadBtn = document.querySelector('#reload-button svg'); + + // Force reflow to reset the animation + void reloadBtn.offsetWidth; + reloadBtn.classList.add("rotate"); + + // call function after 500 ms to remove the class + setTimeout(() => reloadBtn.classList.remove("rotate"), 500); + +} + if ('mediaSession' in navigator) { // Handler for the play action @@ -369,4 +389,9 @@ document.getElementById('globalAudio').addEventListener('ended', () => { nextLink.click(); } } +}); + +document.addEventListener("DOMContentLoaded", function() { + // Automatically reload every 5 minutes (300,000 milliseconds) + setInterval(reloadDirectory, 300000); }); \ No newline at end of file diff --git a/templates/app.html b/templates/app.html index f2df4d3..b26c7c1 100644 --- a/templates/app.html +++ b/templates/app.html @@ -42,6 +42,15 @@