From 0ed28de6133115907b9de3353fd12ad59e7511ee Mon Sep 17 00:00:00 2001 From: Joshua Lester Date: Tue, 8 Oct 2024 15:28:44 -0700 Subject: [PATCH 1/2] Ignores going to previous page when at /home --- EssentialCSharp.Web/wwwroot/js/site.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EssentialCSharp.Web/wwwroot/js/site.js b/EssentialCSharp.Web/wwwroot/js/site.js index c76f5c54..c10bd58b 100644 --- a/EssentialCSharp.Web/wwwroot/js/site.js +++ b/EssentialCSharp.Web/wwwroot/js/site.js @@ -152,7 +152,9 @@ const app = createApp({ } function goToPrevious() { - window.location.href = "/" + PREVIOUS_PAGE; + if (!window.location.href.endsWith("/home")) { + window.location.href = "/" + PREVIOUS_PAGE; + } } function goToNext() { window.location.href = "/" + NEXT_PAGE; From ad4f20b4e0b26079cb1a36aea39fe2a2aad2b05a Mon Sep 17 00:00:00 2001 From: Joshua Lester Date: Thu, 10 Oct 2024 07:42:18 -0700 Subject: [PATCH 2/2] Made more generic solution to ignore left/right arrows on invalid pages --- EssentialCSharp.Web/wwwroot/js/site.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/EssentialCSharp.Web/wwwroot/js/site.js b/EssentialCSharp.Web/wwwroot/js/site.js index c10bd58b..7a98e7cc 100644 --- a/EssentialCSharp.Web/wwwroot/js/site.js +++ b/EssentialCSharp.Web/wwwroot/js/site.js @@ -152,12 +152,16 @@ const app = createApp({ } function goToPrevious() { - if (!window.location.href.endsWith("/home")) { - window.location.href = "/" + PREVIOUS_PAGE; + let previousPage = PREVIOUS_PAGE; + if (previousPage !== null) { + window.location.href = "/" + previousPage; } } function goToNext() { - window.location.href = "/" + NEXT_PAGE; + let nextPage = NEXT_PAGE; + if (nextPage !== null) { + window.location.href = "/" + nextPage; + } } document.addEventListener("keydown", (e) => {