X-Git-Url: http://id.pley.net/movie_parser.git/blobdiff_plain/9114b5c6a1b71b9c3007b44d69acf3b886861a4d..b73211b4d80bf99a6cbb870c33a1d1a3afc8fbce:/AtomTester.html?ds=inline diff --git a/AtomTester.html b/AtomTester.html index 78587ca..5d1d4de 100644 --- a/AtomTester.html +++ b/AtomTester.html @@ -15,11 +15,13 @@ function checkForAtom(offset) { reader.onload = function(e) { - var atom = new Atom(e.target.result); - if (atom) + var atom = new Atom(); + if (atom) { + atom.parse(e.target.result, 0); readAtom(offset, atom.size); + } }; - var subset = file.slice(offset, offset + 16); + var subset = file.slice(offset, offset + 36); reader.readAsArrayBuffer(subset); } @@ -39,7 +41,6 @@ checkForAtom(0); } - function toDOMRepresentation(object) { if (object instanceof Atom) @@ -59,7 +60,13 @@ return document.createTextNode('"' + object + '"'); else if (object instanceof Date) return document.createTextNode(object.toLocaleString()); - else + else if (object instanceof Uint8Array) { + return Uint8ArrayNode(object); + } else if (object instanceof Object) + return toDOMNode(object); + else if (object === null) + return document.createTextNode('[null]'); + else return document.createTextNode(object.toString()); } @@ -89,6 +96,29 @@ } return output; } + + function Uint8ArrayNode(array) + { + var table = document.createElement('table'); + var width = 16; + for (var offset = 0; offset <= array.length; offset += width) { + var tr = document.createElement('tr'); + table.appendChild(tr); + + var th = document.createElement('th'); + tr.appendChild(th); + th.innerText = ('0000000' + offset.toString(16)).substr(-8) + ':'; + + for (var column = 0; column < width && offset + column < array.length; column += 2) { + var td = document.createElement('td'); + tr.appendChild(td); + td.innerText = ('00' + array[offset + column].toString(16)).substr(-2); + if (offset + column + 1 < array.length) + td.innerText += ('00' + array[offset + column + 1].toString(16)).substr(-2); + } + } + return table; + } function setup() { document.getElementById('file').addEventListener('change', onFileSelect, false); @@ -102,8 +132,9 @@ dd dl { margin: 0; vertical-align: top } dd span { display: inline-block; vertical-align: top; } - dt, dd { display: inline-block; min-width: 8em; } + dt, dd { display: inline-block; min-width: 14em; } dd { margin-left: 1em; } + dd th { font-weight: normal; text-align: right; } .description { text-align: center; font-weight: bold; } /* make the output display as a table */