this.preset[query] = val;
}
}
+ this.preset.dataurl = `/data/wordlist.${this.preset.lang}.json`
}
- load(dataurl) {
+ load() {
this.configure(window.location.hash.split('#'));
- fetch(dataurl).then(res => res.json()).then(json => {
+ fetch(this.preset.dataurl).then(res => res.json()).then(json => {
this.words = this.dataselect(json)
this.setup();
});
fetch('/word/report', {method: 'POST', body: JSON.stringify(this.history)});
}
- constructor(dataurl) {
- this.preset = {images: true};
- this.load(dataurl);
+ constructor() {
+ this.preset = {images: true, lang: 'en'};
+ this.load();
this.history = [];
window.onbeforeunload = e => {
this.stop('abort');
};
window.onhashchange = e => {
- this.load(dataurl);
+ this.load();
};
}
}