Parent Directory
|
Revision Log
Support for w(innerHTML) dumpping
| 1 | <!DOCTYPE HTML> |
| 2 | <html lang=en> |
| 3 | <head> |
| 4 | <title>Live Scripting HTML Parser</title> |
| 5 | <link rel=author href="http://suika.fam.cx/~wakaba/who?"> |
| 6 | <link rel=license href="http://suika.fam.cx/c/gnu/gpl" |
| 7 | title="GNU GPL2 or later"> |
| 8 | <style> |
| 9 | h1 { |
| 10 | margin: 0; |
| 11 | font-size: 150%; |
| 12 | } |
| 13 | h2 { |
| 14 | margin: 0; |
| 15 | font-size: 100%; |
| 16 | } |
| 17 | p { |
| 18 | margin: 0 1em; |
| 19 | } |
| 20 | textarea { |
| 21 | width: 100%; |
| 22 | -width: 99%; |
| 23 | height: 10em; |
| 24 | } |
| 25 | output { |
| 26 | display: block; |
| 27 | font-family: monospace; |
| 28 | white-space: -moz-pre-wrap; |
| 29 | white-space: pre-wrap; |
| 30 | } |
| 31 | </style> |
| 32 | <script> |
| 33 | var delayedUpdater = 0; |
| 34 | |
| 35 | function update () { |
| 36 | if (delayedUpdater) { |
| 37 | clearTimeout (delayedUpdater); |
| 38 | delayedUpdater = 0; |
| 39 | } |
| 40 | delayedUpdater = setTimeout (update2, 100); |
| 41 | } // update |
| 42 | |
| 43 | function update2 () { |
| 44 | var v = document.sourceElement.value; |
| 45 | if (v != document.previousSourceText) { |
| 46 | document.previousSourceText = v; |
| 47 | document.links['permalink'].href |
| 48 | = location.pathname + '?s=' + encodeURIComponent (v); |
| 49 | document.links['ldvlink'].href |
| 50 | = 'http://software.hixie.ch/utilities/js/live-dom-viewer/?' |
| 51 | + encodeURIComponent (v); |
| 52 | |
| 53 | document.logElement.textContent = ''; |
| 54 | var p = new Parser (new InputStream (v)); |
| 55 | var doc = p.doc; |
| 56 | p.parse (); |
| 57 | |
| 58 | log (dumpTree (doc, '')); |
| 59 | |
| 60 | if (p.hasAsyncScript) { |
| 61 | log ('Some script codes are executed asynchronously; it means that the document might be rendered in different ways depending on the network condition and other factors'); |
| 62 | } |
| 63 | } |
| 64 | } // update2 |
| 65 | |
| 66 | var logIndentLevel = 0; |
| 67 | function log (s) { |
| 68 | var indent = ''; |
| 69 | for (var i = 0; i < logIndentLevel; i++) { |
| 70 | indent += ' '; |
| 71 | } |
| 72 | s = indent + s.replace (/\n/g, "\n" + indent); |
| 73 | document.logElement.appendChild (document.createTextNode (s + "\n")); |
| 74 | } // log |
| 75 | |
| 76 | function InputStream (s) { |
| 77 | this.s = s; |
| 78 | } // InputStream |
| 79 | |
| 80 | function Parser (i, doc) { |
| 81 | this.parseMode = 'pcdata'; |
| 82 | if (!doc) { |
| 83 | doc = new JSDocument (this); |
| 84 | doc.manakaiIsHTML = true; |
| 85 | } |
| 86 | this.doc = doc; |
| 87 | this.openElements = [doc]; |
| 88 | this.input = i; |
| 89 | this.scriptsExecutedAfterParsing = []; |
| 90 | this.scriptsExecutedSoon = []; |
| 91 | this.scriptsExecutedAsynchronously = []; |
| 92 | } // Parser |
| 93 | |