lang => $lang,
});
say '<h1>Words</h1>';
- say '<section id="gallery"></section>';
+ say '<section id="quiz"></section>';
say "<script>new Word\u$name()</script>";
}
exit;
}
setup() {
- this.gallery = document.getElementById('gallery');
- this.gallery.innerHTML = '';
- put(this.gallery, 'p', 'Under construction.');
+ super.setup();
+ this.form.innerHTML = '';
+ put(this.form, 'p', 'Under construction.');
for (let cat of this.preset.cat || this.data[''][3]) {
- this.add(put(this.gallery, 'ul.gallery'), [cat]);
+ this.add(put(this.form, 'ul.gallery'), [cat]);
}
}
}
load() {
+ this.configure();
if (this.preset.pairs) {
this.dataurl = '/data/wordpairs.json';
fetch(this.dataurl).then(res => res.json()).then(pairs => {
}
setup() {
+ super.setup();
this.turned = [];
- this.form = document.getElementById('quiz');
+ this.form.innerHTML = '';
+ this.form.className = '';
let cards;
if (this.words) {
}
setup() {
- this.form = document.getElementById('quiz');
+ super.setup();
this.next();
}
};
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+$/)) {
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();
}
setup() {
- this.form = document.getElementById('quiz');
+ super.setup();
+ this.form.innerHTML = '';
this.question = put(this.form, 'figure');
this.words.splice(9)