diff --git a/server/views/index.pug b/server/views/index.pug index 625e081..3c4c8dc 100644 --- a/server/views/index.pug +++ b/server/views/index.pug @@ -221,6 +221,9 @@ block content } function handleRepoAction(repoName, hasSetWebhook, currentPage, perPage) { + // Save the scroll position + const scrollY = window.scrollY; + fetch(`/webhook/config?repo=${repoName}&hassetwebhook=${hasSetWebhook}&page=${currentPage}&per_page=${perPage}`) .then(response => response.json()) .then(data => { @@ -239,6 +242,9 @@ block content //- } //- repoCard.setAttribute('webhook-repo-status', data.hasSetWebhook); + // Store the scroll position in localStorage + localStorage.setItem("scrollY", scrollY); + // Refresh the page window.location.href = `/?page=${currentPage}&per_page=${perPage}`; document.getElementById('repoModal').style.display = 'none'; } @@ -262,3 +268,11 @@ block content modal.style.display = 'none'; } }); + + document.addEventListener('DOMContentLoaded', (event) => { + const scrollY = localStorage.getItem('scrollY'); + if (scrollY) { + window.scrollTo(0, parseInt(scrollY, 10)); + localStorage.removeItem('scrollY'); // Clean up after restoring + } + }); \ No newline at end of file