X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/c0bdbebdd5c4760320f82cb7471a3113082b2a90..8ed7634d0fa3b7154275c14477b361b358ee783f:/word/finder.js diff --git a/word/finder.js b/word/finder.js index b1db273..5dcc9e3 100644 --- a/word/finder.js +++ b/word/finder.js @@ -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,22 +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].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(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() {}