if (this.preset.cat !== undefined) {
ids.clear();
- let children = [this.preset.cat];
+ let children = this.preset.cat;
for (let loop = 0; children.length && loop < 20; loop++) {
for (let child of children) ids.add(child.toString());
children = children.map(cat => json[cat][3]).filter(is => is).flat()
}
}
- if (this.preset.image) {
+ if (this.preset.images) {
ids = ids.filter(id => json[id][2]);
}
if (this.preset.level !== undefined) {
return selection;
}
- load(dataurl) {
- this.preset = {};
- let input;
- if (input = window.location.hash.match(/\d+/)) {
- this.preset.cat = parseInt(input[0]);
- }
- if (window.location.hash.match(/a/)) {
- this.preset.level = 3;
+ configure(params) {
+ const opts = new Map(params.map(arg => arg.split(/[:=](.*)/)));
+ for (let [query, val] of opts) {
+ if (query.match(/^\d+$/)) {
+ this.preset.cat = [parseInt(query)];
+ }
+ else if (query === 'level') {
+ this.preset.level = parseInt(val);
+ }
+ else {
+ this.preset[query] = val;
+ }
}
+ }
+ load(dataurl) {
+ this.configure(window.location.hash.split('#'));
fetch(dataurl).then(res => res.json()).then(json => {
this.words = this.dataselect(json)
this.setup();
}
constructor(dataurl) {
+ this.preset = {images: true};
this.load(dataurl);
this.history = [];
window.onbeforeunload = e => {