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) {
innerHTML: html,
});
}
- let levelpart = level <= 1 && this.cats[ref] && this.cats[ref].length > 1;
- if (levelpart) {
+ if (level <= 1 && subs.length >= 2) {
put(worditem, '.large');
}
- if (this.cats[ref]) {
+ 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() {}