word/quiz: category selection from location hash
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 30 Dec 2021 07:14:29 +0000 (08:14 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 7 Feb 2022 17:42:33 +0000 (18:42 +0100)
word/quiz.js

index e2e8cb6adc412ebeab12aa1e5bc09cd790601f81..187aea7e76d72aa2aa3410e8117679cf1e7822f2 100644 (file)
@@ -44,6 +44,14 @@ class WordQuiz {
 
        load(dataurl) {
                this.preset = {};
+               let input;
+               if (input = window.location.hash.match(/\d+/)) {
+                       this.preset.cat = input[0];
+               }
+               if (window.location.hash.match(/a/)) {
+                       this.preset.level = 2;
+               }
+
                fetch(dataurl).then(res => res.json()).then(json => {
                        this.words = this.dataselect(json)
                        this.setup();