comparison s4-main.js @ 984:a094bd547d6b draft

Escape chars in hover string
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 26 Jun 2022 14:10:54 +0900
parents f5a7fbd6c0d0
children e71a86651d72
comparison
equal deleted inserted replaced
983:c69cf72ea116 984:a094bd547d6b
11 let input_pdfsw = 'input[name="comppdf"]'; 11 let input_pdfsw = 'input[name="comppdf"]';
12 if (mypath.match(/(.*)\/(.*)/)) { 12 if (mypath.match(/(.*)\/(.*)/)) {
13 mypath = RegExp.$2; 13 mypath = RegExp.$2;
14 mypath = mypath.substring(0, mypath.lastIndexOf("?")); 14 mypath = mypath.substring(0, mypath.lastIndexOf("?"));
15 //alert("mypath="+mypath); 15 //alert("mypath="+mypath);
16 }
17 function escapeChars(old) {
18 return old.replaceAll('"', '&quot;')
19 .replaceAll("<", '&lt;')
20 .replaceAll(">", '&gt;');
16 } 21 }
17 function collectElementsByAttr(elm, attr, val) { 22 function collectElementsByAttr(elm, attr, val) {
18 var e = document.getElementsByTagName(elm); 23 var e = document.getElementsByTagName(elm);
19 if (!e) return null; 24 if (!e) return null;
20 var list = []; 25 var list = [];
1040 if (repltd) { 1045 if (repltd) {
1041 let txt = repltd.innerText, 1046 let txt = repltd.innerText,
1042 authtd = repltd.parentNode.getElementsByTagName("td")[0], 1047 authtd = repltd.parentNode.getElementsByTagName("td")[0],
1043 author = authtd.querySelector("a.author").innerText, 1048 author = authtd.querySelector("a.author").innerText,
1044 digest = txt.split("\n").splice(0, hoverTextLines).join("\n"); 1049 digest = txt.split("\n").splice(0, hoverTextLines).join("\n");
1045 return "[[ "+author+" ]]\n"+digest; 1050 return escapeChars("[[ "+author+" ]]\n"+digest);
1046 } else 1051 } else
1047 return ""; 1052 return "";
1048 } 1053 }
1049 unit = unit||document; 1054 unit = unit||document;
1050 for (let td of unit.querySelectorAll("td.repl")) { 1055 for (let td of unit.querySelectorAll("td.repl")) {

yatex.org