# HG changeset patch # User HIROSE Yuuji # Date 1652593120 -32400 # Node ID b327b5691b595f0ea6e1f07fe85c3e0c4dc4c32f # Parent edd96c59c8a2f36cbe13412e45ca21f50af5b588 Add author-hide/show button in quiz mode diff -r edd96c59c8a2 -r b327b5691b59 examples/common/default/default.css --- a/examples/common/default/default.css Sun Apr 10 07:54:52 2022 +0900 +++ b/examples/common/default/default.css Sun May 15 14:38:40 2022 +0900 @@ -157,6 +157,7 @@ display: inline-block; border-radius: 0.8ex; } .blog_replies td.repatt {min-width: 12em;} +.blog_replies td.hideauthor {display: none;} table.blog_replies iframe { width: 80%; min-height: 300px; max-width: 50em; max-height: 80vw; padding: 0; border: 0; diff -r edd96c59c8a2 -r b327b5691b59 s4-blog.sh --- a/s4-blog.sh Sun Apr 10 07:54:52 2022 +0900 +++ b/s4-blog.sh Sun May 15 14:38:40 2022 +0900 @@ -310,7 +310,8 @@ EOF case "$blogtype" in "クイズ"|"XXXX集計") - echo "${blogtype}モードは本人と管理者の書き込みのみが表示されます。" + echo "${blogtype}モードは本人と管理者の書き込みのみが表示されます" + echo "隠す/見せる(Hide/Show)" | html button 'id="quizwarn" type="button"' ;; esac | html p 'class="warn"' diff -r edd96c59c8a2 -r b327b5691b59 s4-main.js --- a/s4-main.js Sun Apr 10 07:54:52 2022 +0900 +++ b/s4-main.js Sun May 15 14:38:40 2022 +0900 @@ -793,6 +793,22 @@ } return elem; } + var quizwarnVisible = false; + function toggleAuthorVisibility(e) { + // In QUIZ mode, click to quizwarn line toggles visibility of author + e.stopPropagation(); + if (quizwarnVisible) { + for (let i of document.querySelectorAll("td.repatt")) { + i.classList.remove("hideauthor"); + } + quizwarnVisible = false; + } else { + for (let i of document.querySelectorAll("td.repatt")) { + i.classList.add("hideauthor"); + } + quizwarnVisible = true; + } + } function initBlogs() { // Auto-complete #xxxx let i, check = collectElementsByAttr("input", "name", "notifyto"); @@ -829,6 +845,9 @@ warnFileSize(document.forms[0]); }, false) } + if (i=document.getElementById("quizwarn")) { + i.addEventListener('click', toggleAuthorVisibility, false); + } // Hack article_m links registPjaxViewers(document.querySelectorAll("a[href]")); atMarkView(document);