| 10 |
var child = childs[i]; |
var child = childs[i]; |
| 11 |
if (child.nodeType != 1) continue; |
if (child.nodeType != 1) continue; |
| 12 |
if (child.nodeName == 'DT') { |
if (child.nodeName == 'DT') { |
| 13 |
var text = child.textContent || child.innerText; |
line = parseInt (child.getAttribute ('data-line') || 0); |
| 14 |
var m; |
column = parseInt (child.getAttribute ('data-column') || 0); |
|
if (m = text.match (/Line (\d+)(?: column (\d+))?/)) { |
|
|
line = parseInt (m[1]); |
|
|
column = parseInt (m[2] || 0); |
|
|
} else { |
|
|
line = 0; |
|
|
column = 0; |
|
|
} |
|
| 15 |
} else if (child.nodeName == 'DD') { |
} else if (child.nodeName == 'DD') { |
| 16 |
if (line > 0) { |
if (line > 0) { |
| 17 |
var lineEl = document.getElementById (idPrefix + 'line-' + line); |
var lineEl = document.getElementById (idPrefix + 'line-' + line); |
| 84 |
} |
} |
| 85 |
} // addSourceToParseErrorList |
} // addSourceToParseErrorList |
| 86 |
|
|
| 87 |
|
function insertNavSections (parentId) { |
| 88 |
|
parentId = parentId || ''; |
| 89 |
|
var el = document.createElement ('nav'); |
| 90 |
|
el.id = parentId + 'nav-sections'; |
| 91 |
|
el.innerHTML = '<ul></ul>'; |
| 92 |
|
|
| 93 |
|
if (parentId == '') { |
| 94 |
|
document.body.appendChild (el); |
| 95 |
|
document.webhaccSections = {}; |
| 96 |
|
document.body.setAttribute ('data-scripted', ''); |
| 97 |
|
} else { |
| 98 |
|
var section = document.getElementById (parentId); |
| 99 |
|
section.appendChild (el); |
| 100 |
|
section.webhaccSections = {}; |
| 101 |
|
} |
| 102 |
|
} // insertNavSections |
| 103 |
|
|
| 104 |
|
function addSectionLink (id, label, parentId) { |
| 105 |
|
parentId = parentId || ''; |
| 106 |
|
|
| 107 |
|
var el = document.createElement ('li'); |
| 108 |
|
el.innerHTML = '<a></a>'; |
| 109 |
|
el.firstChild.href = '#' + id; |
| 110 |
|
el.firstChild.innerHTML = label; |
| 111 |
|
document.getElementById (parentId + 'nav-sections') |
| 112 |
|
.firstChild.appendChild (el); |
| 113 |
|
|
| 114 |
|
var sections = document.webhaccSections; |
| 115 |
|
if (parentId != '') { |
| 116 |
|
sections = document.getElementById (parentId).webhaccSections; |
| 117 |
|
} |
| 118 |
|
sections[id] = document.getElementById (id); |
| 119 |
|
sections[id].tabElement = el; |
| 120 |
|
|
| 121 |
|
if (id == 'input' || id == 'input-url') { |
| 122 |
|
showTab (id); |
| 123 |
|
document.webhaccNavigated = false; |
| 124 |
|
} else if (id == 'document-info' && !document.webhaccNavigated) { |
| 125 |
|
showTab (id); |
| 126 |
|
document.webhaccNavigated = false; |
| 127 |
|
} else if (id.match (/-document-info$/)) { |
| 128 |
|
sections[id].tabElement.setAttribute ('data-active', ''); |
| 129 |
|
} else { |
| 130 |
|
sections[id].style.display = 'none'; |
| 131 |
|
} |
| 132 |
|
} // addSectionLink |
| 133 |
|
|
| 134 |
|
function showTab (id) { |
| 135 |
|
var ids = []; |
| 136 |
|
if (id.match (/^line-/)) { |
| 137 |
|
ids = ['source-string']; |
| 138 |
|
} else if (id.match (/^node-/)) { |
| 139 |
|
ids = ['document-tree']; |
| 140 |
|
} else if (id.match (/^subdoc-[^-]+-/)) { |
| 141 |
|
var m; |
| 142 |
|
ids = ['']; |
| 143 |
|
while (true) { |
| 144 |
|
if (m = id.match (/^subdoc-[^-]+-/)) { |
| 145 |
|
ids.push (ids[ids.length - 1] + m[0]); |
| 146 |
|
id = id.substring (m[0].length); |
| 147 |
|
} else { |
| 148 |
|
break; |
| 149 |
|
} |
| 150 |
|
} |
| 151 |
|
if (id.length > 0) { |
| 152 |
|
if (id.match (/^line-/)) { |
| 153 |
|
ids.push (ids[ids.length - 1] + 'source-string'); |
| 154 |
|
} else if (id.match (/^node-/)) { |
| 155 |
|
ids.push (ids[ids.length - 1] + 'document-tree'); |
| 156 |
|
} else { |
| 157 |
|
ids.push (ids[ids.length - 1] + id); |
| 158 |
|
} |
| 159 |
|
} |
| 160 |
|
ids.shift (); // '' |
| 161 |
|
} else if (id.match (/^input-/)) { |
| 162 |
|
ids = ['input', id]; |
| 163 |
|
} else { |
| 164 |
|
ids = [id]; |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
var sections = document.webhaccSections; |
| 168 |
|
while (ids.length > 0) { |
| 169 |
|
var myid = ids.shift (); |
| 170 |
|
_showTab (sections, myid); |
| 171 |
|
sections = sections[myid].webhaccSections; |
| 172 |
|
if (!sections) break; |
| 173 |
|
} |
| 174 |
|
} // showTab |
| 175 |
|
|
| 176 |
|
function _showTab (sections, id) { |
| 177 |
|
if (sections[id]) { |
| 178 |
|
for (var i in sections) { |
| 179 |
|
sections[i].style.display = 'none'; |
| 180 |
|
sections[i].tabElement.removeAttribute ('data-active'); |
| 181 |
|
} |
| 182 |
|
sections[id].style.display = 'block'; |
| 183 |
|
sections[id].tabElement.setAttribute ('data-active', ''); |
| 184 |
|
|
| 185 |
|
document.webhaccNavigated = true; |
| 186 |
|
} |
| 187 |
|
} // _showTab |
| 188 |
|
|
| 189 |
|
function getAncestorAnchorElement (e) { |
| 190 |
|
do { |
| 191 |
|
if (e.nodeName == 'A' || e.nodeName == 'AREA') { |
| 192 |
|
return e; |
| 193 |
|
} |
| 194 |
|
e = e.parentNode; |
| 195 |
|
} while (e); |
| 196 |
|
} // getAncestorAnchorElement |
| 197 |
|
|
| 198 |
|
function onbodyclick (ev) { |
| 199 |
|
var a = getAncestorAnchorElement (ev.target || ev.srcElement); |
| 200 |
|
if (a) { |
| 201 |
|
var href = a.getAttribute ('href'); |
| 202 |
|
if (href && href.match (/^#/)) { |
| 203 |
|
var id = decodeURIComponent (href.substring (1)); |
| 204 |
|
showTab (id); |
| 205 |
|
return true; |
| 206 |
|
} |
| 207 |
|
} |
| 208 |
|
return true; |
| 209 |
|
} // onbodyclick |
| 210 |
|
|
| 211 |
|
function onbodyload () { |
| 212 |
|
// This block should be executed at the end of initialization process, |
| 213 |
|
// since |decodeURIComponent| might throw. |
| 214 |
|
if (!document.webhaccNavigated) { |
| 215 |
|
var fragment = location.hash; |
| 216 |
|
if (fragment) { |
| 217 |
|
var id = decodeURIComponent (fragment.substring (1)); |
| 218 |
|
showTab (id); |
| 219 |
|
var el = document.getElementById (id); |
| 220 |
|
if (el) el.scrollIntoView (); |
| 221 |
|
} else if (document.webhaccSections['result-summary']) { |
| 222 |
|
showTab ('result-summary'); |
| 223 |
|
} else { |
| 224 |
|
showTab ('input'); |
| 225 |
|
} |
| 226 |
|
} |
| 227 |
|
} // onbodyload |
| 228 |
|
|
| 229 |
// $Date$ |
// $Date$ |