From f4744db60ac05178fa5ee554526cd9db4c19b671 Mon Sep 17 00:00:00 2001 From: Zach Graham Date: Fri, 4 Aug 2023 23:01:34 -0500 Subject: [PATCH] Add start button and cleanup --- css/artsey-tutor.css | 7 +++++++ index.html | 24 ++++++------------------ js/artsey-tutor.js | 28 +++++++++++++++++----------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/css/artsey-tutor.css b/css/artsey-tutor.css index befcc4a..64fbd82 100644 --- a/css/artsey-tutor.css +++ b/css/artsey-tutor.css @@ -62,6 +62,7 @@ body { padding: 12px; margin: 0 auto; background-color: slategray; + visibility: collapse; } .keyboard-key { @@ -138,4 +139,10 @@ body { #typing-text { visibility:hidden; position: absolute; +} + +#startButton { + width: 200px; + font-size: 36px; + background-color: steelblue; } \ No newline at end of file diff --git a/index.html b/index.html index 3e8eddc..6807769 100644 --- a/index.html +++ b/index.html @@ -24,21 +24,9 @@ @@ -49,8 +37,8 @@
+
-
@@ -68,8 +56,8 @@ - + diff --git a/js/artsey-tutor.js b/js/artsey-tutor.js index 1794a4b..83eb4fe 100644 --- a/js/artsey-tutor.js +++ b/js/artsey-tutor.js @@ -67,7 +67,7 @@ async function highlightLetter(letterDiv) { $(letterDiv).addClass("letterbox-letter-hl"); } -async function unhighlightLetter(letterDiv) { +async function unHighlightLetter(letterDiv) { $(letterDiv).removeClass("letterbox-letter-hl"); $(letterDiv).addClass("letterbox-letter"); } @@ -95,7 +95,7 @@ async function setNextLetter() { return; let prevIndex = currentLetterIndex-1; if (prevIndex >= -1) - await unhighlightLetter(letterbox.children()[currentLetterIndex]); + await unHighlightLetter(letterbox.children()[currentLetterIndex]); currentLetterIndex++; currentLetter = currentString.charAt(currentLetterIndex).toLowerCase(); currentMapping = mappings[(await getMappingForLetter(currentLetter)).toString()]; @@ -109,14 +109,20 @@ let currentString = "hello world"; let currentMapping = [0, 0, 0, 0, 0, 0, 0, 0]; $(document).ready(async function () { - $('body').on("keyup", (function(e) { - console.log("current letter: " + currentLetter + " typed letter: " + String.fromCharCode(e.which).toLowerCase()); - if (currentLetter === String.fromCharCode(e.which).toLowerCase()) - setNextLetter(); - })); + $("#startButton").on("click", async function () { + $('#startButton').hide(); + $('body').on("keyup", (async function(e) { + console.log("current letter: " + currentLetter + " typed letter: " + String.fromCharCode(e.which).toLowerCase()); + if (currentLetter === String.fromCharCode(e.which).toLowerCase()) + await setNextLetter(); + })); - await sleep(1000); - await setTypingText(currentString); - await sleep(500); - await setNextLetter(); + await sleep(1000); + await setTypingText(currentString); + await sleep(500); + await setNextLetter(); + $("#keyboard").css({opacity: 0, visibility: "visible"}).animate({opacity: 100}, 200, function () { + console.log("keyboard visible!"); + }); + }) }); \ No newline at end of file