X-Git-Url: http://id.pley.net/movie_parser.git/blobdiff_plain/86cb3dcb7102f7c715c323bbd1c62f4f136ddfab..48b43d25b544737831d2252f6af2a64c0861180b:/AtomTester.html?ds=sidebyside diff --git a/AtomTester.html b/AtomTester.html index 789e246..0419988 100644 --- a/AtomTester.html +++ b/AtomTester.html @@ -10,11 +10,14 @@ reader.onload = (function(file) { return function(e) { var offset = 0; + var output = document.getElementById('output'); + output.innerHTML = ''; while (offset < e.target.result.byteLength) { - var atom = new Atom(e.target.result, offset); + var atom = Atom.create(e.target.result, offset); if (!atom) break; atoms.push(atom); + output.appendChild(toDOMNode(atom)); offset += atom.size; } }; @@ -22,11 +25,56 @@ reader.readAsArrayBuffer(file); } + function toDOMNode(object) + { + var output = document.createElement('dl'); + + for (property in object) { + var value = object[property]; + if (typeof(value) == 'function') + continue; + var div = document.createElement('div'); + var dt = document.createElement('dt'); + dt.innerText = property; + + var dd = document.createElement('dd'); + if (value instanceof Atom) + dd.appendChild(toDOMNode(value)); + else if (value instanceof Array) { + dd.appendChild(toDOMNode(value)); + } + else if (typeof(value) == "string") + dd.innerText = '"' + value + '"'; + else if (value instanceof Date) + dd.innerText = value.toLocaleString(); + else + dd.innerText = value; + + div.appendChild(dt); + div.appendChild(dd); + output.appendChild(div); + } + return output; + } + function setup() { document.getElementById('file').addEventListener('change', onFileSelect, false); } +
+