From: Mischa POSLAWSKY Date: Tue, 17 Jan 2023 18:21:55 +0000 (+0100) Subject: word/quiz: decode uri-encoded location hash X-Git-Tag: v1.14~46 X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/ed90e77238fc96d33adc9135b4b4af6223154ae1 word/quiz: decode uri-encoded location hash Separator # not recognised in correct browsers like chrome. --- diff --git a/word/quiz.js b/word/quiz.js index 5283628..dce5f7a 100644 --- a/word/quiz.js +++ b/word/quiz.js @@ -6,6 +6,12 @@ Array.prototype.shuffle = function () { return this; }; +function hashparams() { + // location.hash is not encoded in firefox + const encodedhash = (window.location.href.split('#'))[1] || ''; + return decodeURIComponent(encodedhash).split('#'); +} + class Words { constructor(data, root = undefined) { this.data = data; @@ -111,7 +117,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+$/)) {