Mercurial > hgrepos > hgweb.cgi > s4
changeset 973:072362c47306 draft
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 wrap: on
line diff
--- a/s4-main.js Sat May 28 22:34:21 2022 +0900 +++ b/s4-main.js Sat May 28 22:58:06 2022 +0900 @@ -1034,14 +1034,17 @@ ta.parentNode.appendChild(btn); } function initReplyHover() { - function getTextId(id) { - console.log("Getting!::"+id); - let txt = document.getElementById(id).innerText; - return txt.split("\n").splice(0,hoverTextLines).join("\n"); + function getTextById(id) { + let repltd = document.getElementById(id), + txt = repltd.innerText, + authtd = repltd.parentNode.getElementsByTagName("td")[0], + authAs = authtd.getElementsByTagName("a"), + author = authAs[authAs.length-1].innerText, + digest = txt.split("\n").splice(0, hoverTextLines).join("\n"); + return "[[ "+author+" ]]\n"+digest; } for (let td of document.querySelectorAll("td.repl")) { let text = td.innerHTML; - console.log(text); if (text.startsWith("\>#")) { let newline = text.indexOf("\n"); let first = text.substring(0, newline), @@ -1050,7 +1053,7 @@ /#([0-9]+)/g, (match, start, whole) => { let id = RegExp.$1 - return '<span title="' + getTextId(id) + '">' + return '<span title="' + getTextById(id) + '">' + match + '</span>'; } ) + rest;