Mercurial > hgrepos > hgweb.cgi > s4
changeset 972:8781f341d93a draft
Add referring text to hover title of ">#xxxx" marks.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 28 May 2022 22:34:21 +0900 |
parents | 0ac251f04f21 |
children | 072362c47306 |
files | s4-main.js |
diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-main.js Sun May 22 12:19:15 2022 +0900 +++ b/s4-main.js Sat May 28 22:34:21 2022 +0900 @@ -1,6 +1,7 @@ // 愛 (function (){ var isOlderJS; // Set in init(); + var hoverTextLines = 10; var hasTouchPad = (navigator.maxTouchPoints && navigator.maxTouchPoints >0); var myurl = document.URL, @@ -1032,6 +1033,30 @@ }); 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"); + } + 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), + rest = text.substring(newline); + td.innerHTML = first.replace( + /#([0-9]+)/g, + (match, start, whole) => { + let id = RegExp.$1 + return '<span title="' + getTextId(id) + '">' + + match + '</span>'; + } + ) + rest; + } + } + } function init() { isOlderJS = !("insertAdjacentElement" in document.body); initGrpAction(); @@ -1040,6 +1065,7 @@ initTextarea(); initGrphome(); initMath(); + initReplyHover(); } document.addEventListener('DOMContentLoaded', init, null); })();