changeset 911:fe6e6b72de17

Restrict ajax button activation to certain case
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 05 Jan 2021 13:29:54 +0900
parents 043748271354
children 4f19add6f877
files s4-main.js
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/s4-main.js	Tue Jan 05 13:14:26 2021 +0900
+++ b/s4-main.js	Tue Jan 05 13:29:54 2021 +0900
@@ -613,7 +613,11 @@
 		i.addEventListener("click", insertRedirect, false);
 	    }
 	registInsertDirect(document.querySelectorAll("a[href]"));
-	if (document.querySelector('td[class="repl"]'))
+	if (myurl.match(/replyblog\+[0-9]/)
+	    && document.querySelector("td.repl")) {
+	    // There's no need to provide ajax posting when
+	    // no replies written to the blog.  Therefore we
+	    // assign ajax post when td.repl exists.
 	    for (i of document.querySelectorAll('input#c[value="送信"]')) {
 		let b = document.createElement("button");
 		b.textContent = "送信!";
@@ -626,8 +630,9 @@
 		b.id = i.id;
 		i.remove();
 	    }
-	i = document.getElementById("reload");
-	if (i) i.addEventListener("click", ajaxPost, false);
+	    i = document.getElementById("reload");
+	    if (i) i.addEventListener("click", ajaxPost, false);
+	}
 	for (i of document.querySelectorAll('input[type="file"]')) {
 	    i.addEventListener('change', (e) => {
 		warnFileSize(document.forms[0]);

yatex.org