1 |
wakaba |
1.1 |
function addSourceToParseErrorList (idPrefix) { |
2 |
|
|
var parseErrorsList = document.getElementById |
3 |
|
|
(idPrefix + 'parse-errors-list'); |
4 |
|
|
if (!parseErrorsList) return; |
5 |
|
|
var childs = parseErrorsList.childNodes; |
6 |
|
|
var childsL = childs.length; |
7 |
|
|
var line = 0; |
8 |
|
|
var column = 0; |
9 |
|
|
for (var i = 0; i < childsL; i++) { |
10 |
|
|
var child = childs[i]; |
11 |
|
|
if (child.nodeType != 1) continue; |
12 |
|
|
if (child.nodeName == 'DT') { |
13 |
|
|
var text = child.textContent || child.innerText; |
14 |
|
|
var m; |
15 |
|
|
if (m = text.match (/Line (\d+)(?: column (\d+))?/)) { |
16 |
|
|
line = parseInt (m[1]); |
17 |
|
|
column = parseInt (m[2] || 0); |
18 |
|
|
} else { |
19 |
|
|
line = 0; |
20 |
|
|
column = 0; |
21 |
|
|
} |
22 |
|
|
} else if (child.nodeName == 'DD') { |
23 |
|
|
if (line > 0) { |
24 |
|
|
var lineEl = document.getElementById (idPrefix + 'line-' + line); |
25 |
|
|
if (lineEl) { |
26 |
|
|
lineText = lineEl.innerHTML |
27 |
wakaba |
1.3 |
.replace (/<var>U\+([0-9A-F]{4})<\/var>/g, function (s) { |
28 |
|
|
return String.fromCharCode (parseInt (s, 16)); |
29 |
|
|
}) |
30 |
wakaba |
1.1 |
.replace (/</g, '<') |
31 |
|
|
.replace (/>/g, '>') |
32 |
|
|
.replace (/ /g, '\u00A0') |
33 |
|
|
.replace (/"/g, '"') |
34 |
|
|
.replace (/&/g, '&'); |
35 |
|
|
var p = document.createElement ('p'); |
36 |
|
|
p.className = 'source-fragment'; |
37 |
|
|
var code = document.createElement ('code'); |
38 |
|
|
if (lineText.length > 50) { |
39 |
|
|
if (column - 25 > 0) { |
40 |
|
|
p.appendChild (document.createElement ('var')).innerHTML |
41 |
|
|
= '...'; |
42 |
|
|
lineText = lineText.substring (column - 25, column + 24); |
43 |
|
|
code.appendChild (document.createTextNode |
44 |
|
|
(lineText.substring (0, 24))); |
45 |
|
|
code.appendChild (document.createElement ('mark')) |
46 |
|
|
.appendChild (document.createTextNode |
47 |
|
|
(lineText.charAt (24))); |
48 |
|
|
code.appendChild (document.createTextNode |
49 |
|
|
(lineText.substring (25, lineText.length))); |
50 |
|
|
p.appendChild (code); |
51 |
|
|
p.appendChild (document.createElement ('var')).innerHTML |
52 |
|
|
= '...'; |
53 |
|
|
} else { |
54 |
|
|
lineText = lineText.substring (0, 50); |
55 |
|
|
if (column > 0) { |
56 |
|
|
code.appendChild (document.createTextNode |
57 |
|
|
(lineText.substring (0, column - 1))); |
58 |
|
|
code.appendChild (document.createElement ('mark')) |
59 |
|
|
.appendChild (document.createTextNode |
60 |
|
|
(lineText.charAt (column - 1))); |
61 |
|
|
code.appendChild (document.createTextNode |
62 |
|
|
(lineText.substring (column, lineText.length))); |
63 |
|
|
} else { |
64 |
|
|
code.appendChild (document.createTextNode |
65 |
|
|
(lineText.substring (0, 50))); |
66 |
|
|
} |
67 |
|
|
p.appendChild (code); |
68 |
|
|
p.appendChild (document.createElement ('var')).innerHTML |
69 |
|
|
= '...'; |
70 |
|
|
} |
71 |
|
|
} else { |
72 |
wakaba |
1.2 |
if (column > 0) { |
73 |
|
|
code.appendChild (document.createTextNode |
74 |
|
|
(lineText.substring (0, column - 1))); |
75 |
|
|
code.appendChild (document.createElement ('mark')) |
76 |
|
|
.appendChild (document.createTextNode |
77 |
|
|
(lineText.charAt (column - 1))); |
78 |
|
|
code.appendChild (document.createTextNode |
79 |
|
|
(lineText.substring (column, lineText.length))); |
80 |
|
|
} else { |
81 |
|
|
code.appendChild (document.createTextNode (lineText)); |
82 |
|
|
} |
83 |
wakaba |
1.1 |
p.appendChild (code); |
84 |
|
|
} |
85 |
|
|
child.appendChild (p); |
86 |
|
|
} |
87 |
|
|
} |
88 |
|
|
line = 0; |
89 |
|
|
column = 0; |
90 |
|
|
} |
91 |
|
|
} |
92 |
|
|
} // addSourceToParseErrorList |
93 |
|
|
|
94 |
wakaba |
1.3 |
// $Date: 2008/03/16 05:45:10 $ |