word: category references (recursive selection)
[sheet.git] / word / finder.js
index b1db273415ae27e51f7c40026c014673fd115543..ea1781d16ad3d5ee528d7b027a79ee62a0a8d648 100644 (file)
@@ -2,7 +2,7 @@ class WordFinder extends WordQuiz {
        add(parentitem, rows) {
                const catitem = put(parentitem, 'ul');
                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,14 +14,13 @@ 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].sort((a, b) => {
-                                       const [worda, wordb] = [this.data[a], this.data[b]];
-                                       return (worda[1] % 1) - (wordb[1] % 1)
-                                               || worda[0].localeCompare(wordb[0]);
-                               }));
+                               this.add(worditem, subs);
                        }
                });
        }
@@ -29,7 +28,7 @@ class WordFinder extends WordQuiz {
        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.add(this.gallery, this.preset.cat ? [this.preset.cat] : this.data[''][3]);
        }
 
        stop() {}