blob: 72fcb1c5de61130e483cf91e5395d46618fdf16f (
plain) (
tree)
|
|
let initialized = false;
let current = null;
let revealed = false;
let examples = [];
function add_example(example) {
console.log("add example");
examples.push(example);
if (!initialized) {
display_example(0);
$(document).keydown(function (e) {
if (e.keyCode === 32) {
spacebar();
}
})
initialized = true;
}
}
function display_example(i) {
if (i < examples.length) {
$("#gen_ex_cnt").text(`Example ${i}`);
$("#gen_ex_display").html(examples[i].furi);
$("#gen_ex_en").html(examples[i].en);
$("#gen_ex_words").html(examples[i].vocab);
$("#gen_section").addClass("gen_hidden");
current = i;
revealed = false;
} else {
$("#gen_ex_display").text("done");
$("#gen_ex_en").html(`<a onclick="display_example(0);">redo</a>`);
$("#gen_ex_words").text("");
}
}
function spacebar() {
if (revealed) {
console.log("Next item");
display_example(current + 1);
} else {
console.log("Revealing item");
$("#gen_section").removeClass("gen_hidden");
revealed = true;
}
}
|