git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
word/quiz: common base class for all subpages
[sheet.git]
/
word
/
memory.js
diff --git
a/word/memory.js
b/word/memory.js
index 0e523a1c7857fa7832abd14d6f180dd7a13ca27a..375b7c185bab825ba6eb63b5ea80862952ac6cf0 100644
(file)
--- 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')) {
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 = [];
// 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;
}
return;
}
@@
-34,7
+37,7
@@
class WordMemory {
.forEach(card => put(card, '!.turn!.bad'));
}
.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 = [];
this.dataurl = '/data/wordpairs.json';
fetch(this.dataurl).then(res => res.json()).then(pairs => {
this.turned = [];
@@
-52,5
+55,3
@@
class WordMemory {
});
}
};
});
}
};
-
-new WordMemory();