Parent Directory
|
Revision Log
|
Patch
| revision 1.4 by wakaba, Sun Apr 20 12:19:13 2008 UTC | revision 1.12 by wakaba, Sun Apr 27 11:21:09 2008 UTC | |
|---|---|---|
| # | Line 1 | Line 1 |
| 1 | <!DOCTYPE HTML> | <!DOCTYPE HTML> |
| 2 | <html lang=en> | <html lang=en> |
| 3 | <head> | <head> |
| 4 | <title>Demo of HTML5 Parsing Algorithm with Scripting Enabled</title> | <title>Live Scripting HTML Parser</title> |
| 5 | <style> | <style> |
| 6 | h1, h2 { | |
| 7 | margin: 0; | |
| 8 | font-size: 100%; | |
| 9 | } | |
| 10 | p, pre { | |
| 11 | margin: 0; | |
| 12 | } | |
| 13 | textarea { | textarea { |
| 14 | display: block; | width: 100%; |
| 15 | width: 80%; | -width: 99%; |
| 16 | margin-left: auto; | height: 10em; |
| margin-right: auto; | ||
| min-height: 20em; | ||
| 17 | } | } |
| 18 | output { | output { |
| 19 | display: block; | display: block; |
| # | Line 18 | Line 23 |
| 23 | } | } |
| 24 | </style> | </style> |
| 25 | <script> | <script> |
| 26 | var delayedUpdater = 0; | |
| 27 | ||
| 28 | function update () { | function update () { |
| 29 | document.logElement.textContent = ''; | if (delayedUpdater) { |
| 30 | var p = new Parser (new InputStream (document.sourceElement.value)); | clearTimeout (delayedUpdater); |
| 31 | var doc = p.doc; | delayedUpdater = 0; |
| 32 | p.parse (); | } |
| 33 | log (dumpTree (doc, '')); | delayedUpdater = setTimeout (update2, 100); |
| 34 | } // update | } // update |
| 35 | ||
| 36 | function update2 () { | |
| 37 | var v = document.sourceElement.value; | |
| 38 | if (v != document.previousSourceText) { | |
| 39 | document.previousSourceText = v; | |
| 40 | document.links['permalink'].href | |
| 41 | = location.pathname + '?s=' + encodeURIComponent (v); | |
| 42 | document.links['ldvlink'].href | |
| 43 | = 'http://software.hixie.ch/utilities/js/live-dom-viewer/?' | |
| 44 | + encodeURIComponent (v); | |
| 45 | ||
| 46 | document.logElement.textContent = ''; | |
| 47 | var p = new Parser (new InputStream (v)); | |
| 48 | var doc = p.doc; | |
| 49 | p.parse (); | |
| 50 | ||
| 51 | log (dumpTree (doc, '')); | |
| 52 | ||
| 53 | if (p.hasAsyncScript) { | |
| 54 | 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'); | |
| 55 | } | |
| 56 | } | |
| 57 | } // update2 | |
| 58 | ||
| 59 | var logIndentLevel = 0; | |
| 60 | function log (s) { | function log (s) { |
| 61 | for (var i = 0; i < logIndentLevel; i++) { | |
| 62 | s = ' ' + s; | |
| 63 | } | |
| 64 | document.logElement.appendChild (document.createTextNode (s + "\n")); | document.logElement.appendChild (document.createTextNode (s + "\n")); |
| 65 | } // log | } // log |
| 66 | ||
| # | Line 42 | Line 76 |
| 76 | } | } |
| 77 | this.doc = doc; | this.doc = doc; |
| 78 | this.openElements = [doc]; | this.openElements = [doc]; |
| 79 | this.in = i; | this.input = i; |