changeset 2614:ae5e8818eff0

#101. Updated specification.js
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 15 Nov 2016 09:52:16 +0000
parents 4c04933c15ed
children 8b8f3f3ce68e
files js/specification.js
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/js/specification.js	Tue Nov 15 09:45:42 2016 +0000
+++ b/js/specification.js	Tue Nov 15 09:52:16 2016 +0000
@@ -781,6 +781,8 @@
             this.label = null;
             this.startTime = undefined;
             this.stopTime = undefined;
+            this.sampleRate = undefined;
+            this.alternatives = [];
             this.schema = specification.schema.getAllElementsByName('audioelement')[0];;
             this.parent = null;
             this.decode = function (parent, xml) {
@@ -800,6 +802,17 @@
                             break;
                     }
                 }
+                // Get the alternative nodes
+                var child = xml.firstElementChild;
+                while (child) {
+                    if (child.nodeName == "alternative") {
+                        this.alternatives.push({
+                            'url': child.getAttribute("url"),
+                            'sampleRate': child.getAttribute("sampleRate")
+                        });
+                    }
+                    child = child.nextElementSibling;
+                }
 
             };
             this.encode = function (root) {
@@ -814,6 +827,12 @@
                         eval("AENode.setAttribute('" + name + "',this." + name + ")");
                     }
                 }
+                this.alternatives.forEach(function (alt) {
+                    var node = root.createElement("alternative");
+                    node.setAttribute("url", alt.url);
+                    node.setAttribute("sampleRate", alt.sampleRate);
+                    AENode.appendChild(node);
+                });
                 return AENode;
             };
         };