-setup: () => {
- fetch(quiz.dataurl).then(res => res.json()).then(json => {
- quiz.form = document.getElementById('quiz');
- quiz.words = Object.values(json)
- .sort(() => {return .5 - Math.random()}) // shuffle
- .map(row => row.split(/:/))
- quiz.next();
- });
-},
-};
+ {
+ let cats = new Set();
+ let subcats = rows.map(row => row[3]); // direct parents
+ for (let loop = 0; subcats.length && loop < 20; loop++) {
+ subcats.forEach(cat => cats.add(cat));
+ subcats = subcats.map(row => json[row] && json[row][3]).filter(val => val); // recurse grandparents
+ }
+ rows = rows.filter(row => !cats.has(row[2])); // remove referenced categories
+ }
+ return rows.shuffle();
+ }
+
+ load(dataurl) {
+ this.preset = {};
+ let input;
+ if (input = window.location.hash.match(/\d+/)) {
+ this.preset.cat = input[0];
+ }
+ if (window.location.hash.match(/a/)) {
+ this.preset.level = 3;
+ }
+
+ fetch(dataurl).then(res => res.json()).then(json => {
+ this.words = this.dataselect(json)
+ this.setup();
+ });
+ }