Mercurial > hg > webaudioevaluationtool
comparison test_create/test_core.js @ 2908:9c26e579e64d
Test create supports template XMLs. Added ITU-R BS.1116 template.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Tue, 01 Aug 2017 09:13:57 +0100 |
parents | a1e294297380 |
children | e2b241c88b74 |
comparison
equal
deleted
inserted
replaced
2907:a1e294297380 | 2908:9c26e579e64d |
---|---|
151 } | 151 } |
152 }]); | 152 }]); |
153 | 153 |
154 AngularInterface.controller("introduction", ['$scope', '$element', '$window', function ($s, $e, $w) { | 154 AngularInterface.controller("introduction", ['$scope', '$element', '$window', function ($s, $e, $w) { |
155 $s.state = 0; | 155 $s.state = 0; |
156 $s.selected = undefined; | |
156 $s.next = function () { | 157 $s.next = function () { |
157 $s.state++; | 158 $s.state++; |
158 if ($s.state > 1 || $s.file) { | 159 if ($s.state > 1 || $s.file) { |
159 $s.hidePopup(); | 160 $s.hidePopup(); |
161 $s.initialise($s.selected); | |
160 } | 162 } |
161 }; | 163 }; |
162 $s.back = function () { | 164 $s.back = function () { |
163 $s.state--; | 165 $s.state--; |
164 }; | 166 }; |
175 return i.name == name; | 177 return i.name == name; |
176 }); | 178 }); |
177 if (obj === undefined) { | 179 if (obj === undefined) { |
178 throw ("Cannot find specification"); | 180 throw ("Cannot find specification"); |
179 } | 181 } |
180 $s.setTestPrototype(obj); | 182 if (typeof obj.template === "string") { |
181 }; | 183 get(obj.template).then(function (data) { |
182 // Get the test interface specifications | 184 $s.parseFile(data); |
185 }, function (err) {}) | |
186 } else { | |
187 $s.setTestPrototype(obj); | |
188 } | |
189 }; | |
190 $s.select = function (name) { | |
191 $s.selected = name; | |
192 } | |
193 // Get the test interface specifications | |
183 $s.file = undefined; | 194 $s.file = undefined; |
184 $s.description = ""; | 195 $s.description = ""; |
196 | |
197 $s.parseFile = function (f) { | |
198 var p = new DOMParser(); | |
199 specification.decode(p.parseFromString(f, "text/xml")); | |
200 $s.$apply(); | |
201 } | |
185 | 202 |
186 $s.handleFiles = function ($event) { | 203 $s.handleFiles = function ($event) { |
187 $s.file = $event.currentTarget.files[0]; | 204 $s.file = $event.currentTarget.files[0]; |
188 var r = new FileReader(); | 205 var r = new FileReader(); |
189 r.onload = function () { | 206 r.onload = function () { |
190 var p = new DOMParser(); | 207 $s.parseFile(r.result); |
191 specification.decode(p.parseFromString(r.result, "text/xml")); | |
192 $s.$apply(); | |
193 }; | 208 }; |
194 r.readAsText($s.file); | 209 r.readAsText($s.file); |
195 }; | 210 }; |
196 }]); | 211 }]); |
197 | 212 |
240 $s.configure = function () {} | 255 $s.configure = function () {} |
241 | 256 |
242 $s.$watch("selectedTestPrototype", $s.configure); | 257 $s.$watch("selectedTestPrototype", $s.configure); |
243 | 258 |
244 $s.placeholder = function (name) { | 259 $s.placeholder = function (name) { |
245 var spec = $s.schema.querySelector("attribute[name=\"" + name + "\"]") || $w.specification.schema.querySelector("attribute[name=\"" + name + "\"]"); | 260 if ($s.schema) { |
246 var attr = spec.getAttribute("default"); | 261 var spec = $s.schema.querySelector("attribute[name=\"" + name + "\"]") || $w.specification.schema.querySelector("attribute[name=\"" + name + "\"]"); |
247 if (attr === undefined) { | 262 var attr = spec.getAttribute("default"); |
248 return ""; | 263 if (attr === undefined) { |
249 } | 264 return ""; |
250 return attr; | 265 } |
266 return attr; | |
267 } | |
251 } | 268 } |
252 }]); | 269 }]); |
253 | 270 |
254 AngularInterface.controller("survey", ['$scope', '$element', '$window', function ($s, $e, $w) { | 271 AngularInterface.controller("survey", ['$scope', '$element', '$window', function ($s, $e, $w) { |
255 $s.addSurveyEntry = function () { | 272 $s.addSurveyEntry = function () { |