Mercurial > hgrepos > hgweb.cgi > s4
changeset 974:39ef64b5654d draft
Check ID existence
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 28 May 2022 23:18:43 +0900 |
parents | 072362c47306 |
children | ec5cb1790119 |
files | s4-main.js |
diffstat | 1 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-main.js Sat May 28 22:58:06 2022 +0900 +++ b/s4-main.js Sat May 28 23:18:43 2022 +0900 @@ -1035,13 +1035,16 @@ } function initReplyHover() { 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; + let repltd = document.getElementById(id); + if (repltd) { + let 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; + } else + return ""; } for (let td of document.querySelectorAll("td.repl")) { let text = td.innerHTML;