Mercurial > urweb
comparison lib/js/urweb.js @ 901:f17638dd3080
dlist row add working with Konqueror
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 06 Aug 2009 14:24:40 -0400 |
parents | ed381288ce9a |
children | 4b9f1de2c647 |
comparison
equal
deleted
inserted
replaced
900:ed381288ce9a | 901:f17638dd3080 |
---|---|
250 eval(thisScript.textContent); | 250 eval(thisScript.textContent); |
251 } catch (v) { | 251 } catch (v) { |
252 doExn(v); | 252 doExn(v); |
253 } | 253 } |
254 if (thisScript.parentNode) | 254 if (thisScript.parentNode) |
255 thisScripts.parentNode.removeChild(thisScript); | 255 thisScript.parentNode.removeChild(thisScript); |
256 } | 256 } |
257 | 257 |
258 thisScript = savedScript; | 258 thisScript = savedScript; |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 | 262 |
263 // Dynamic tree entry points | 263 // Dynamic tree entry points |
264 | 264 |
265 function dyn(s) { | 265 function dyn(pnode, s) { |
266 var x = document.createElement("div"); | 266 var x = document.createElement("script"); |
267 x.style.display = "inline"; | |
268 x.dead = false; | 267 x.dead = false; |
269 x.signal = s; | 268 x.signal = s; |
270 x.sources = null; | 269 x.sources = null; |
271 x.closures = null; | 270 x.closures = null; |
272 | 271 |
273 var first = null; | 272 var child = null; |
274 | 273 |
275 x.recreate = function(v) { | 274 x.recreate = function(v) { |
276 for (var ls = x.closures; ls; ls = ls.next) | 275 for (var ls = x.closures; ls; ls = ls.next) |
277 freeClosure(ls.data); | 276 freeClosure(ls.data); |
278 | 277 |
279 for (var node = first; node && node != x; ) { | 278 if (child) { |
280 if (node.getElementsByTagName) { | 279 if (child.getElementsByTagName) { |
281 var arr = node.getElementsByTagName("div"); | 280 var arr = child.getElementsByTagName("script"); |
282 for (var i = 0; i < arr.length; ++i) { | 281 for (var i = 0; i < arr.length; ++i) { |
283 var span = arr[i]; | 282 var span = arr[i]; |
284 span.dead = true; | 283 span.dead = true; |
285 for (var ls = span.sources; ls; ls = ls.next) | 284 for (var ls = span.sources; ls; ls = ls.next) |
286 ls.data.dyns = remove(span, ls.data.dyns); | 285 ls.data.dyns = remove(span, ls.data.dyns); |
287 for (var ls = span.closures; ls; ls = ls.next) | 286 for (var ls = span.closures; ls; ls = ls.next) |
288 freeClosure(ls.data); | 287 freeClosure(ls.data); |
289 } | 288 } |
290 } | 289 } |
291 | 290 |
292 var old = node; | 291 if (child.parentNode) |
293 node = node.nextSibling; | 292 child.parentNode.removeChild(child); |
294 if (old.parentNode) | |
295 old.parentNode.removeChild(old); | |
296 } | 293 } |
297 | 294 |
298 var cls = {v : null}; | 295 var cls = {v : null}; |
299 var dummy = document.createElement("table"); | 296 var html = flatten(cls, v); |
300 dummy.innerHTML = flatten(cls, v); | |
301 x.closures = cls.v; | 297 x.closures = cls.v; |
302 runScripts(dummy); | 298 |
303 | 299 if (pnode == "table") { |
304 for (first = dummy.firstChild; first && first.tagName == "TBODY"; first = first.firstChild); | 300 var dummy = document.createElement("body"); |
305 for (var node = first; node; ) { | 301 dummy.innerHTML = "<table>" + html + "</table>"; |
306 var old = node; | 302 runScripts(dummy); |
307 node = node.nextSibling; | 303 var rows = dummy.firstChild.rows; |
304 var nRows = rows.length; | |
305 var table = x.parentNode; | |
306 | |
307 var arr = dummy.getElementsByTagName("tbody"); | |
308 if (arr.length > 0) { | |
309 var tbody = arr[0], next; | |
310 for (var node = tbody.firstChild; node; node = next) { | |
311 next = node.nextSibling; | |
312 table.appendChild(node); | |
313 } | |
314 } | |
315 } else { | |
316 child = document.createElement("span"); | |
317 child.innerHTML = html; | |
318 runScripts(child); | |
308 if (x.parentNode) | 319 if (x.parentNode) |
309 x.parentNode.insertBefore(old, x); | 320 x.parentNode.insertBefore(child, x); |
310 } | 321 } |
311 }; | 322 }; |
312 | 323 |
313 addNode(x); | 324 addNode(x); |
314 populate(x); | 325 populate(x); |