X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/fa43237a3eb6cc3f399fd3b2584ef6152a07dc1e..44e2112d30af2edb254091897a4e4b34d91785fc:/word/quiz.js diff --git a/word/quiz.js b/word/quiz.js index 5283628..4470394 100644 --- a/word/quiz.js +++ b/word/quiz.js @@ -6,6 +6,15 @@ Array.prototype.shuffle = function () { 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; @@ -74,6 +83,15 @@ class Words { get label() { return row[0].replace(/\/.*/, ''); // primary form }, + get html() { + let aliases = this.title.split('/'); + let html = aliases.shift(); + html = html.replace(/\((.+)\)/, '$1'); + for (let alias of aliases) { + html += ` (${alias})`; + } + return html; + }, level: row[1], imgid: row[2], thumb(size = 32) { @@ -111,7 +129,7 @@ class WordQuiz { 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+$/)) {