X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/e889c7543227d2aeee90553fea9c59524c2cec95..0f3a55ca3cfa02e2446a20dc050d04490b23bb8d:/word/quiz.js diff --git a/word/quiz.js b/word/quiz.js index ef5e0d8..0518fa1 100644 --- a/word/quiz.js +++ b/word/quiz.js @@ -8,7 +8,8 @@ class Quiz { let answers = [word[2], this.words[1][2], this.words[2][2], this.words[3][2]] .sort(() => {return .5 - Math.random()}) // shuffle answers.forEach(suggest => { - let option = put(form, 'li', suggest, {onclick: () => { + let label = suggest.replace(/\/.*/, ''); + let option = put(form, 'li', label, {onclick: () => { if (suggest != word[2]) { // incorrect put(option, '.wrong'); @@ -20,9 +21,8 @@ class Quiz { }); } - constructor() { - this.dataurl = '/data/wordlist.nl.json'; - fetch(this.dataurl).then(res => res.json()).then(json => { + constructor(dataurl) { + fetch(dataurl).then(res => res.json()).then(json => { this.form = document.getElementById('quiz'); this.words = Object.values(json) .sort(() => {return .5 - Math.random()}) // shuffle @@ -31,5 +31,3 @@ class Quiz { }); } }; - -new Quiz();