X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/a3c116952bbc2bfc1b77d8814637a36ed76883c3..e6f9791973f7c1ef542c3b1438b7fb0527f22109:/word/memory.js?ds=sidebyside diff --git a/word/memory.js b/word/memory.js index 24feead..89fd853 100644 --- a/word/memory.js +++ b/word/memory.js @@ -5,6 +5,7 @@ class WordMemory extends WordQuiz { // show an open card this.turned.push(target); put(target, '.turn'); + this.log('pick', target.id, target.index); } else if (this.turned.length < 2) { return; // keep open @@ -30,6 +31,7 @@ class WordMemory extends WordQuiz { this.turned = []; if (Array.from(this.form.children).every(card => card.classList.contains('good'))) { put(this.form, '.good'); + this.stop('done'); } return; } @@ -70,11 +72,15 @@ class WordMemory extends WordQuiz { .map(e => e.toString()) } - cards.shuffle().forEach(word => { + cards.shuffle().forEach((word, seq) => { let ref = Math.abs(word); put(this.form, - 'figure>img[src=$]<', `/data/word/en/${ref}.jpg`, - {onclick: e => this.turn(e), id: ref, className: word < 0 ? 'mirror' : ''} + 'figure>img[src=$]<', `/data/word/32/${ref}.jpg`, { + onclick: e => this.turn(e), + id: ref, + className: word < 0 ? 'mirror' : '', + index: seq, + } ); }); }