keyboard/altgr/index: move ctrl rows to distinct inventory mode
[sheet.git] / word / memory.js
index dfbb8a65b2b4dcdc22995701b26229a33de6757f..b539b2da4776d3831660a1d8cc4ddca82fd7111a 100644 (file)
@@ -41,22 +41,25 @@ class WordMemory extends WordQuiz {
                .forEach(card => put(card, '!.turn!.bad'));
        }
 
-       load(dataurl) {
-               if (dataurl) {
-                       super.load(dataurl);
-               }
-               else {
+       load() {
+               this.configure();
+               if (this.preset.pairs) {
                        this.dataurl = '/data/wordpairs.json';
                        fetch(this.dataurl).then(res => res.json()).then(pairs => {
                                this.pairs = pairs;
                                this.setup();
                        });
                }
+               else {
+                       super.load();
+               }
        }
 
        setup() {
+               super.setup();
                this.turned = [];
-               this.form = document.getElementById('quiz');
+               this.form.innerHTML = '';
+               this.form.className = '';
 
                let cards;
                if (this.words) {
@@ -66,7 +69,7 @@ class WordMemory extends WordQuiz {
                        let cols = Math.round(Math.sqrt(count) * aspect**.5);
                        count = cols * Math.ceil(count / cols);
                        this.form.style['grid-template-columns'] = `repeat(${cols}, 1fr)`;
-                       cards = this.words.splice(0, count>>1).map(row => row[2]);
+                       cards = this.words.splice(0, count>>1).map(row => row.imgid);
                        cards.push(...cards.map(val => -val));
                }
                else {