Mercurial > hgrepos > hgweb.cgi > s4
changeset 969:b327b5691b59 draft
Add author-hide/show button in quiz mode
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 15 May 2022 14:38:40 +0900 |
parents | edd96c59c8a2 |
children | 10803d78f07c |
files | examples/common/default/default.css s4-blog.sh s4-main.js |
diffstat | 3 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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"'
--- 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);