git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
charset: legacy encodings petscii, atascii, msx, zx-spectrum
[sheet.git]
/
word
/
quiz.js
diff --git
a/word/quiz.js
b/word/quiz.js
index e2e8cb6adc412ebeab12aa1e5bc09cd790601f81..bb12a832c73b170e496dc09e25e6fb88aa0c8849 100644
(file)
--- a/
word/quiz.js
+++ b/
word/quiz.js
@@
-44,13
+44,35
@@
class WordQuiz {
load(dataurl) {
this.preset = {};
load(dataurl) {
this.preset = {};
+ let input;
+ if (input = window.location.hash.match(/\d+/)) {
+ this.preset.cat = input[0];
+ }
+ if (window.location.hash.match(/a/)) {
+ this.preset.level = 3;
+ }
+
fetch(dataurl).then(res => res.json()).then(json => {
this.words = this.dataselect(json)
this.setup();
});
}
fetch(dataurl).then(res => res.json()).then(json => {
this.words = this.dataselect(json)
this.setup();
});
}
+ 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);
constructor(dataurl) {
this.load(dataurl);
+ this.history = [];
+ window.onbeforeunload = e => {
+ this.stop('abort');
+ };
}
}
}
}