changeset 975:ec5cb1790119 draft

Apply referring hover to td ajax-posted
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 29 May 2022 07:55:44 +0900
parents 39ef64b5654d
children ae6c5df09f22
files s4-main.js
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/s4-main.js	Sat May 28 23:18:43 2022 +0900
+++ b/s4-main.js	Sun May 29 07:55:44 2022 +0900
@@ -184,6 +184,7 @@
 		localntr.classList.remove("dissolving");
 		localntr.classList.add("emerging");
 	    }, 100);
+	    initReplyHover(ntr);
 	    cnt++;
 	}
 	mathjaxUpdate(newids);
@@ -1033,7 +1034,7 @@
 	});
 	ta.parentNode.appendChild(btn);
     }
-    function initReplyHover() {
+    function initReplyHover(unit) {
 	function getTextById(id) {
 	    let repltd = document.getElementById(id);
 	    if (repltd) {
@@ -1046,7 +1047,8 @@
 	    } else
 		return "";
 	}
-	for (let td of document.querySelectorAll("td.repl")) {
+	unit = unit||document;
+	for (let td of unit.querySelectorAll("td.repl")) {
 	    let text = td.innerHTML;
 	    if (text.startsWith("\&gt;#")) {
 		let newline = text.indexOf("\n");
@@ -1056,8 +1058,9 @@
 		    /#([0-9]+)/g,
 		    (match, start, whole) => {
 			let id = RegExp.$1
-			return '<span title="' + getTextById(id) + '">'
-			    + match + '</span>';
+			return '<a title="' + getTextById(id)
+			    + '" href="' + match
+			    + '">' + match + '</a>';
 		    }
 		) + rest;
 	    }

yatex.org