s4

changeset 974:39ef64b5654d

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 diff
     1.1 --- a/s4-main.js	Sat May 28 22:58:06 2022 +0900
     1.2 +++ b/s4-main.js	Sat May 28 23:18:43 2022 +0900
     1.3 @@ -1035,13 +1035,16 @@
     1.4      }
     1.5      function initReplyHover() {
     1.6  	function getTextById(id) {
     1.7 -	    let repltd = document.getElementById(id),
     1.8 -		txt = repltd.innerText,
     1.9 -		authtd = repltd.parentNode.getElementsByTagName("td")[0],
    1.10 -		authAs = authtd.getElementsByTagName("a"),
    1.11 -		author = authAs[authAs.length-1].innerText,
    1.12 -		digest = txt.split("\n").splice(0, hoverTextLines).join("\n");
    1.13 -	    return "[[ "+author+" ]]\n"+digest;
    1.14 +	    let repltd = document.getElementById(id);
    1.15 +	    if (repltd) {
    1.16 +		let txt = repltd.innerText,
    1.17 +		    authtd = repltd.parentNode.getElementsByTagName("td")[0],
    1.18 +		    authAs = authtd.getElementsByTagName("a"),
    1.19 +		    author = authAs[authAs.length-1].innerText,
    1.20 +		    digest = txt.split("\n").splice(0, hoverTextLines).join("\n");
    1.21 +		return "[[ "+author+" ]]\n"+digest;
    1.22 +	    } else
    1.23 +		return "";
    1.24  	}
    1.25  	for (let td of document.querySelectorAll("td.repl")) {
    1.26  	    let text = td.innerHTML;