dkl9 commited on 2025-332 19:47:06
Showing 3 changed files, with 19 additions and 6 deletions.
| ... | ... |
@@ -7,6 +7,7 @@ |
| 7 | 7 |
<link rel="icon" type="image/png" href="/favicon.png"> |
| 8 | 8 |
<style> |
| 9 | 9 |
body { font-family: sans-serif; margin: 0; width: 100%; }
|
| 10 |
+ input:not(:checked) + #mobile { display: none; }
|
|
| 10 | 11 |
#mobile td { min-width: min(16vw, 5rem); height: min(16vw, 5rem); text-align: center; }
|
| 11 | 12 |
#plot { border: 1px solid grey; flex-shrink: 0; width: min(90vw, 25em); height: min(90vw, 25em); flex-shrink: 0; }
|
| 12 | 13 |
#grid { border-collapse: separate; border-spacing: 3px 12px; margin-top: 10px; }
|
| ... | ... |
@@ -47,7 +48,7 @@ |
| 47 | 48 |
<li>l for natural log</li> |
| 48 | 49 |
<li>+, -, *, / for basic operations</li> |
| 49 | 50 |
</ul> |
| 50 |
- <p>Or use the grid of buttons. |
|
| 51 |
+ <p>Or use the on-screen keyboard. |
|
| 51 | 52 |
Inputs to - and / are still taken in the usual order, so "2 x -" is two minus <var>x</var>.</p> |
| 52 | 53 |
<p>For example, write 1 / (sin² <var>x</var>) as "1 x s q /", or ln(2) <var>e</var><sup><var>x</var></sup> as "2 l x e *".</p> |
| 53 | 54 |
<p>Your answer will be coloured as feedback. |
| ... | ... |
@@ -35,7 +35,7 @@ switch (host) {
|
| 35 | 35 |
const container = document.getElementsByClassName("container")[0];
|
| 36 | 36 |
const message = document.getElementById("message");
|
| 37 | 37 |
const boxes = {grey: "⬜️", yellow: "🟨", green: "🟩"};
|
| 38 |
-const congrats = ["Incredible", "Amazing", "Great", "Nice", "You got it", "Whew"]; |
|
| 38 |
+const congrats = ["Incredible", "Great", "Nice", "Whew"]; |
|
| 39 | 39 |
const gotitButton = document.getElementById("gotit");
|
| 40 | 40 |
|
| 41 | 41 |
if (localStorage.getItem("gotit") === "true") hideInstructions(gotitButton);
|
| ... | ... |
@@ -1,12 +1,11 @@ |
| 1 | 1 |
const keyToToken = { x:"x", 1:"1", 2:"2", q:"^2", c:"^3", s:"sin", e:"exp", l:"ln", "+":"+", "-":"-", "*":"*", "/":"/" };
|
| 2 |
-const maxGuesses = 6; |
|
| 2 |
+const maxGuesses = 4; |
|
| 3 | 3 |
const mobile = /Mobi|Android/i.test(navigator.userAgent); |
| 4 | 4 |
const buttonKeys = [["x", "1", "2", "q"], ["c", "s", "e", "l"], ["+", "-", "*", "/"]]; |
| 5 | 5 |
const grid = document.getElementById("grid");
|
| 6 | 6 |
|
| 7 |
-if (mobile) {
|
|
| 7 |
+function makeKeyboard() {
|
|
| 8 | 8 |
const ib = document.createElement("table");
|
| 9 |
- ib.id = "mobile"; |
|
| 10 | 9 |
for (let i = 0; i < 3; i++) {
|
| 11 | 10 |
const r = document.createElement("tr");
|
| 12 | 11 |
for (let j = 0; j < 4; j++) {
|
| ... | ... |
@@ -42,7 +41,7 @@ if (mobile) {
|
| 42 | 41 |
sc.colSpan = buttonKeys[0].length / 2; |
| 43 | 42 |
lr.append(sc); |
| 44 | 43 |
ib.append(lr); |
| 45 |
- grid.after(ib); |
|
| 44 |
+ return ib; |
|
| 46 | 45 |
} |
| 47 | 46 |
|
| 48 | 47 |
function makeButton(label, size, handler) {
|
| ... | ... |
@@ -95,3 +94,16 @@ document.addEventListener("keyup", e => {
|
| 95 | 94 |
} |
| 96 | 95 |
} |
| 97 | 96 |
}); |
| 97 |
+ |
|
| 98 |
+const inputButtons = makeKeyboard(); |
|
| 99 |
+inputButtons.id = "mobile"; |
|
| 100 |
+grid.after(inputButtons); |
|
| 101 |
+if (!mobile) {
|
|
| 102 |
+ const toggleLabel = document.createElement("label");
|
|
| 103 |
+ toggleLabel.textContent = "Show on-screen keyboard"; |
|
| 104 |
+ toggleLabel.htmlFor = "tosk"; |
|
| 105 |
+ const toggleCheck = document.createElement("input");
|
|
| 106 |
+ toggleCheck.id = "tosk"; |
|
| 107 |
+ toggleCheck.type = "checkbox"; |
|
| 108 |
+ inputButtons.before(toggleLabel, toggleCheck); |
|
| 109 |
+} |
|
| 98 | 110 |