]> id.pley.net Git - movie_parser.git/blobdiff - AtomTester.html
Added tkhd, mdhd atoms. Added getAtomByType and getAtomsByType.
[movie_parser.git] / AtomTester.html
index 82d9be2727d03348c6799746eb4012bf8201a5c8..04199880eaf42f8b2120f540b5b397d14016d519 100644 (file)
@@ -17,7 +17,7 @@
                         if (!atom)
                             break;
                         atoms.push(atom);
                         if (!atom)
                             break;
                         atoms.push(atom);
-                        output.appendChild(atom.toDOMNode());
+                        output.appendChild(toDOMNode(atom));
                         offset += atom.size;
                     }
                 };
                         offset += atom.size;
                     }
                 };
             reader.readAsArrayBuffer(file);
         }
         
             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);
         }
         function setup() {
             document.getElementById('file').addEventListener('change', onFileSelect, false);
         }
@@ -34,7 +66,7 @@
         dt, dd { display: inline; }
         dt:after { content:": " }
         dd:after { content:"\A"; white-space:pre; }
         dt, dd { display: inline; }
         dt:after { content:": " }
         dd:after { content:"\A"; white-space:pre; }
-        dd ol { display: inline-block; margin: 0; vertical-align: top }
+        dd dl { margin: 0; vertical-align: top }
         
         /* make the output display as a table */
         dl { display: table; }
         
         /* make the output display as a table */
         dl { display: table; }