1 |
wakaba |
1.1 |
function setResult (id, value) { |
2 |
|
|
var rel = document.getElementById (id); |
3 |
|
|
rel.textContent = 'FAIL (script error)'; |
4 |
|
|
rel.innerText = 'FAIL (script error)'; |
5 |
|
|
rel.setAttributeNS (null, 'class', 'FAIL'); // NOTE: 'className' setter does not work in Firefox 2. |
6 |
|
|
var valueType = typeof value; |
7 |
|
|
if (value === undefined) { |
8 |
|
|
rel.textContent = '(undefined)'; |
9 |
|
|
rel.innerText = '(undefined)'; |
10 |
|
|
} else if (value === null) { |
11 |
|
|
rel.textContent = '(null)'; |
12 |
|
|
rel.innerText = '(null)'; |
13 |
|
|
} else if (value === '') { |
14 |
|
|
rel.textContent = '(empty)'; |
15 |
|
|
rel.innerText = '(empty)'; |
16 |
|
|
} else { |
17 |
|
|
value = '' + value; |
18 |
|
|
rel.textContent = ''; |
19 |
|
|
rel.innerText = ''; |
20 |
|
|
rel.appendChild (document.createElementNS |
21 |
|
|
('http://www.w3.org/2000/svg', 'tspan')) |
22 |
|
|
.appendChild (document.createTextNode |
23 |
|
|
(value.replace (/&/g, '&') |
24 |
|
|
.replace (/\u0009/g, '	') |
25 |
|
|
.replace (/\u000A/g, '
') |
26 |
|
|
.replace (/\u000D/g, '
'))); |
27 |
|
|
} |
28 |
|
|
rel.appendChild (document.createTextNode (', type ' + valueType)); |
29 |
|
|
rel.setAttributeNS (null, 'class', 'see-detail'); |
30 |
|
|
} |