Implement lesson structure
This commit is contained in:
parent
6f0fe9afad
commit
116a71fd24
|
|
@ -34,6 +34,12 @@ let mappings = {
|
|||
'key_exclamation': [0, 0, 1, 0, 0, 0, 1, 0]
|
||||
}
|
||||
|
||||
let lessons = [
|
||||
"hello world!",
|
||||
"artseyio is the best layout ever!",
|
||||
"what's up all?"
|
||||
];
|
||||
|
||||
async function artseyDraw() {
|
||||
let keys = $('.keyboard-key');
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
|
|
@ -93,6 +99,24 @@ async function setNextLetter() {
|
|||
let letterbox = $("#letterbox");
|
||||
if (currentLetterIndex > currentString.length-1)
|
||||
return;
|
||||
if (currentLetterIndex === currentString.length-1) {
|
||||
console.log("end of string");
|
||||
await hideKeyboard();
|
||||
await sleep(1000);
|
||||
await setTypingText("Well done! Let's try another.")
|
||||
await sleep(1000);
|
||||
if (++currentLessonIndex > lessons.length-1)
|
||||
currentLessonIndex = 0;
|
||||
currentString = lessons[++currentLessonIndex];
|
||||
await setTypingText(currentString);
|
||||
currentLetterIndex = -1;
|
||||
await artseyReset();
|
||||
await showKeyboard();
|
||||
// currentLetterIndex = -1;
|
||||
// await artseyReset();
|
||||
// await setTypingText(lessons['2']);
|
||||
// currentLetter = currentString.charAt(0);
|
||||
}
|
||||
let prevIndex = currentLetterIndex-1;
|
||||
if (prevIndex >= -1 || currentLetterIndex === 0)
|
||||
await unHighlightLetter(letterbox.children()[currentLetterIndex]);
|
||||
|
|
@ -110,17 +134,31 @@ async function showWrongInput() {
|
|||
})
|
||||
}
|
||||
|
||||
async function showKeyboard() {
|
||||
$("#keyboard").animate({opacity: 1.0}, 1000, function () {
|
||||
console.log("keyboard visible!");
|
||||
});
|
||||
}
|
||||
|
||||
async function hideKeyboard() {
|
||||
$("#keyboard").animate({opacity: 0}, 1000, function () {
|
||||
console.log("keyboard hidden!");
|
||||
});
|
||||
}
|
||||
|
||||
let currentLetterIndex = -1;
|
||||
let currentLessonIndex = 0;
|
||||
let currentLetter = '';
|
||||
let currentString = "hello world";
|
||||
let currentString = lessons[0];
|
||||
let currentMapping = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
$(document).ready(async function () {
|
||||
$("#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())
|
||||
let keycode = (e.key ? e.key : e.which)
|
||||
console.log("current letter: " + currentLetter + " typed letter: " + String.fromCharCode(keycode.toLowerCase().charCodeAt(0)));
|
||||
if (currentLetter === String.fromCharCode(keycode.toLowerCase().charCodeAt(0)))
|
||||
await setNextLetter();
|
||||
else
|
||||
await showWrongInput();
|
||||
|
|
@ -130,8 +168,6 @@ $(document).ready(async function () {
|
|||
await setTypingText(currentString);
|
||||
await sleep(500);
|
||||
await setNextLetter();
|
||||
$("#keyboard").animate({opacity: 1.0}, 1000, function () {
|
||||
console.log("keyboard visible!");
|
||||
});
|
||||
await showKeyboard();
|
||||
})
|
||||
});
|
||||
Loading…
Reference in New Issue