s4

changeset 973:072362c47306

Add author to hover text
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 28 May 2022 22:58:06 +0900
parents 8781f341d93a
children 39ef64b5654d
files s4-main.js
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/s4-main.js	Sat May 28 22:34:21 2022 +0900
     1.2 +++ b/s4-main.js	Sat May 28 22:58:06 2022 +0900
     1.3 @@ -1034,14 +1034,17 @@
     1.4  	ta.parentNode.appendChild(btn);
     1.5      }
     1.6      function initReplyHover() {
     1.7 -	function getTextId(id) {
     1.8 -	    console.log("Getting!::"+id);
     1.9 -	    let txt = document.getElementById(id).innerText;
    1.10 -	    return txt.split("\n").splice(0,hoverTextLines).join("\n");
    1.11 +	function getTextById(id) {
    1.12 +	    let repltd = document.getElementById(id),
    1.13 +		txt = repltd.innerText,
    1.14 +		authtd = repltd.parentNode.getElementsByTagName("td")[0],
    1.15 +		authAs = authtd.getElementsByTagName("a"),
    1.16 +		author = authAs[authAs.length-1].innerText,
    1.17 +		digest = txt.split("\n").splice(0, hoverTextLines).join("\n");
    1.18 +	    return "[[ "+author+" ]]\n"+digest;
    1.19  	}
    1.20  	for (let td of document.querySelectorAll("td.repl")) {
    1.21  	    let text = td.innerHTML;
    1.22 -	    console.log(text);
    1.23  	    if (text.startsWith("\&gt;#")) {
    1.24  		let newline = text.indexOf("\n");
    1.25  		let first   = text.substring(0, newline),
    1.26 @@ -1050,7 +1053,7 @@
    1.27  		    /#([0-9]+)/g,
    1.28  		    (match, start, whole) => {
    1.29  			let id = RegExp.$1
    1.30 -			return '<span title="' + getTextId(id) + '">'
    1.31 +			return '<span title="' + getTextById(id) + '">'
    1.32  			    + match + '</span>';
    1.33  		    }
    1.34  		) + rest;