+ var subset = file.slice(offset, offset + 36);
+ reader.readAsArrayBuffer(subset);
+ }
+
+ 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(atom));
+ if (file.size > offset + length)
+ checkForAtom(offset + length);
+ };
+ var subset = file.slice(offset, offset + length);
+ reader.readAsArrayBuffer(subset);
+ }
+
+ checkForAtom(0);
+ }
+ function toDOMRepresentation(object)
+ {
+ if (object instanceof Atom)
+ return toDOMNode(object);
+ 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) {
+ span.appendChild(toDOMRepresentation(object[i]));
+ if (i + 1 < object.length)
+ span.appendChild(document.createTextNode(', '));
+ }
+ span.appendChild(document.createTextNode(']'));
+ return span;
+ }
+ else if (typeof(object) == "string")
+ return document.createTextNode('"' + object + '"');
+ else if (object instanceof Date)
+ return document.createTextNode(object.toLocaleString());
+ 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());