sitemap: prefer https protocol for absolute site references
[sheet.git] / word / quiz.js
index dce5f7a43ace9c973c726432f70d651112cbea69..9436f7a85675d5b87aa72d18a5660cee02cba295 100644 (file)
@@ -7,9 +7,12 @@ Array.prototype.shuffle = function () {
 };
 
 function hashparams() {
-       // location.hash is not encoded in firefox
-       const encodedhash = (window.location.href.split('#'))[1] || '';
-       return decodeURIComponent(encodedhash).split('#');
+       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 {
@@ -80,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(/\((.+)\)/, '<small>$1</small>');
+                               for (let alias of aliases) {
+                                       html += ` <small>(${alias})</small>`;
+                               }
+                               return html;
+                       },
                        level: row[1],
                        imgid: row[2],
                        thumb(size = 32) {
@@ -126,6 +138,9 @@ class WordQuiz {
                        else if (query === 'level') {
                                this.preset.level = parseInt(val);
                        }
+                       else if (query === 'debug') {
+                               this.preset.debug = true;
+                       }
                        else {
                                this.preset[query] = val;
                        }