changeset 934:9184aa358773 draft

Fake click at Ctrl-Enter posting for ajax post.
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 06 Apr 2021 14:51:44 +0900
parents 3a19873ca4f5
children c17e67348950
files s4-main.js
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/s4-main.js	Sun Mar 28 16:33:40 2021 +0900
+++ b/s4-main.js	Tue Apr 06 14:51:44 2021 +0900
@@ -478,9 +478,13 @@
 	}
 	return stra.join("\n");
     }
-    function submitThisForm(input) {
+    function submitThisForm(e) {
+	var input = e.target, ajaxpost = document.getElementById("c");
 	for (var elm=input.parentNode; elm; elm = elm.parentNode) {
-	    if (elm.nodeName.match(/form/i)) {
+	    if (ajaxpost) {
+		ajaxpost.click();
+		return true;
+	    } else if (elm.nodeName.match(/form/i)) {
 		elm.submit();
 		return true;
 	    }
@@ -505,7 +509,7 @@
     }
     function helpMarkdownEnter(e) {
 	if (e.keyCode == 13 && !e.shiftKey) {
-	    if (e.ctrlKey && submitThisForm(e.target)) {
+	    if (e.ctrlKey && submitThisForm(e)) {
 		e.preventDefault();
 		return;
 	    }

yatex.org