latin: unistrokes circles matched separately
[sheet.git] / word / finder.js
1 class WordFinder extends WordQuiz {
2         add(parentitem, rows) {
3                 const catitem = put(parentitem, 'ul');
4                 rows.forEach(ref => {
5                         const [title, level, imgid] = this.data[ref];
6                         const worditem = put(catitem, 'li');
7                         const figitem = put(worditem, 'figure');
8                         if (imgid) {
9                                 put(figitem, 'img[src=$]', `/data/word/32/${imgid}.jpg`);
10                         }
11                         if (title) {
12                                 let html = title.replace(/\/(.*)/, ' <small>($1)</small>');
13                                 put(figitem, 'figcaption', {
14                                         innerHTML: html,
15                                 });
16                         }
17                         let levelpart = level <= 1 && this.cats[ref] && this.cats[ref].length > 1;
18                         if (levelpart) {
19                                 put(worditem, '.large');
20                         }
21                         if (this.cats[ref]) {
22                                 // delve into subcategory
23                                 put(worditem, '.parent');
24                                 this.add(worditem, this.cats[ref].sort((a, b) => {
25                                         const [worda, wordb] = [this.data[a], this.data[b]];
26                                         return (worda[1] % 1) - (wordb[1] % 1)
27                                                 || worda[0].localeCompare(wordb[0]);
28                                 }));
29                         }
30                 });
31         }
32
33         setup() {
34                 this.gallery = document.getElementById('gallery');
35                 put(this.gallery, '-p', 'Under construction.');
36                 this.add(this.gallery, this.preset.cat ? [this.preset.cat] : this.cats[null]);
37         }
38
39         stop() {}
40 };