s4

changeset 975:ec5cb1790119

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 diff
     1.1 --- a/s4-main.js	Sat May 28 23:18:43 2022 +0900
     1.2 +++ b/s4-main.js	Sun May 29 07:55:44 2022 +0900
     1.3 @@ -184,6 +184,7 @@
     1.4  		localntr.classList.remove("dissolving");
     1.5  		localntr.classList.add("emerging");
     1.6  	    }, 100);
     1.7 +	    initReplyHover(ntr);
     1.8  	    cnt++;
     1.9  	}
    1.10  	mathjaxUpdate(newids);
    1.11 @@ -1033,7 +1034,7 @@
    1.12  	});
    1.13  	ta.parentNode.appendChild(btn);
    1.14      }
    1.15 -    function initReplyHover() {
    1.16 +    function initReplyHover(unit) {
    1.17  	function getTextById(id) {
    1.18  	    let repltd = document.getElementById(id);
    1.19  	    if (repltd) {
    1.20 @@ -1046,7 +1047,8 @@
    1.21  	    } else
    1.22  		return "";
    1.23  	}
    1.24 -	for (let td of document.querySelectorAll("td.repl")) {
    1.25 +	unit = unit||document;
    1.26 +	for (let td of unit.querySelectorAll("td.repl")) {
    1.27  	    let text = td.innerHTML;
    1.28  	    if (text.startsWith("\&gt;#")) {
    1.29  		let newline = text.indexOf("\n");
    1.30 @@ -1056,8 +1058,9 @@
    1.31  		    /#([0-9]+)/g,
    1.32  		    (match, start, whole) => {
    1.33  			let id = RegExp.$1
    1.34 -			return '<span title="' + getTextById(id) + '">'
    1.35 -			    + match + '</span>';
    1.36 +			return '<a title="' + getTextById(id)
    1.37 +			    + '" href="' + match
    1.38 +			    + '">' + match + '</a>';
    1.39  		    }
    1.40  		) + rest;
    1.41  	    }