From 3f0b6e395941309dd239dcd9102e7297b122f9e6 Mon Sep 17 00:00:00 2001 From: cyfraeviolae Date: Sat, 26 Feb 2022 01:52:45 -0500 Subject: on screen kb --- index.html | 45 ++++++++++++++++++++++++++++++++++++++++++++- static/script.js | 44 +++++++++++++++++++++++++------------------- static/styles.css | 26 ++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index ad76874..ffbe3b3 100644 --- a/index.html +++ b/index.html @@ -23,13 +23,22 @@ line, Roseacrucis will reveal which letters are in the right place 🟩, in the right word but in a different place 🟨, or not in the word at all ⬜.

+

+ For the ransom price of one new line with the same metrical and syllabic structure as today’s secret + line, Roseacrucis will reveal which letters are in the right place 🟩, in the right word but in a different + place 🟨, or not in the word at all ⬜. +

+

+ For the ransom price of one new line with the same metrical and syllabic structure as today’s secret + line, Roseacrucis will reveal which letters are in the right place 🟩, in the right word but in a different + place 🟨, or not in the word at all ⬜. +

Write a line of poetry. Syllables in dark boxes should be stressed.

-
@@ -59,6 +68,40 @@

+
+
+
Q
+
W
+
E
+
R
+
T
+
Y
+
U
+
I
+
O
+
P
+
+
+
A
+
S
+
D
+
F
+
G
+
H
+
J
+
K
+
L
+
+
+
Z
+
X
+
C
+
V
+
B
+
N
+
M
+
+
diff --git a/static/script.js b/static/script.js index 2516256..6a52d3e 100644 --- a/static/script.js +++ b/static/script.js @@ -156,39 +156,42 @@ function winGame(challenge) { document.getElementById('share').value = `I solved the ${date} Prosodyle at cyfraeviolae.org/prosodyle. My first guess was: "${firstguess}".` } -document.addEventListener('keydown', function(e) { - // if (!Array.from(e.target.classList).includes('entrybox')) { - // return; - // } - // 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')) { - return; - } - if (e.target.id == 'share') { - return; - } - e.preventDefault(); - - if (e.key == 'Enter') { +function keyHandler(key) { + if (key == 'Enter') { document.getElementById('check').click() return; } var el = document.querySelector(`[data-offset="${focused}"]`); var offset = parseInt(el.getAttribute('data-offset')) var nextel; - if (e.key == 'Backspace') { + if (key == 'Backspace') { el.innerText = ''; nextel = document.querySelector(`[data-offset="${offset-1}"]`); } else { - el.innerText = e.key.toUpperCase(); + el.innerText = key.toUpperCase(); nextel = document.querySelector(`[data-offset="${offset+1}"]`); } if (nextel) { focus(nextel); unfocus(el); } +} + +document.addEventListener('keydown', function(e) { + // if (!Array.from(e.target.classList).includes('entrybox')) { + // return; + // } + // 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')) { + return; + } + if (e.target.id == 'share') { + return; + } + e.preventDefault(); + keyHandler(e.key) }) document.addEventListener('mousedown', function(e) { @@ -196,6 +199,10 @@ document.addEventListener('mousedown', function(e) { e.preventDefault(); unfocus(document.querySelector(`[data-offset="${focused}"]`)); focus(e.target); + } else if (Array.from(e.target.classList).includes('key')) { + e.preventDefault(); + var k = e.target.innerText + keyHandler(k) } }) @@ -219,7 +226,6 @@ document.getElementById('copy').addEventListener('click', function(e) { function focus(el) { focused = parseInt(el.getAttribute('data-offset')) el.classList.add('focus') - document.getElementById('kb').focus() } function unfocus(el) { diff --git a/static/styles.css b/static/styles.css index 5bd99f1..bf62330 100644 --- a/static/styles.css +++ b/static/styles.css @@ -148,3 +148,29 @@ hr { #share { width: 90%; } + +.keyboard { + border-top: 2px black solid; + padding-top:10px; + padding-bottom:7px; + background-color: #fdf3f3; + position: sticky; + bottom: 0; + text-align: center; + max-width: 40em; + left: 26px; +} +.kbrow { + margin-bottom: 5px; +} +.key { + font-family: Cantarell; + display: inline-block; + height: 35px; + width: 30px; + border-radius: 4px; + border: 1px black solid; + line-height: 33px; + cursor: pointer; + user-select: none; +} -- cgit v1.2.3