From af99f42e425d0fd4e22d92458d5dc2049429d684 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 30 Dec 2021 05:57:50 +0100 Subject: [PATCH] word/quiz: common base class for all subpages Only json loading from multichoice to start with. --- word/memory.js | 6 ++---- word/memory.plp | 2 ++ word/multichoice.js | 12 ++++-------- word/multichoice.plp | 3 ++- word/quiz.js | 17 +++++++++++++++++ 5 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 word/quiz.js diff --git a/word/memory.js b/word/memory.js index c3adfd4..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')) { @@ -37,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 = []; @@ -55,5 +55,3 @@ class WordMemory { }); } }; - -new WordMemory(); diff --git a/word/memory.plp b/word/memory.plp index 8aa952c..d0364e4 100644 --- a/word/memory.plp +++ b/word/memory.plp @@ -3,6 +3,7 @@ Html({ raw => <<'EOT', +