From d7683c7f82ff87171bf17192866f8a6a47185b14 Mon Sep 17 00:00:00 2001 From: cyfraeviolae Date: Sat, 26 Feb 2022 02:09:17 -0500 Subject: arrows --- index.html | 5 ++++- static/poems.js | 52 ++++++++++++++++++++++++++-------------------------- static/script.js | 6 +++++- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index ebd1e1d..a32675b 100644 --- a/index.html +++ b/index.html @@ -70,6 +70,7 @@
I
O
P
+
A
@@ -83,6 +84,7 @@
L
+
Z
Z
X
C
@@ -90,7 +92,8 @@
B
N
M
-
+
+
diff --git a/static/poems.js b/static/poems.js index fd5d0bd..89e8701 100644 --- a/static/poems.js +++ b/static/poems.js @@ -1,30 +1,4 @@ var challenges = [ - { - "line": [["In", "/fin", "ite"], ["/wrath"], ["and"], ["/in", "fin", "/ite"], ["des", "/pair"]], - "title": "Book IV", - "collection": "Paradise Lost", - "author": "John Milton", - "meter": "iambic pentameter", - "ctx": `Me miserable! which way shall I flie -Infinite wrauth, and infinite despaire? -Which way I flie is Hell; my self am Hell; -And in the lowest deep a lower deep -Still threatning to devour me opens wide, -To which the Hell I suffer seems a Heav'n.`, - "link": "https://milton.host.dartmouth.edu/reading_room/pl/book_4/text.shtml", - }, - { - "line": [["For"], ["the"], ["/An", "gel"], ["of"], ["/Death"], ["spread"], ["his"], ["/wings"], ["on"], ["the"], ["/blast"]], - "title": "The Destruction of Sennacherib", - "collection": "Hebrew Melodies", - "author": "Lord Byron", - "meter": "anapestic tetrameter", - "ctx": `For the Angel of Death spread his wings on the blast, -And breathed in the face of the foe as he passed; -And the eyes of the sleepers waxed deadly and chill, -And their hearts but once heaved, and for ever grew still!`, - "link": "https://www.poetryfoundation.org/poems/43827/the-destruction-of-sennacherib", - }, { "line": [["A"], ["/pre", "sence"], ["/that"], ["dis", "/turbs"], ["me"], ["/with"], ["the"], ["/joy"]], "title": "Lines written a few miles above Tintern Abbey", @@ -43,4 +17,30 @@ All thinking things, all objects of all thought, And rolls through all things.`, "link": "https://www.gutenberg.org/files/9622/9622-h/9622-h.htm#poem23", }, + { + "line": [["For"], ["the"], ["/An", "gel"], ["of"], ["/Death"], ["spread"], ["his"], ["/wings"], ["on"], ["the"], ["/blast"]], + "title": "The Destruction of Sennacherib", + "collection": "Hebrew Melodies", + "author": "Lord Byron", + "meter": "anapestic tetrameter", + "ctx": `For the Angel of Death spread his wings on the blast, +And breathed in the face of the foe as he passed; +And the eyes of the sleepers waxed deadly and chill, +And their hearts but once heaved, and for ever grew still!`, + "link": "https://www.poetryfoundation.org/poems/43827/the-destruction-of-sennacherib", + }, + { + "line": [["In", "/fin", "ite"], ["/wrath"], ["and"], ["/in", "fin", "/ite"], ["des", "/pair"]], + "title": "Book IV", + "collection": "Paradise Lost", + "author": "John Milton", + "meter": "iambic pentameter", + "ctx": `Me miserable! which way shall I flie +Infinite wrauth, and infinite despaire? +Which way I flie is Hell; my self am Hell; +And in the lowest deep a lower deep +Still threatning to devour me opens wide, +To which the Hell I suffer seems a Heav'n.`, + "link": "https://milton.host.dartmouth.edu/reading_room/pl/book_4/text.shtml", + }, ] diff --git a/static/script.js b/static/script.js index 9692f36..7585efa 100644 --- a/static/script.js +++ b/static/script.js @@ -167,6 +167,10 @@ function keyHandler(key) { if (key == 'Backspace') { el.innerText = ''; nextel = document.querySelector(`[data-offset="${offset-1}"]`); + } else if (key == 'ArrowLeft') { + nextel = document.querySelector(`[data-offset="${offset-1}"]`); + } else if (key == 'ArrowRight') { + nextel = document.querySelector(`[data-offset="${offset+1}"]`); } else { el.innerText = key.toUpperCase(); nextel = document.querySelector(`[data-offset="${offset+1}"]`); @@ -184,7 +188,7 @@ document.addEventListener('keydown', function(e) { // if (e.ctrlKey || e.altKey || (e.key.length != 1 && e.key != 'Backspace')) { // return; // } - if (e.ctrlKey || e.altKey || (!"ABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(e.key.toUpperCase()) && e.key != 'Backspace' && e.key != 'Enter')) { + if (e.ctrlKey || e.altKey || (!"ABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(e.key.toUpperCase()) && e.key != 'Backspace' && e.key != 'Enter' && e.key != 'ArrowLeft' && e.key != 'ArrowRight')) { return; } if (e.target.id == 'share') { -- cgit v1.2.3