From b247a99a38053ce731ed3d193045f21479c06218 Mon Sep 17 00:00:00 2001 From: Ward Cunningham Date: Sun, 3 Nov 2024 15:11:37 -0800 Subject: [PATCH 1/3] fix decoding of arrow key events --- lib/legacy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/legacy.js b/lib/legacy.js index e82353c..87fb2ff 100644 --- a/lib/legacy.js +++ b/lib/legacy.js @@ -51,10 +51,9 @@ $(function() { const LEFTARROW = 37; const RIGHTARROW = 39; - const dirs = {LEFTARROW:-1, RIGHTARROW:+1}; $(document).on("keydown", function(event) { - const direction = dirs[event.which]; + const direction = event.which == LEFTARROW ? -1 : event.which == RIGHTARROW ? 1 : null if (direction && !$(event.target).is(":input")) { const pages = $('.page'); const newIndex = pages.index($('.active')) + direction; From 3711d36f7d1afe8971aa96eef05f68579085789a Mon Sep 17 00:00:00 2001 From: Ward Cunningham Date: Tue, 5 Nov 2024 08:01:00 -0800 Subject: [PATCH 2/3] early exit return restored to fix local storage bug --- lib/pageHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pageHandler.js b/lib/pageHandler.js index 4e8b125..c13607d 100644 --- a/lib/pageHandler.js +++ b/lib/pageHandler.js @@ -106,7 +106,7 @@ pageHandler.get = function({whenGotten,whenNotGotten,pageInformation} ) { let localPage; if (localPage = pageFromLocalStorage(pageInformation.slug)) { if (pageInformation.rev) { localPage = revision.create(pageInformation.rev, localPage); } - whenGotten(newPage( localPage, 'local' )); + return whenGotten(newPage( localPage, 'local' )); } } From 9e84b6557b7a4c173c886f54bd09afbdd6f9ac3f Mon Sep 17 00:00:00 2001 From: Ward Cunningham Date: Tue, 5 Nov 2024 09:05:45 -0800 Subject: [PATCH 3/3] code early exit as separate return --- lib/pageHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pageHandler.js b/lib/pageHandler.js index c13607d..172ddb9 100644 --- a/lib/pageHandler.js +++ b/lib/pageHandler.js @@ -106,7 +106,8 @@ pageHandler.get = function({whenGotten,whenNotGotten,pageInformation} ) { let localPage; if (localPage = pageFromLocalStorage(pageInformation.slug)) { if (pageInformation.rev) { localPage = revision.create(pageInformation.rev, localPage); } - return whenGotten(newPage( localPage, 'local' )); + whenGotten(newPage( localPage, 'local' )); + return; } }