+ return refs;
+ }
+
+ get(id) {
+ if (!this.has(id)) {
+ return;
+ }
+ const p = this;
+ const row = this.data[id];
+ return row && {
+ id: id,
+ title: row[0],
+ get label() {
+ return row[0].replace(/\/.*/, ''); // primary form
+ },
+ get html() {
+ let aliases = this.title.split('/');
+ let html = aliases.shift();
+ html = html.replace(/\((.+)\)/, '<small>$1</small>');
+ for (let alias of aliases) {
+ html += ` <small>(${alias})</small>`;
+ }
+ return html;
+ },
+ level: row[1],
+ imgid: row[2],
+ thumb(size = 32) {
+ return `/data/word/${size}/${row[2]}.jpg`;
+ },
+ get subs() {
+ return p.subs(id).map(e => p.get(e));
+ },
+ };
+ }
+}
+
+class WordQuiz {
+ dataselect(json) {
+ this.data = this.datafilter(json);
+ return [...this.data.random()];