word: reload page to apply changed location hash
[sheet.git] / word / finder.js
index 606f0334432b5d3f3a48ed0b0f3b51f3f62a20d9..5dcc9e3de93f079521c4be441f0345795ce99c78 100644 (file)
@@ -1,8 +1,7 @@
 class WordFinder extends WordQuiz {
-       add(parentitem, rows) {
-               const catitem = put(parentitem, 'ul');
+       add(catitem, rows) {
                rows.forEach(ref => {
-                       const [title, level, imgid] = this.data[ref];
+                       const [title, level, imgid, subs] = this.data[ref];
                        const worditem = put(catitem, 'li');
                        const figitem = put(worditem, 'figure');
                        if (imgid) {
@@ -14,18 +13,24 @@ class WordFinder extends WordQuiz {
                                        innerHTML: html,
                                });
                        }
-                       if (this.cats[ref]) {
+                       if (level <= 1 && subs.length >= 2) {
+                               put(worditem, '.large');
+                       }
+                       if (subs.length) {
                                // delve into subcategory
                                put(worditem, '.parent');
-                               this.add(worditem, this.cats[ref]);
+                               this.add(put(worditem, 'ul'), subs);
                        }
                });
        }
 
        setup() {
                this.gallery = document.getElementById('gallery');
-               put(this.gallery, '-p', 'Under construction.');
-               this.add(this.gallery, this.preset.cat ? [this.preset.cat] : this.cats[null]);
+               this.gallery.innerHTML = '';
+               put(this.gallery, 'p', 'Under construction.');
+               for (let cat of this.preset.cat ? [this.preset.cat] : this.data[''][3]) {
+                       this.add(put(this.gallery, 'ul.gallery'), [cat]);
+               }
        }
 
        stop() {}