X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/819787ff54335a68b34b7d9729f6d7e28870d8ac..af99f42e425d0fd4e22d92458d5dc2049429d684:/word/memory.js diff --git a/word/memory.js b/word/memory.js index 0e523a1..375b7c1 100644 --- a/word/memory.js +++ b/word/memory.js @@ -1,4 +1,4 @@ -class WordMemory { +class WordMemory extends WordQuiz { turn(click) { let target = click.currentTarget; if (!target.classList.contains('turn')) { @@ -26,6 +26,9 @@ class WordMemory { // lock both as correct this.turned.forEach(card => put(card, '.good![onclick]')); this.turned = []; + if (Array.from(this.form.children).every(card => card.classList.contains('good'))) { + put(this.form, '.good'); + } return; } @@ -34,7 +37,7 @@ class WordMemory { .forEach(card => put(card, '!.turn!.bad')); } - constructor() { + load(dataurl) { this.dataurl = '/data/wordpairs.json'; fetch(this.dataurl).then(res => res.json()).then(pairs => { this.turned = []; @@ -52,5 +55,3 @@ class WordMemory { }); } }; - -new WordMemory();