+ if (this.preset.level !== undefined) {
+ selection.filter(id => json[id][1] <= this.preset.level);
+ }
+
+ if (this.preset.distinct) {
+ // remove referenced categories
+ selection.filter(id => !selection.get(id).subs.length);
+ }
+
+ return selection;
+ }
+
+ configure(params = hashparams()) {
+ 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 if (query === 'debug') {
+ this.preset.debug = true;
+ }
+ else {
+ this.preset[query] = val;
+ }