word: reload page to apply changed location hash
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 5 Jun 2022 19:06:41 +0000 (21:06 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 11 Jul 2022 02:02:34 +0000 (04:02 +0200)
base.css
word/finder.js
word/finder.plp
word/quiz.js

index 6f34ef15ef0fd9084760593d57d0672f7a1fca6e..31429aa7067158562ec6a73070bf5c394d30c420 100644 (file)
--- a/base.css
+++ b/base.css
@@ -736,7 +736,7 @@ figure img {
 }
 @media (min-width: 603px) and (min-height: 400px) {
        /* fit 3 cells of 200x133 */
-       .gallery > ul > li:first-child > figure,
+       .gallery > li:first-child > figure,
        .gallery li.huge > figure {
                grid-row: span 3;
                grid-column: span 3;
index ea1781d16ad3d5ee528d7b027a79ee62a0a8d648..5dcc9e3de93f079521c4be441f0345795ce99c78 100644 (file)
@@ -1,6 +1,5 @@
 class WordFinder extends WordQuiz {
-       add(parentitem, rows) {
-               const catitem = put(parentitem, 'ul');
+       add(catitem, rows) {
                rows.forEach(ref => {
                        const [title, level, imgid, subs] = this.data[ref];
                        const worditem = put(catitem, 'li');
@@ -20,15 +19,18 @@ class WordFinder extends WordQuiz {
                        if (subs.length) {
                                // delve into subcategory
                                put(worditem, '.parent');
-                               this.add(worditem, subs);
+                               this.add(put(worditem, 'ul'), subs);
                        }
                });
        }
 
        setup() {
                this.gallery = document.getElementById('gallery');
-               put(this.gallery, '-p', 'Under construction.');
-               this.add(this.gallery, this.preset.cat ? [this.preset.cat] : this.data[''][3]);
+               this.gallery.innerHTML = '';
+               put(this.gallery, 'p', 'Under construction.');
+               for (let cat of this.preset.cat ? [this.preset.cat] : this.data[''][3]) {
+                       this.add(put(this.gallery, 'ul.gallery'), [cat]);
+               }
        }
 
        stop() {}
index 6e302ba38a992a29498d904c230ebd4774e8fc26..ffaeb12710059f012babbc5c9c69cc48be10a3ee 100644 (file)
@@ -11,5 +11,5 @@ EOT
 });
 
 say '<h1>Words</h1>';
-say '<section id="gallery" class="gallery"></section>';
+say '<section id="gallery"></section>';
 say "<script>new WordFinder('/$wordlistbase.json')</script>";
index 1aaab61cb6e56f537f75ad9da554dbab820723a0..a7194bbac88418f0b5cfd89aa6e5dd8c1369c9d4 100644 (file)
@@ -89,5 +89,8 @@ class WordQuiz {
                window.onbeforeunload = e => {
                        this.stop('abort');
                };
+               window.onhashchange = e => {
+                       this.load(dataurl);
+               };
        }
 }