word/quiz: apply subsequent hash parameters
[sheet.git] / word / quiz.js
index 5283628407e51fbe84ff5cc54ea02f1c7e88c623..5498809f67ceb2bbb0ce9a7d31ab8205217b6277 100644 (file)
@@ -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;
@@ -111,7 +120,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+$/)) {