unicode: one set of barb arrows from unicode 7.0
[sheet.git] / word / quiz.js
index 187aea7e76d72aa2aa3410e8117679cf1e7822f2..bb12a832c73b170e496dc09e25e6fb88aa0c8849 100644 (file)
@@ -49,7 +49,7 @@ class WordQuiz {
                        this.preset.cat = input[0];
                }
                if (window.location.hash.match(/a/)) {
-                       this.preset.level = 2;
+                       this.preset.level = 3;
                }
 
                fetch(dataurl).then(res => res.json()).then(json => {
@@ -58,7 +58,21 @@ class WordQuiz {
                });
        }
 
+       log(...args) {
+               this.history.push([new Date().toISOString(), ...args]);
+       }
+
+       stop(...args) {
+               this.log(...args);
+               window.onbeforeunload = null;
+               fetch('/word/report', {method: 'POST', body: JSON.stringify(this.history)});
+       }
+
        constructor(dataurl) {
                this.load(dataurl);
+               this.history = [];
+               window.onbeforeunload = e => {
+                       this.stop('abort');
+               };
        }
 }