Cleanup
This commit is contained in:
parent
d24600cbd4
commit
3cab30027a
|
|
@ -90,54 +90,33 @@ async function getMappingForLetter(letter) {
|
|||
}
|
||||
|
||||
async function setNextLetter() {
|
||||
if (currentletterIndex > currentString.length-1) {
|
||||
let letterbox = $("#letterbox");
|
||||
if (currentLetterIndex > currentString.length-1)
|
||||
return;
|
||||
}
|
||||
let prevIndex = currentletterIndex-1;
|
||||
if (prevIndex >= -1) {
|
||||
await unhighlightLetter($("#letterbox").children()[currentletterIndex]);
|
||||
}
|
||||
currentletterIndex++;
|
||||
currentLetter = currentString.charAt(currentletterIndex).toLowerCase();
|
||||
let prevIndex = currentLetterIndex-1;
|
||||
if (prevIndex >= -1)
|
||||
await unhighlightLetter(letterbox.children()[currentLetterIndex]);
|
||||
currentLetterIndex++;
|
||||
currentLetter = currentString.charAt(currentLetterIndex).toLowerCase();
|
||||
currentMapping = mappings[(await getMappingForLetter(currentLetter)).toString()];
|
||||
await highlightLetter($("#letterbox").children()[currentletterIndex]);
|
||||
await highlightLetter(letterbox.children()[currentLetterIndex]);
|
||||
await artseyDraw();
|
||||
}
|
||||
|
||||
let currentletterIndex = -1;
|
||||
let currentLetterIndex = -1;
|
||||
let currentLetter = '';
|
||||
let currentString = "hello world";
|
||||
let currentMapping = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
$(document).ready(async function () {
|
||||
|
||||
$( "body" ).on( "click", function(event) {
|
||||
// $( "#target" ).trigger( "keyup" );
|
||||
console.log(event);
|
||||
} );
|
||||
|
||||
$( "#typing-text" ).on( "keypress", function() {
|
||||
//console.log( "Handler for `keypress` called." );
|
||||
console.log($("#typing-text").text());
|
||||
} );
|
||||
|
||||
$('body').on("keyup", (function(e) {
|
||||
//alert('Handler for .keyup() called.');
|
||||
$('#typing-text').focus();
|
||||
console.log("current letter: " + currentLetter + " typed letter: " + String.fromCharCode(e.which).toLowerCase());
|
||||
|
||||
if (currentLetter === String.fromCharCode(e.which).toLowerCase()) {
|
||||
if (currentLetter === String.fromCharCode(e.which).toLowerCase())
|
||||
setNextLetter();
|
||||
}
|
||||
}));
|
||||
console.log("ready! Here's a demo.");
|
||||
|
||||
await sleep(1000);
|
||||
await setTypingText(currentString);
|
||||
await sleep(500);
|
||||
await setNextLetter();
|
||||
|
||||
// for (let i = 0; i < currentString.length; i++) {
|
||||
// await setNextLetter();
|
||||
// await sleep(1000);
|
||||
// }
|
||||
});
|
||||
Loading…
Reference in New Issue