word edit: hide original image until requested
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 29 May 2020 05:10:27 +0000 (07:10 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 6 Jun 2020 01:49:20 +0000 (03:49 +0200)
writer.js
writer.plp

index 450a8f2ece4772eac272672e5d2c0668e6b1de6a..e21b6849e2a59db9ef7b6d641bfff6a2a38077d5 100644 (file)
--- a/writer.js
+++ b/writer.js
@@ -31,4 +31,16 @@ document.addEventListener('DOMContentLoaded', () => {
                }).catch(error => alert(error));
                return false;
        };
+
+       let imgpreview = document.getElementById('sourcepreview');
+       if (imgpreview) {
+               let imginput = document.getElementById('source');
+               let previewbutton = imginput.parentNode.appendChild(document.createElement('button'));
+               previewbutton.type = 'button';
+               previewbutton.append('View');
+               previewbutton.onclick = () => {
+                       previewbutton.childNodes[0].nodeValue = imgpreview.hidden ? 'Hide' : 'View';
+                       imgpreview.hidden = !imgpreview.hidden;
+               };
+       }
 });
index 2df9e559f2895c7eb982f18301e2d836c74d2e8a..206333f137e04c33e67b777b31e98ffdb37aa329 100644 (file)
@@ -40,9 +40,6 @@ input:not([type]) {
 select {
        padding: .3rem .2rem; /* TODO: input */
 }
-form > ul li img {
-       max-width: 300px;
-}
 
 ul.popup {
        display: flex;
@@ -108,7 +105,7 @@ my @wordcols = (
        form    => 'Translation',
        alt     => 'Synonyms',
        wptitle => 'Wikipedia',
-       source  => 'Image URL',
+       source  => 'Image',
        thumb   => 'Convert options',
        prio    => 'Level',
        cover   => undef, # included with prio
@@ -231,12 +228,13 @@ for my $colinfo (pairs @wordcols) {
        }
        else {
                printf '<input id="%s" name="%1$s" value="%s" />', $col, Entity($val);
-               -e and printf '<img src="/%s" alt="%s" />', $_, $row->{form} for
-                       $col eq 'source' ? "data/word/org/$row->{id}.jpg" :
-                       $col eq 'thumb'  ? "data/word/eng/$row->{form}.jpg" :
-                       ();
+               -e and printf '<img src="/%s" alt="%s" />', $_, $row->{form}
+                       for $col eq 'thumb'  ? "data/word/eng/$row->{form}.jpg" : ();
        }
                print '</span>';
+       -e and printf('<img id="%spreview" src="/%s" alt="%s" hidden />',
+               $col, $_, $row->{form}
+       ) for $col eq 'source' ? "data/word/org/$row->{id}.jpg" : ();
        say '</p></li>';
 }
 :>