/[suikacvs]/test/html-webhacc/cc-script.js
Suika

Contents of /test/html-webhacc/cc-script.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Sun Mar 16 05:45:10 2008 UTC (16 years, 8 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +12 -2 lines
File MIME type: application/javascript
++ ChangeLog	16 Mar 2008 05:45:04 -0000
	* cc-script.js: Character was not marked if the line
	is less than 50 characters.

2008-03-16  Wakaba  <wakaba@suika.fam.cx>

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 (/&lt;/g, '<')
28 .replace (/&gt;/g, '>')
29 .replace (/&nbsp;/g, '\u00A0')
30 .replace (/&quot;/g, '"')
31 .replace (/&amp;/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 if (column > 0) {
70 code.appendChild (document.createTextNode
71 (lineText.substring (0, column - 1)));
72 code.appendChild (document.createElement ('mark'))
73 .appendChild (document.createTextNode
74 (lineText.charAt (column - 1)));
75 code.appendChild (document.createTextNode
76 (lineText.substring (column, lineText.length)));
77 } else {
78 code.appendChild (document.createTextNode (lineText));
79 }
80 p.appendChild (code);
81 }
82 child.appendChild (p);
83 }
84 }
85 line = 0;
86 column = 0;
87 }
88 }
89 } // addSourceToParseErrorList
90
91 // $Date: 2008/03/16 01:30:56 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24