]> 105106.c2e0p.group Git - movie_parser.git/blobdiff - AtomTester.html
Added SyncSampleAtom, TimeToSampleAtom, and a new base Atom, VersionFlagsAtom, on...
[movie_parser.git] / AtomTester.html
index 789e24633336267030f319cbd398e8787206729f..04199880eaf42f8b2120f540b5b397d14016d519 100644 (file)
             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;
                     }
                 };
             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);
         }
     </script>
+    <style>
+        dl { border: 1px solid black; }
+        dt, dd { display: inline; }
+        dt:after { content:": " }
+        dd:after { content:"\A"; white-space:pre; }
+        dd dl { margin: 0; vertical-align: top }
+        
+        /* make the output display as a table */
+        dl { display: table; }
+        dl div { display: table-row; }
+        dt, dd { display: table-cell; }
+    </style>
 </head>
 <body id="atomtester" onload="setup()">
     <input type="file" id="file" name="file" />
+    <div id=output>
 </body>
\ No newline at end of file