X-Git-Url: http://105106.c2e0p.group/movie_parser.git/blobdiff_plain/49dd866a06288856e4a1d5df3f00a6a0fccea2fa..9114b5c6a1b71b9c3007b44d69acf3b886861a4d:/AtomTester.html diff --git a/AtomTester.html b/AtomTester.html index 2617264..78587ca 100644 --- a/AtomTester.html +++ b/AtomTester.html @@ -13,39 +13,38 @@ var reader = new FileReader(); output.innerHTML = ''; - function checkForMoovAtom(offset) { + function checkForAtom(offset) { reader.onload = function(e) { - var result = e.target.result; - var basicAtom = new Atom(result); - if (!basicAtom) - return; - else if (basicAtom.type == 'moov') - readMoovAtom(offset, basicAtom.size); - else - checkForMoovAtom(offset + basicAtom.size); + var atom = new Atom(e.target.result); + if (atom) + readAtom(offset, atom.size); }; var subset = file.slice(offset, offset + 16); reader.readAsArrayBuffer(subset); - }; - - function readMoovAtom(offset, length) { - reader.onload = function(e) { - moovAtom = Atom.create(e.target.result); + } + + function readAtom(offset, length) { + reader.onload = function(e) { + atom = Atom.create(e.target.result); + if (!atom) + return; var output = document.getElementById('output'); - output.appendChild(toDOMNode(moovAtom)); + output.appendChild(toDOMNode(atom)); + if (file.size > offset + length) + checkForAtom(offset + length); }; var subset = file.slice(offset, offset + length); reader.readAsArrayBuffer(subset); - }; + } - checkForMoovAtom(0); + checkForAtom(0); } function toDOMRepresentation(object) { if (object instanceof Atom) return toDOMNode(object); - else if (object instanceof Array) { + else if (object instanceof Array || object instanceof Uint32Array) { var span = document.createElement('span'); span.appendChild(document.createTextNode('[')); for (var i = 0; i < object.length; ++i) { @@ -67,6 +66,13 @@ function toDOMNode(object) { var output = document.createElement('dl'); + + if (typeof(object.description) == 'string') { + var div = document.createElement('div'); + div.classList.add('description'); + div.appendChild(document.createTextNode(object.description)); + output.appendChild(div); + } for (property in object) { var value = object[property]; @@ -98,6 +104,7 @@ dt, dd { display: inline-block; min-width: 8em; } dd { margin-left: 1em; } + .description { text-align: center; font-weight: bold; } /* make the output display as a table */ /*