s4

changeset 969:b327b5691b59

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 diff
     1.1 --- a/examples/common/default/default.css	Sun Apr 10 07:54:52 2022 +0900
     1.2 +++ b/examples/common/default/default.css	Sun May 15 14:38:40 2022 +0900
     1.3 @@ -157,6 +157,7 @@
     1.4      display: inline-block; border-radius: 0.8ex;
     1.5  }
     1.6  .blog_replies td.repatt {min-width: 12em;}
     1.7 +.blog_replies td.hideauthor {display: none;}
     1.8  table.blog_replies iframe {
     1.9      width: 80%; min-height: 300px; max-width: 50em; max-height: 80vw;
    1.10      padding: 0; border: 0;
     2.1 --- a/s4-blog.sh	Sun Apr 10 07:54:52 2022 +0900
     2.2 +++ b/s4-blog.sh	Sun May 15 14:38:40 2022 +0900
     2.3 @@ -310,7 +310,8 @@
     2.4  	EOF
     2.5        case "$blogtype" in
     2.6  	"クイズ"|"XXXX集計")
     2.7 -	  echo "${blogtype}モードは本人と管理者の書き込みのみが表示されます。"
     2.8 +	  echo "${blogtype}モードは本人と管理者の書き込みのみが表示されます"
     2.9 +	  echo "隠す/見せる(Hide/Show)" | html button 'id="quizwarn" type="button"'
    2.10  	  ;;
    2.11        esac | html p 'class="warn"'
    2.12  
     3.1 --- a/s4-main.js	Sun Apr 10 07:54:52 2022 +0900
     3.2 +++ b/s4-main.js	Sun May 15 14:38:40 2022 +0900
     3.3 @@ -793,6 +793,22 @@
     3.4  	}
     3.5  	return elem;
     3.6      }
     3.7 +    var quizwarnVisible = false;
     3.8 +    function toggleAuthorVisibility(e) {
     3.9 +	// In QUIZ mode, click to quizwarn line toggles visibility of author
    3.10 +	e.stopPropagation();
    3.11 +	if (quizwarnVisible) {
    3.12 +	    for (let i of document.querySelectorAll("td.repatt")) {
    3.13 +		i.classList.remove("hideauthor");
    3.14 +	    }
    3.15 +	    quizwarnVisible = false;
    3.16 +	} else {
    3.17 +	    for (let i of document.querySelectorAll("td.repatt")) {
    3.18 +		i.classList.add("hideauthor");
    3.19 +	    }
    3.20 +	    quizwarnVisible = true;
    3.21 +	}
    3.22 +    }
    3.23      function initBlogs() {
    3.24  	// Auto-complete #xxxx
    3.25  	let i, check = collectElementsByAttr("input", "name", "notifyto");
    3.26 @@ -829,6 +845,9 @@
    3.27  		warnFileSize(document.forms[0]);
    3.28  	    }, false)
    3.29  	}
    3.30 +	if (i=document.getElementById("quizwarn")) {
    3.31 +	    i.addEventListener('click', toggleAuthorVisibility, false);
    3.32 +	}
    3.33  	// Hack article_m links
    3.34  	registPjaxViewers(document.querySelectorAll("a[href]"));
    3.35  	atMarkView(document);