git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
keyboard/altgr/unigraph: diagonals and dots in rightmost columns
[sheet.git]
/
word
/
quiz.js
diff --git
a/word/quiz.js
b/word/quiz.js
index 5283628407e51fbe84ff5cc54ea02f1c7e88c623..9436f7a85675d5b87aa72d18a5660cee02cba295 100644
(file)
--- a/
word/quiz.js
+++ b/
word/quiz.js
@@
-6,6
+6,15
@@
Array.prototype.shuffle = function () {
return this;
};
return this;
};
+function hashparams() {
+ const encodedhash = window.location.href.split('#').slice(1) || '';
+ if (encodedhash.length == 1) {
+ // location.hash is not encoded in firefox
+ return decodeURIComponent(encodedhash).split('#');
+ }
+ return encodedhash;
+}
+
class Words {
constructor(data, root = undefined) {
this.data = data;
class Words {
constructor(data, root = undefined) {
this.data = data;
@@
-74,6
+83,15
@@
class Words {
get label() {
return row[0].replace(/\/.*/, ''); // primary form
},
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) {
level: row[1],
imgid: row[2],
thumb(size = 32) {
@@
-111,7
+129,7
@@
class WordQuiz {
return selection;
}
return selection;
}
- configure(params =
window.location.hash.split('#'
)) {
+ configure(params =
hashparams(
)) {
const opts = new Map(params.map(arg => arg.split(/[:=](.*)/)));
for (let [query, val] of opts) {
if (query.match(/^\d+$/)) {
const opts = new Map(params.map(arg => arg.split(/[:=](.*)/)));
for (let [query, val] of opts) {
if (query.match(/^\d+$/)) {
@@
-120,6
+138,9
@@
class WordQuiz {
else if (query === 'level') {
this.preset.level = parseInt(val);
}
else if (query === 'level') {
this.preset.level = parseInt(val);
}
+ else if (query === 'debug') {
+ this.preset.debug = true;
+ }
else {
this.preset[query] = val;
}
else {
this.preset[query] = val;
}