| 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 |
.replace (/</g, '<') |
| 28 |
.replace (/>/g, '>') |
| 29 |
.replace (/ /g, '\u00A0') |
| 30 |
.replace (/"/g, '"') |
| 31 |
.replace (/&/g, '&'); |
| 32 |
var p = document.createElement ('p'); |
| 33 |
p.className = 'source-fragment'; |
| 34 |
var code = document.createElement ('code'); |
| 35 |
if (lineText.length > 50) { |
| 36 |
if (column - 25 > 0) { |
| 37 |
p.appendChild (document.createElement ('var')).innerHTML |
| 38 |
= '...'; |
| 39 |
lineText = lineText.substring (column - 25, column + 24); |
| 40 |
code.appendChild (document.createTextNode |
| 41 |
(lineText.substring (0, 24))); |
| 42 |
code.appendChild (document.createElement ('mark')) |
| 43 |
.appendChild (document.createTextNode |
| 44 |
(lineText.charAt (24))); |
| 45 |
code.appendChild (document.createTextNode |
| 46 |
(lineText.substring (25, lineText.length))); |
| 47 |
p.appendChild (code); |
| 48 |
p.appendChild (document.createElement ('var')).innerHTML |
| 49 |
= '...'; |
| 50 |
} else { |
| 51 |
lineText = lineText.substring (0, 50); |
| 52 |
if (column > 0) { |
| 53 |
code.appendChild (document.createTextNode |
| 54 |
(lineText.substring (0, column - 1))); |
| 55 |
code.appendChild (document.createElement ('mark')) |
| 56 |
.appendChild (document.createTextNode |
| 57 |
(lineText.charAt (column - 1))); |
| 58 |
code.appendChild (document.createTextNode |
| 59 |
(lineText.substring (column, lineText.length))); |
| 60 |
} else { |
| 61 |
code.appendChild (document.createTextNode |
| 62 |
(lineText.substring (0, 50))); |
| 63 |
} |
| 64 |
p.appendChild (code); |
| 65 |
p.appendChild (document.createElement ('var')).innerHTML |
| 66 |
= '...'; |
| 67 |
} |
| 68 |
} else { |
| 69 |
code.appendChild (document.createTextNode (lineText)); |
| 70 |
p.appendChild (code); |
| 71 |
} |
| 72 |
child.appendChild (p); |
| 73 |
} |
| 74 |
} |
| 75 |
line = 0; |
| 76 |
column = 0; |
| 77 |
} |
| 78 |
} |
| 79 |
} // addSourceToParseErrorList |
| 80 |
|
| 81 |
// $Date:$ |