# HG changeset patch # User HIROSE Yuuji # Date 1653744861 -32400 # Node ID 8781f341d93ac9a7184264b35b7f8eecf529e0a2 # Parent 0ac251f04f21ab53d0f9c835eeaf4ad93e91c522 Add referring text to hover title of ">#xxxx" marks. diff -r 0ac251f04f21 -r 8781f341d93a s4-main.js --- 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 '' + + match + ''; + } + ) + rest; + } + } + } function init() { isOlderJS = !("insertAdjacentElement" in document.body); initGrpAction(); @@ -1040,6 +1065,7 @@ initTextarea(); initGrphome(); initMath(); + initReplyHover(); } document.addEventListener('DOMContentLoaded', init, null); })();