annotate test_create/test_core.js @ 2911:bcb741f60298

#222 More dropdown labels and help
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Tue, 01 Aug 2017 11:57:16 +0100
parents e2b241c88b74
children 7b6cdd27f3ee
rev   line source
nicholas@2885 1 /* globals document, angular, window, Promise, XMLHttpRequest, Specification, XMLSerializer, Blob, DOMParser, FileReader, $*/
nicholas@2851 2 function get(url) {
nicholas@2851 3 // Return a new promise.
nicholas@2851 4 return new Promise(function (resolve, reject) {
nicholas@2851 5 // Do the usual XHR stuff
nicholas@2851 6 var req = new XMLHttpRequest();
nicholas@2851 7 req.open('GET', url);
nickjillings@1370 8
nicholas@2851 9 req.onload = function () {
nicholas@2851 10 // This is called even on 404 etc
nicholas@2851 11 // so check the status
nicholas@2851 12 if (req.status == 200) {
nicholas@2851 13 // Resolve the promise with the response text
nicholas@2851 14 resolve(req.response);
nicholas@2851 15 } else {
nicholas@2851 16 // Otherwise reject with the status text
nicholas@2851 17 // which will hopefully be a meaningful error
nicholas@2851 18 reject(Error(req.statusText));
nicholas@2851 19 }
nicholas@2851 20 };
nicholas@2851 21
nicholas@2851 22 // Handle network errors
nicholas@2851 23 req.onerror = function () {
nicholas@2851 24 reject(Error("Network Error"));
nicholas@2851 25 };
nicholas@2851 26
nicholas@2851 27 // Make the request
nicholas@2851 28 req.send();
nicholas@2851 29 });
nickjillings@1370 30 }
nickjillings@1370 31
nicholas@2851 32 var AngularInterface = angular.module("creator", []);
nickjillings@1370 33
nicholas@2851 34 var specification = new Specification();
nickjillings@1370 35
nicholas@2535 36 window.onload = function () {
nicholas@2851 37 // Get the test interface specifications
n@2911 38 toggleDropdowns();
n@2911 39 };
n@2911 40
n@2911 41 function toggleDropdowns() {
nicholas@2884 42 $(function () {
nicholas@2884 43 $('[data-toggle="popover"]').popover();
nicholas@2884 44 });
n@2911 45 }
nicholas@2535 46
nicholas@2861 47 function handleFiles(event) {
nicholas@2861 48 var s = angular.element(event.currentTarget).scope();
nicholas@2861 49 s.handleFiles(event);
nicholas@2861 50 s.$apply();
nicholas@2861 51 }
nicholas@2861 52
nicholas@2851 53 AngularInterface.controller("view", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2851 54 $s.popupVisible = true;
nicholas@2864 55 $s.testSpecifications = {};
nicholas@2864 56
nicholas@2864 57 (function () {
nicholas@2864 58 new Promise(function (resolve, reject) {
nicholas@2864 59 var xml = new XMLHttpRequest();
nicholas@2864 60 xml.open("GET", "test_create/interfaces/specifications.json");
nicholas@2864 61 xml.onload = function () {
nicholas@2864 62 if (xml.status === 200) {
nicholas@2864 63 resolve(xml.responseText);
nicholas@2864 64 return;
nicholas@2864 65 }
nicholas@2864 66 reject(xml.status);
nicholas@2864 67 };
nicholas@2864 68 xml.onerror = function () {
nicholas@2864 69 reject(new Error("Network Error"));
nicholas@2864 70 };
nicholas@2864 71 xml.send();
nicholas@2864 72 }).then(JSON.parse).then(function (data) {
nicholas@2864 73 $s.testSpecifications = data;
nicholas@2864 74 $s.$apply();
nicholas@2865 75 });
nicholas@2864 76 })();
nickjillings@1370 77
nicholas@2851 78 $s.showPopup = function () {
nicholas@2851 79 $s.popupVisible = true;
nicholas@2851 80 };
nicholas@2851 81 $s.hidePopup = function () {
nicholas@2851 82 $s.popupVisible = false;
nicholas@2851 83 };
nicholas@2851 84 $s.globalSchema = undefined;
nicholas@2851 85 get("xml/test-schema.xsd").then(function (text) {
nicholas@2851 86 specification.processSchema(text);
nicholas@2851 87 $s.globalSchema = specification.getSchema();
nicholas@2851 88 });
nicholas@2851 89 $s.specification = specification;
nicholas@2886 90 $s.selectedTestPrototype = undefined;
nicholas@2886 91 $s.setTestPrototype = function (obj) {
nicholas@2886 92 $s.selectedTestPrototype = obj;
nicholas@2886 93 $w.specification.interface = obj.interface;
nicholas@2886 94 }
nicholas@2857 95
nicholas@2857 96 $s.addPage = function () {
nicholas@2857 97 $s.specification.createNewPage();
nicholas@2859 98 };
nicholas@2860 99
nicholas@2862 100 $s.removePage = function (page) {
nicholas@2862 101 var index = $s.specification.pages.findIndex(function (a) {
nicholas@2862 102 return a == page;
nicholas@2862 103 });
nicholas@2862 104 if (index === -1) {
nicholas@2862 105 throw ("Invalid Page");
nicholas@2862 106 }
nicholas@2862 107 $s.specification.pages.splice(index, 1);
nicholas@2862 108 };
nicholas@2862 109
nicholas@2860 110 $s.exportXML = function () {
nicholas@2860 111 var s = new XMLSerializer();
nicholas@2860 112 var doc = specification.encode();
nicholas@2891 113 var xmlstr = s.serializeToString(doc);
nicholas@2860 114 var bb = new Blob([s.serializeToString(doc)], {
nicholas@2860 115 type: 'application/xml'
nicholas@2860 116 });
nicholas@2860 117 var dnlk = window.URL.createObjectURL(bb);
nicholas@2891 118 var a = document.createElement("a");
nicholas@2891 119 a.href = dnlk;
nicholas@2891 120 a.download = "test.xml";
nicholas@2891 121 a.click();
nicholas@2891 122 window.URL.revokeObjectURL(dnlk);
nicholas@2861 123 };
nicholas@2887 124 $s.validated = false;
nicholas@2887 125 $s.showValidationMessages = false;
nicholas@2887 126 $s.validate = function () {
nicholas@2887 127 var s = new XMLSerializer();
nicholas@2887 128 var Module = {
nicholas@2887 129 xml: s.serializeToString(specification.encode()),
nicholas@2887 130 schema: specification.getSchemaString(),
nicholas@2887 131 arguments: ["--noout", "--schema", 'test-schema.xsd', 'document.xml']
nicholas@2887 132 };
nicholas@2887 133 var xmllint = validateXML(Module);
nicholas@2887 134 console.log(xmllint);
nicholas@2887 135 if (xmllint != 'document.xml validates\n') {
nicholas@2887 136 $s.validated = false;
nicholas@2887 137 var list = $e[0].querySelector("#validation-error-list");
nicholas@2887 138 while (list.firstChild) {
nicholas@2887 139 list.removeChild(list.firstChild);
nicholas@2887 140 }
nicholas@2887 141 var errors = xmllint.split('\n');
nicholas@2887 142 errors = errors.slice(0, errors.length - 2);
nicholas@2887 143 errors.forEach(function (str) {
nicholas@2887 144 var li = document.createElement("li");
nicholas@2887 145 li.textContent = str;
nicholas@2887 146 list.appendChild(li);
nicholas@2887 147 });
nicholas@2887 148 } else {
nicholas@2887 149 $s.validated = true;
nicholas@2887 150 }
nicholas@2887 151 $s.showValidationMessages = true;
nicholas@2887 152 }
nicholas@2887 153 $s.hideValidationMessages = function () {
nicholas@2887 154 $s.showValidationMessages = false;
nicholas@2887 155 }
n@2911 156 $s.$watch(function () {
n@2911 157 return document.querySelectorAll("div.pageNode").length;
n@2911 158 }, $w.toggleDropdowns);
n@2911 159 $s.$watch(function () {
n@2911 160 return document.querySelectorAll("div.surveyentry").length;
n@2911 161 }, $w.toggleDropdowns);
n@2911 162 $s.$watch(function () {
n@2911 163 return document.querySelectorAll("div.interface").length;
n@2911 164 }, $w.toggleDropdowns);
n@2911 165 $s.$watch(function () {
n@2911 166 return document.querySelectorAll("div.audioelement").length;
n@2911 167 }, $w.toggleDropdowns);
nicholas@2851 168 }]);
nickjillings@1370 169
nicholas@2851 170 AngularInterface.controller("introduction", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2851 171 $s.state = 0;
n@2908 172 $s.selected = undefined;
nicholas@2851 173 $s.next = function () {
nicholas@2851 174 $s.state++;
nicholas@2861 175 if ($s.state > 1 || $s.file) {
nicholas@2851 176 $s.hidePopup();
n@2908 177 $s.initialise($s.selected);
nicholas@2851 178 }
nicholas@2851 179 };
nicholas@2851 180 $s.back = function () {
nicholas@2851 181 $s.state--;
nicholas@2851 182 };
nicholas@2851 183 $s.mouseover = function (name) {
nicholas@2864 184 var obj = $s.testSpecifications.interfaces.find(function (i) {
nicholas@2851 185 return i.name == name;
nicholas@2851 186 });
nicholas@2851 187 if (obj) {
nicholas@2851 188 $s.description = obj.description.en;
nicholas@2851 189 }
nicholas@2851 190 };
nicholas@2851 191 $s.initialise = function (name) {
nicholas@2885 192 var obj = $s.testSpecifications.interfaces.find(function (i) {
nicholas@2851 193 return i.name == name;
nicholas@2851 194 });
nicholas@2886 195 if (obj === undefined) {
nicholas@2886 196 throw ("Cannot find specification");
nicholas@2886 197 }
n@2908 198 if (typeof obj.template === "string") {
n@2908 199 get(obj.template).then(function (data) {
n@2908 200 $s.parseFile(data);
n@2908 201 }, function (err) {})
n@2908 202 } else {
n@2908 203 $s.setTestPrototype(obj);
n@2908 204 }
nicholas@2851 205 };
n@2908 206 $s.select = function (name) {
n@2908 207 $s.selected = name;
n@2908 208 }
n@2908 209 // Get the test interface specifications
nicholas@2861 210 $s.file = undefined;
nicholas@2851 211 $s.description = "";
nicholas@2861 212
n@2908 213 $s.parseFile = function (f) {
n@2908 214 var p = new DOMParser();
n@2908 215 specification.decode(p.parseFromString(f, "text/xml"));
n@2908 216 $s.$apply();
n@2908 217 }
n@2908 218
nicholas@2861 219 $s.handleFiles = function ($event) {
nicholas@2861 220 $s.file = $event.currentTarget.files[0];
nicholas@2861 221 var r = new FileReader();
nicholas@2861 222 r.onload = function () {
n@2908 223 $s.parseFile(r.result);
nicholas@2862 224 };
nicholas@2861 225 r.readAsText($s.file);
nicholas@2861 226 };
nicholas@2851 227 }]);
nickjillings@1370 228
nicholas@2851 229 AngularInterface.controller("setup", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2851 230 function initialise() {
nicholas@2851 231 if ($s.globalSchema) {
nicholas@2851 232 $s.schema = $s.globalSchema.querySelector("[name=setup]");
nickjillings@1385 233 }
nickjillings@1370 234 }
nicholas@2851 235 $s.schema = undefined;
nicholas@2851 236 $s.attributes = [];
nickjillings@1370 237
nicholas@2851 238 $s.$watch("globalSchema", initialise);
nicholas@2853 239 $s.$watch("specification.metrics.enabled.length", function () {
nicholas@2853 240 var metricsNode = document.getElementById("metricsNode");
nicholas@2853 241 if (!$s.specification.metrics) {
nicholas@2853 242 return;
nicholas@2853 243 }
nicholas@2853 244 metricsNode.querySelectorAll("input").forEach(function (DOM) {
nicholas@2853 245 DOM.checked = false;
nicholas@2853 246 });
nicholas@2853 247 $s.specification.metrics.enabled.forEach(function (metric) {
nicholas@2853 248 var DOM = metricsNode.querySelector("[value=" + metric + "]");
nicholas@2853 249 if (DOM) {
nicholas@2853 250 DOM.checked = true;
nicholas@2853 251 }
nicholas@2853 252 });
nicholas@2855 253 });
nicholas@2853 254
nicholas@2853 255 $s.enableMetric = function ($event) {
nicholas@2853 256 var metric = $event.currentTarget.value;
nicholas@2853 257 var index = specification.metrics.enabled.findIndex(function (a) {
nicholas@2853 258 return a == metric;
nicholas@2853 259 });
nicholas@2853 260 if ($event.currentTarget.checked) {
nicholas@2853 261 if (index == -1) {
nicholas@2853 262 specification.metrics.enabled.push(metric);
nicholas@2853 263 }
nicholas@2853 264 } else {
nicholas@2853 265 if (index >= 0) {
nicholas@2853 266 specification.metrics.enabled.splice(index, 1);
nicholas@2853 267 }
nicholas@2853 268 }
nicholas@2855 269 };
nicholas@2886 270
nicholas@2886 271 $s.configure = function () {}
nicholas@2886 272
nicholas@2886 273 $s.$watch("selectedTestPrototype", $s.configure);
n@2907 274
n@2907 275 $s.placeholder = function (name) {
n@2908 276 if ($s.schema) {
n@2908 277 var spec = $s.schema.querySelector("attribute[name=\"" + name + "\"]") || $w.specification.schema.querySelector("attribute[name=\"" + name + "\"]");
n@2908 278 var attr = spec.getAttribute("default");
n@2908 279 if (attr === undefined) {
n@2908 280 return "";
n@2908 281 }
n@2908 282 return attr;
n@2907 283 }
n@2907 284 }
nicholas@2851 285 }]);
nicholas@2853 286
nicholas@2858 287 AngularInterface.controller("survey", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2858 288 $s.addSurveyEntry = function () {
nicholas@2858 289 $s.survey.addOption();
nicholas@2858 290 };
nicholas@2858 291 $s.removeSurveyEntry = function (entry) {
nicholas@2858 292 var index = $s.survey.options.findIndex(function (a) {
nicholas@2858 293 return a == entry;
nicholas@2858 294 });
nicholas@2858 295 if (index === -1) {
nicholas@2858 296 throw ("Invalid Entry");
nicholas@2858 297 }
nicholas@2858 298 $s.survey.options.splice(index, 1);
nicholas@2858 299 };
nicholas@2858 300 }]);
nicholas@2858 301
nicholas@2853 302 AngularInterface.controller("surveyOption", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2853 303
nicholas@2853 304 $s.removeOption = function (option) {
nicholas@2853 305 var index = $s.opt.options.findIndex(function (a) {
nicholas@2853 306 return a == option;
nicholas@2853 307 });
nicholas@2853 308 if (index === -1) {
nicholas@2853 309 throw ("Invalid option");
nicholas@2853 310 }
nicholas@2853 311 $s.opt.options.splice(index, 1);
nicholas@2853 312 };
nicholas@2853 313 $s.addOption = function () {
nicholas@2853 314 $s.opt.options.push({
nicholas@2853 315 name: "",
nicholas@2853 316 text: ""
nicholas@2853 317 });
nicholas@2855 318 };
nicholas@2857 319
nicholas@2857 320 $s.addCondition = function () {
nicholas@2857 321 $s.opt.conditions.push({
nicholas@2857 322 check: "equals",
nicholas@2857 323 value: "",
nicholas@2857 324 jumpToOnPass: undefined,
nicholas@2857 325 jumpToOnFail: undefined
nicholas@2857 326 });
nicholas@2857 327 };
nicholas@2857 328
nicholas@2857 329 $s.removeCondition = function (condition) {
nicholas@2857 330 var index = $s.opt.conditions.findIndex(function (c) {
nicholas@2857 331 return c == condition;
nicholas@2857 332 });
nicholas@2857 333 if (index === -1) {
nicholas@2857 334 throw ("Invalid Condition");
nicholas@2857 335 }
nicholas@2857 336 $s.opt.conditions.splice(index, 1);
nicholas@2857 337 };
nicholas@2855 338 }]);
nicholas@2855 339
nicholas@2855 340 AngularInterface.controller("interfaceNode", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2855 341 $s.$watch("interface.options.length", function () {
nicholas@2855 342 if (!$s.interface || !$s.interface.options) {
nicholas@2855 343 return;
nicholas@2855 344 }
nicholas@2855 345 var options = $e[0].querySelector(".interfaceOptions").querySelectorAll(".attribute");
nicholas@2855 346 options.forEach(function (option) {
nicholas@2855 347 var name = option.getAttribute("name");
nicholas@2855 348 var index = $s.interface.options.findIndex(function (io) {
nicholas@2855 349 return io.name == name;
nicholas@2855 350 });
nicholas@2855 351 option.querySelector("input").checked = (index >= 0);
nicholas@2855 352 if (name == "scalerange" && index >= 0) {
nicholas@2855 353 option.querySelector("[name=min]").value = $s.interface.options[index].min;
nicholas@2855 354 option.querySelector("[name=max]").value = $s.interface.options[index].max;
nicholas@2855 355 }
nicholas@2855 356 });
nicholas@2855 357 });
nicholas@2855 358 $s.enableInterfaceOption = function ($event) {
nicholas@2855 359 var name = $event.currentTarget.parentElement.getAttribute("name");
nicholas@2855 360 var type = $event.currentTarget.parentElement.getAttribute("type");
nicholas@2855 361 var index = $s.interface.options.findIndex(function (io) {
nicholas@2855 362 return io.name == name;
nicholas@2855 363 });
nicholas@2855 364 if (index == -1 && $event.currentTarget.checked) {
nicholas@2855 365 var obj = $s.interface.options.push({
nicholas@2855 366 name: name,
nicholas@2855 367 type: type
nicholas@2855 368 });
nicholas@2855 369 if (name == "scalerange") {
nicholas@2855 370 obj.min = $event.currentTarget.parentElement.querySelector("[name=min]").value;
nicholas@2855 371 obj.max = $event.currentTarget.parentElement.querySelector("[name=max]").value;
nicholas@2855 372 }
nicholas@2855 373 } else if (index >= 0 && !$event.currentTarget.checked) {
nicholas@2855 374 $s.interface.options.splice(index, 1);
nicholas@2855 375 }
nicholas@2857 376 };
nicholas@2886 377 $s.scales = [];
nicholas@2857 378 $s.removeScale = function (scale) {
nicholas@2857 379 var index = $s.interface.scales.findIndex(function (s) {
nicholas@2857 380 return s == scale;
nicholas@2857 381 });
nicholas@2857 382 if (index >= 0) {
nicholas@2857 383 $s.interface.scales.splice(index, 1);
nicholas@2857 384 }
nicholas@2857 385 };
nicholas@2857 386 $s.addScale = function () {
nicholas@2857 387 $s.interface.scales.push({
nicholas@2857 388 position: undefined,
nicholas@2857 389 text: undefined
nicholas@2857 390 });
nicholas@2857 391 };
nicholas@2864 392 $s.clearScales = function () {
nicholas@2864 393 $s.interface.scales = [];
nicholas@2864 394 };
nicholas@2876 395 $s.useScales = function (scale) {
nicholas@2864 396 $s.clearScales();
nicholas@2876 397 scale.scales.forEach(function (s) {
nicholas@2864 398 $s.interface.scales.push(s);
nicholas@2864 399 });
nicholas@2886 400 $s.selectedScale = scale.name;
nicholas@2864 401 };
nicholas@2886 402 $s.selectedScale = undefined;
nicholas@2886 403
nicholas@2886 404 $s.configure = function () {
nicholas@2886 405 if ($s.selectedTestPrototype === undefined) {
nicholas@2886 406 return;
nicholas@2886 407 }
nicholas@2886 408 if ($s.selectedTestPrototype.checks && $s.selectedTestPrototype.checks.length >= 1) {
nicholas@2886 409 $s.selectedTestPrototype.checks.forEach(function (entry) {
nicholas@2886 410 var dom = $e[0].querySelector("[name=\"" + entry.name + "\"] input");
nicholas@2886 411 if (entry.support == "none") {
nicholas@2886 412 dom.checked = false;
nicholas@2886 413 dom.disabled = true;
nicholas@2886 414 }
nicholas@2886 415 });
nicholas@2886 416 }
nicholas@2886 417 if ($s.selectedTestPrototype.show && $s.selectedTestPrototype.show.length >= 1) {
nicholas@2886 418 $s.selectedTestPrototype.show.forEach(function (entry) {
nicholas@2886 419 var dom = $e[0].querySelector("[name=\"" + entry.name + "\"] input");
nicholas@2886 420 if (entry.support == "none") {
nicholas@2886 421 dom.checked = false;
nicholas@2886 422 dom.disabled = true;
nicholas@2886 423 }
nicholas@2886 424 });
nicholas@2886 425 }
nicholas@2886 426 if ($s.interface !== specification.interfaces) {
nicholas@2886 427 // Page specific interface nodes
nicholas@2886 428 if ($s.selectedTestPrototype.hasScales !== undefined && ($s.selectedTestPrototype.hasScales == "false" || $s.selectedTestPrototype.hasScales == false)) {
nicholas@2886 429 var elem = $e[0].querySelector("[name=\"scale-selection\"]")
nicholas@2886 430 elem.style.visibility = "hidden";
nicholas@2886 431 elem.style.height = "0px";
nicholas@2886 432 }
nicholas@2886 433 if ($s.selectedTestPrototype.scales && $s.selectedTestPrototype.show.length >= 1) {
nicholas@2886 434 $s.scales = [];
nicholas@2886 435 $s.selectedTestPrototype.scales.forEach(function (scalename) {
nicholas@2886 436 var obj = $s.testSpecifications.scales.find(function (a) {
nicholas@2886 437 return a.name == scalename;
nicholas@2886 438 });
nicholas@2886 439 $s.scales.push(obj);
nicholas@2886 440 });
nicholas@2886 441 if ($s.selectedTestPrototype.scales.includes($s.selectedScale) == false) {
nicholas@2886 442 $s.clearScales();
nicholas@2886 443 }
nicholas@2886 444 if ($s.scales.length == 1) {
nicholas@2886 445 $s.clearScales();
nicholas@2886 446 $s.useScales($s.scales[0]);
nicholas@2886 447 }
nicholas@2886 448 } else {
nicholas@2886 449 $s.scales = $s.testSpecifications.scales;
nicholas@2886 450 }
nicholas@2886 451 }
nicholas@2886 452 };
nicholas@2886 453
nicholas@2886 454 $s.$watch("selectedTestPrototype", $s.configure);
nicholas@2886 455 $s.configure();
nicholas@2853 456 }]);
nicholas@2859 457 AngularInterface.controller("page", ['$scope', '$element', '$window', function ($s, $e, $w) {
n@2907 458 $s.schema = $w.specification.schema.querySelector("element[name=\"page\"]");
n@2909 459 $s.page.label = $s.page.label || "default";
nicholas@2859 460 $s.addInterface = function () {
nicholas@2859 461 $s.page.addInterface();
nicholas@2859 462 };
nicholas@2859 463 $s.removeInterface = function (node) {
nicholas@2859 464 var index = $s.page.interfaces.findIndex(function (a) {
nicholas@2859 465 return a == node;
nicholas@2859 466 });
nicholas@2859 467 if (index === -1) {
nicholas@2859 468 throw ("Invalid node");
nicholas@2859 469 }
nicholas@2859 470 $s.page.interfaces.splice(index, 1);
nicholas@2859 471 };
nicholas@2859 472
nicholas@2859 473 $s.addCommentQuestion = function () {
nicholas@2859 474 $s.page.addCommentQuestion();
nicholas@2859 475 };
nicholas@2859 476 $s.removeCommentQuestion = function (node) {
nicholas@2859 477 var index = $s.page.commentQuestions.findIndex(function (a) {
nicholas@2859 478 return a == node;
nicholas@2859 479 });
nicholas@2859 480 if (index === -1) {
nicholas@2859 481 throw ("Invalid node");
nicholas@2859 482 }
nicholas@2859 483 $s.page.commentQuestions.splice(index, 1);
nicholas@2859 484 };
nicholas@2859 485 $s.addAudioElement = function () {
nicholas@2859 486 $s.page.addAudioElement();
nicholas@2859 487 };
nicholas@2859 488 $s.removeAudioElement = function (element) {
nicholas@2859 489 var index = $s.page.audioElements.findIndex(function (a) {
nicholas@2859 490 return a == element;
nicholas@2859 491 });
nicholas@2859 492 if (index === -1) {
nicholas@2859 493 throw ("Invalid node");
nicholas@2859 494 }
nicholas@2859 495 $s.page.audioElements.splice(index, 1);
nicholas@2859 496 };
n@2907 497
n@2907 498 $s.placeholder = function (name) {
n@2907 499 var spec = $s.schema.querySelector("attribute[name=\"" + name + "\"]") || $w.specification.schema.querySelector("attribute[name=\"" + name + "\"]");
n@2907 500 var attr = spec.getAttribute("default");
n@2907 501 if (attr === undefined) {
n@2907 502 return "";
n@2907 503 }
n@2907 504 return attr;
n@2907 505 }
nicholas@2859 506 }]);