# HG changeset patch # User HIROSE Yuuji # Date 1565916499 -32400 # Node ID a03bfd5d242a361517c5ca550d686cc4c27b82f0 # Parent dfa90fbc05bd9c8e82b061959f7ee2c6f16bf554 First trial of js interaction. Reply checkbox inserts/removes redirection mark. diff -r dfa90fbc05bd -r a03bfd5d242a examples/common/default/html.m4.html --- a/examples/common/default/html.m4.html Thu Aug 15 17:09:16 2019 +0900 +++ b/examples/common/default/html.m4.html Fri Aug 16 09:48:19 2019 +0900 @@ -8,6 +8,7 @@ `') _TITLE_|ifdef(`_S4NAME_',`_S4NAME_',s4) + ifdef(`_S4CSS_', ` ')dnl diff -r dfa90fbc05bd -r a03bfd5d242a s4-blog.sh --- a/s4-blog.sh Thu Aug 15 17:09:16 2019 +0900 +++ b/s4-blog.sh Fri Aug 16 09:48:19 2019 +0900 @@ -440,7 +440,7 @@
-"' diff -r dfa90fbc05bd -r a03bfd5d242a s4-main.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/s4-main.js Fri Aug 16 09:48:19 2019 +0900 @@ -0,0 +1,62 @@ +(function (){ + function collectElementsByNameAttr(elm, name) { + var e = document.getElementsByTagName(elm); + if (!e) return null; + var list = []; + for (var i of e) { + if (i.getAttribute("name") == name) + list.push(i) + } + return list; + } + function insertRedirect(e) { + var articleId, textarea = document.getElementById("text"); + var p = e.target, checked = p.checked; + while (p = p.parentNode) + if (p.nodeName.match(/^td$/i)) break; + if (!p) return; + while (p = p.nextSibling) + if (p.nodeName.match(/^td$/i)) break; + if (!p) return; + articleId = p.getAttribute("id"); + if (textarea && articleId) { + var tv = textarea.value, lines; + if (tv) + lines = tv.split("\n"); + else + lines = [""]; + var re = new RegExp("[, ]*#"+articleId+"(?![0-9])"); + if (checked) { + if (!lines[0].match(re)) { + var re2 = new RegExp(/>#[#0-9, ]+[0-9]/); + if (lines[0].match(re2)) + lines[0] = lines[0].replace( + re2, '$&, '+'#'+articleId); + else { + if (lines[0] > "") lines[0] = " "+lines[0]; + lines[0] = ">#"+articleId+lines[0]; + } + } + } else { // Remove #xxxxx + if (lines[0].match(/^>#[0-9 ,]+#/)) // 2 or more #id's + lines[0] = lines[0].replace( + new RegExp("^>#"+articleId+"[ ,]*"), ">").replace( + new RegExp("[ ,]*#"+articleId), ""); + else { + lines[0] = lines[0].replace( + new RegExp(">#"+articleId+"[ ,]*"), ""); + } + } + lines[0] = lines[0].replace(/^> *$/, ''); + textarea.value = lines.join("\n"); + } + } + function init(){ + var el, check = collectElementsByNameAttr("input", "notifyto"); + if (check) + for (var i of check) { + i.addEventListener("click", insertRedirect, null); + } + } + document.addEventListener('DOMContentLoaded', init, null); +})();
'"$touchhelp
添付ファイル(${filesize_max_MB}以下):"'