word/quiz: generic page container setup
[sheet.git] / word / quiz.js
index 68c2ee81e69e1b7ccaaa34fa43e463cce76852bd..3243b19ed5c2f52ef019868a32136f253bf41481 100644 (file)
@@ -62,7 +62,7 @@ class WordQuiz {
                return selection;
        }
 
-       configure(params) {
+       configure(params = window.location.hash.split('#')) {
                const opts = new Map(params.map(arg => arg.split(/[:=](.*)/)));
                for (let [query, val] of opts) {
                        if (query.match(/^\d+$/)) {
@@ -78,8 +78,12 @@ class WordQuiz {
                this.preset.dataurl = `/data/wordlist.${this.preset.lang}.json`
        }
 
+       setup() {
+               this.form = document.getElementById('quiz');
+       }
+
        load() {
-               this.configure(window.location.hash.split('#'));
+               this.configure();
                fetch(this.preset.dataurl).then(res => res.json()).then(json => {
                        this.words = this.dataselect(json)
                        this.setup();