annotate test_create/test_core.js @ 2961:1593792ae742

fix bug introduced in 6e05fd48809259342e69b3cdd942bf458edd4c53 - serialization of xml version tag prevents export function from working
author Thomas Schlien <schlien@iks.rwth-aachen.de>
date Thu, 23 Nov 2017 14:03:28 +0100
parents 5705787531a3
children f99b888f57e9 c8707694f4e7
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 });
n@2912 89 $s.availableInterfaceModules = [];
n@2912 90 get("interfaces/interfaces.json").then(JSON.parse).then(function (d) {
n@2912 91 $s.availableInterfaceModules = d.interfaces;
n@2912 92 $s.$apply();
n@2912 93 });
nicholas@2851 94 $s.specification = specification;
nicholas@2886 95 $s.selectedTestPrototype = undefined;
nicholas@2886 96 $s.setTestPrototype = function (obj) {
nicholas@2886 97 $s.selectedTestPrototype = obj;
nicholas@2886 98 $w.specification.interface = obj.interface;
nicholas@2886 99 }
nicholas@2857 100
nicholas@2857 101 $s.addPage = function () {
nicholas@2857 102 $s.specification.createNewPage();
nicholas@2859 103 };
nicholas@2860 104
nicholas@2862 105 $s.removePage = function (page) {
nicholas@2862 106 var index = $s.specification.pages.findIndex(function (a) {
nicholas@2862 107 return a == page;
nicholas@2862 108 });
nicholas@2862 109 if (index === -1) {
nicholas@2862 110 throw ("Invalid Page");
nicholas@2862 111 }
nicholas@2862 112 $s.specification.pages.splice(index, 1);
nicholas@2862 113 };
nicholas@2862 114
nicholas@2860 115 $s.exportXML = function () {
nicholas@2860 116 var s = new XMLSerializer();
schlien@2961 117 var doc = specification.encode();
nicholas@2891 118 var xmlstr = s.serializeToString(doc);
schlien@2961 119 var bb = new Blob(["<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + s.serializeToString(doc)], {
nicholas@2860 120 type: 'application/xml'
nicholas@2860 121 });
nicholas@2860 122 var dnlk = window.URL.createObjectURL(bb);
nicholas@2891 123 var a = document.createElement("a");
n@2913 124 document.body.appendChild(a)
nicholas@2891 125 a.href = dnlk;
nicholas@2891 126 a.download = "test.xml";
nicholas@2891 127 a.click();
nicholas@2891 128 window.URL.revokeObjectURL(dnlk);
n@2913 129 document.body.removeChild(a);
nicholas@2861 130 };
nicholas@2887 131 $s.validated = false;
nicholas@2887 132 $s.showValidationMessages = false;
nicholas@2887 133 $s.validate = function () {
nicholas@2887 134 var s = new XMLSerializer();
nicholas@2887 135 var Module = {
nicholas@2959 136 xml: "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + s.serializeToString(specification.encode()),
nicholas@2887 137 schema: specification.getSchemaString(),
nicholas@2887 138 arguments: ["--noout", "--schema", 'test-schema.xsd', 'document.xml']
nicholas@2887 139 };
nicholas@2887 140 var xmllint = validateXML(Module);
nicholas@2887 141 console.log(xmllint);
nicholas@2887 142 if (xmllint != 'document.xml validates\n') {
nicholas@2887 143 $s.validated = false;
nicholas@2887 144 var list = $e[0].querySelector("#validation-error-list");
nicholas@2887 145 while (list.firstChild) {
nicholas@2887 146 list.removeChild(list.firstChild);
nicholas@2887 147 }
nicholas@2887 148 var errors = xmllint.split('\n');
nicholas@2887 149 errors = errors.slice(0, errors.length - 2);
nicholas@2887 150 errors.forEach(function (str) {
nicholas@2887 151 var li = document.createElement("li");
nicholas@2887 152 li.textContent = str;
nicholas@2887 153 list.appendChild(li);
nicholas@2887 154 });
nicholas@2887 155 } else {
nicholas@2887 156 $s.validated = true;
nicholas@2887 157 }
nicholas@2887 158 $s.showValidationMessages = true;
nicholas@2887 159 }
nicholas@2887 160 $s.hideValidationMessages = function () {
nicholas@2887 161 $s.showValidationMessages = false;
nicholas@2887 162 }
n@2911 163 $s.$watch(function () {
n@2911 164 return document.querySelectorAll("div.pageNode").length;
n@2911 165 }, $w.toggleDropdowns);
n@2911 166 $s.$watch(function () {
n@2911 167 return document.querySelectorAll("div.surveyentry").length;
n@2911 168 }, $w.toggleDropdowns);
n@2911 169 $s.$watch(function () {
n@2911 170 return document.querySelectorAll("div.interface").length;
n@2911 171 }, $w.toggleDropdowns);
n@2911 172 $s.$watch(function () {
n@2911 173 return document.querySelectorAll("div.audioelement").length;
n@2911 174 }, $w.toggleDropdowns);
nicholas@2851 175 }]);
nickjillings@1370 176
nicholas@2851 177 AngularInterface.controller("introduction", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2851 178 $s.state = 0;
n@2908 179 $s.selected = undefined;
nicholas@2851 180 $s.next = function () {
nicholas@2851 181 $s.state++;
nicholas@2861 182 if ($s.state > 1 || $s.file) {
nicholas@2851 183 $s.hidePopup();
n@2908 184 $s.initialise($s.selected);
nicholas@2851 185 }
nicholas@2851 186 };
nicholas@2851 187 $s.back = function () {
nicholas@2851 188 $s.state--;
nicholas@2851 189 };
nicholas@2851 190 $s.mouseover = function (name) {
nicholas@2864 191 var obj = $s.testSpecifications.interfaces.find(function (i) {
nicholas@2851 192 return i.name == name;
nicholas@2851 193 });
nicholas@2851 194 if (obj) {
nicholas@2851 195 $s.description = obj.description.en;
nicholas@2851 196 }
nicholas@2851 197 };
nicholas@2851 198 $s.initialise = function (name) {
nicholas@2885 199 var obj = $s.testSpecifications.interfaces.find(function (i) {
nicholas@2851 200 return i.name == name;
nicholas@2851 201 });
nicholas@2886 202 if (obj === undefined) {
nicholas@2886 203 throw ("Cannot find specification");
nicholas@2886 204 }
n@2908 205 if (typeof obj.template === "string") {
n@2908 206 get(obj.template).then(function (data) {
n@2908 207 $s.parseFile(data);
n@2908 208 }, function (err) {})
n@2908 209 } else {
n@2908 210 $s.setTestPrototype(obj);
n@2908 211 }
nicholas@2851 212 };
n@2908 213 $s.select = function (name) {
nicholas@2960 214 $s.selected = name;
nicholas@2960 215 }
nicholas@2960 216 // Get the test interface specifications
nicholas@2861 217 $s.file = undefined;
nicholas@2851 218 $s.description = "";
nicholas@2861 219
n@2908 220 $s.parseFile = function (f) {
n@2908 221 var p = new DOMParser();
n@2908 222 specification.decode(p.parseFromString(f, "text/xml"));
n@2908 223 $s.$apply();
n@2908 224 }
n@2908 225
nicholas@2861 226 $s.handleFiles = function ($event) {
nicholas@2861 227 $s.file = $event.currentTarget.files[0];
nicholas@2861 228 var r = new FileReader();
nicholas@2861 229 r.onload = function () {
n@2908 230 $s.parseFile(r.result);
nicholas@2862 231 };
nicholas@2861 232 r.readAsText($s.file);
nicholas@2861 233 };
nicholas@2851 234 }]);
nickjillings@1370 235
nicholas@2851 236 AngularInterface.controller("setup", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2851 237 function initialise() {
nicholas@2851 238 if ($s.globalSchema) {
nicholas@2851 239 $s.schema = $s.globalSchema.querySelector("[name=setup]");
nickjillings@1385 240 }
nickjillings@1370 241 }
nicholas@2851 242 $s.schema = undefined;
nicholas@2851 243 $s.attributes = [];
nickjillings@1370 244
nicholas@2851 245 $s.$watch("globalSchema", initialise);
nicholas@2853 246 $s.$watch("specification.metrics.enabled.length", function () {
nicholas@2853 247 var metricsNode = document.getElementById("metricsNode");
nicholas@2853 248 if (!$s.specification.metrics) {
nicholas@2853 249 return;
nicholas@2853 250 }
nicholas@2853 251 metricsNode.querySelectorAll("input").forEach(function (DOM) {
nicholas@2853 252 DOM.checked = false;
nicholas@2853 253 });
nicholas@2853 254 $s.specification.metrics.enabled.forEach(function (metric) {
nicholas@2853 255 var DOM = metricsNode.querySelector("[value=" + metric + "]");
nicholas@2853 256 if (DOM) {
nicholas@2853 257 DOM.checked = true;
nicholas@2853 258 }
nicholas@2853 259 });
nicholas@2855 260 });
nicholas@2853 261
nicholas@2853 262 $s.enableMetric = function ($event) {
nicholas@2853 263 var metric = $event.currentTarget.value;
nicholas@2853 264 var index = specification.metrics.enabled.findIndex(function (a) {
nicholas@2853 265 return a == metric;
nicholas@2853 266 });
nicholas@2853 267 if ($event.currentTarget.checked) {
nicholas@2853 268 if (index == -1) {
nicholas@2853 269 specification.metrics.enabled.push(metric);
nicholas@2853 270 }
nicholas@2853 271 } else {
nicholas@2853 272 if (index >= 0) {
nicholas@2853 273 specification.metrics.enabled.splice(index, 1);
nicholas@2853 274 }
nicholas@2853 275 }
nicholas@2855 276 };
nicholas@2886 277
nicholas@2886 278 $s.configure = function () {}
nicholas@2886 279
nicholas@2886 280 $s.$watch("selectedTestPrototype", $s.configure);
n@2907 281
n@2907 282 $s.placeholder = function (name) {
n@2908 283 if ($s.schema) {
n@2908 284 var spec = $s.schema.querySelector("attribute[name=\"" + name + "\"]") || $w.specification.schema.querySelector("attribute[name=\"" + name + "\"]");
n@2908 285 var attr = spec.getAttribute("default");
n@2912 286 if (attr === null) {
n@2912 287 return "Not set";
n@2908 288 }
n@2908 289 return attr;
n@2907 290 }
n@2907 291 }
nicholas@2851 292 }]);
nicholas@2853 293
nicholas@2858 294 AngularInterface.controller("survey", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2858 295 $s.addSurveyEntry = function () {
nicholas@2858 296 $s.survey.addOption();
nicholas@2858 297 };
nicholas@2858 298 $s.removeSurveyEntry = function (entry) {
nicholas@2858 299 var index = $s.survey.options.findIndex(function (a) {
nicholas@2858 300 return a == entry;
nicholas@2858 301 });
nicholas@2858 302 if (index === -1) {
nicholas@2858 303 throw ("Invalid Entry");
nicholas@2858 304 }
nicholas@2858 305 $s.survey.options.splice(index, 1);
nicholas@2858 306 };
nicholas@2858 307 }]);
nicholas@2858 308
nicholas@2853 309 AngularInterface.controller("surveyOption", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2853 310
nicholas@2853 311 $s.removeOption = function (option) {
nicholas@2853 312 var index = $s.opt.options.findIndex(function (a) {
nicholas@2853 313 return a == option;
nicholas@2853 314 });
nicholas@2853 315 if (index === -1) {
nicholas@2853 316 throw ("Invalid option");
nicholas@2853 317 }
nicholas@2853 318 $s.opt.options.splice(index, 1);
nicholas@2853 319 };
nicholas@2853 320 $s.addOption = function () {
nicholas@2853 321 $s.opt.options.push({
nicholas@2853 322 name: "",
nicholas@2853 323 text: ""
nicholas@2853 324 });
nicholas@2855 325 };
nicholas@2857 326
nicholas@2857 327 $s.addCondition = function () {
nicholas@2857 328 $s.opt.conditions.push({
nicholas@2857 329 check: "equals",
nicholas@2857 330 value: "",
nicholas@2857 331 jumpToOnPass: undefined,
nicholas@2857 332 jumpToOnFail: undefined
nicholas@2857 333 });
nicholas@2857 334 };
nicholas@2857 335
nicholas@2857 336 $s.removeCondition = function (condition) {
nicholas@2857 337 var index = $s.opt.conditions.findIndex(function (c) {
nicholas@2857 338 return c == condition;
nicholas@2857 339 });
nicholas@2857 340 if (index === -1) {
nicholas@2857 341 throw ("Invalid Condition");
nicholas@2857 342 }
nicholas@2857 343 $s.opt.conditions.splice(index, 1);
nicholas@2857 344 };
nicholas@2855 345 }]);
nicholas@2855 346
nicholas@2855 347 AngularInterface.controller("interfaceNode", ['$scope', '$element', '$window', function ($s, $e, $w) {
nicholas@2855 348 $s.$watch("interface.options.length", function () {
nicholas@2855 349 if (!$s.interface || !$s.interface.options) {
nicholas@2855 350 return;
nicholas@2855 351 }
nicholas@2855 352 var options = $e[0].querySelector(".interfaceOptions").querySelectorAll(".attribute");
nicholas@2855 353 options.forEach(function (option) {
nicholas@2855 354 var name = option.getAttribute("name");
nicholas@2855 355 var index = $s.interface.options.findIndex(function (io) {
nicholas@2855 356 return io.name == name;
nicholas@2855 357 });
nicholas@2855 358 option.querySelector("input").checked = (index >= 0);
nicholas@2855 359 if (name == "scalerange" && index >= 0) {
nicholas@2855 360 option.querySelector("[name=min]").value = $s.interface.options[index].min;
nicholas@2855 361 option.querySelector("[name=max]").value = $s.interface.options[index].max;
nicholas@2855 362 }
nicholas@2855 363 });
nicholas@2855 364 });
nicholas@2855 365 $s.enableInterfaceOption = function ($event) {
nicholas@2855 366 var name = $event.currentTarget.parentElement.getAttribute("name");
nicholas@2855 367 var type = $event.currentTarget.parentElement.getAttribute("type");
nicholas@2855 368 var index = $s.interface.options.findIndex(function (io) {
nicholas@2855 369 return io.name == name;
nicholas@2855 370 });
nicholas@2855 371 if (index == -1 && $event.currentTarget.checked) {
nicholas@2855 372 var obj = $s.interface.options.push({
nicholas@2855 373 name: name,
nicholas@2855 374 type: type
nicholas@2855 375 });
nicholas@2855 376 if (name == "scalerange") {
nicholas@2855 377 obj.min = $event.currentTarget.parentElement.querySelector("[name=min]").value;
nicholas@2855 378 obj.max = $event.currentTarget.parentElement.querySelector("[name=max]").value;
nicholas@2855 379 }
nicholas@2855 380 } else if (index >= 0 && !$event.currentTarget.checked) {
nicholas@2855 381 $s.interface.options.splice(index, 1);
nicholas@2855 382 }
nicholas@2857 383 };
nicholas@2886 384 $s.scales = [];
nicholas@2857 385 $s.removeScale = function (scale) {
nicholas@2857 386 var index = $s.interface.scales.findIndex(function (s) {
nicholas@2857 387 return s == scale;
nicholas@2857 388 });
nicholas@2857 389 if (index >= 0) {
nicholas@2857 390 $s.interface.scales.splice(index, 1);
nicholas@2857 391 }
nicholas@2857 392 };
nicholas@2857 393 $s.addScale = function () {
nicholas@2857 394 $s.interface.scales.push({
nicholas@2857 395 position: undefined,
nicholas@2857 396 text: undefined
nicholas@2857 397 });
nicholas@2857 398 };
nicholas@2864 399 $s.clearScales = function () {
nicholas@2864 400 $s.interface.scales = [];
nicholas@2864 401 };
nicholas@2876 402 $s.useScales = function (scale) {
nicholas@2864 403 $s.clearScales();
nicholas@2876 404 scale.scales.forEach(function (s) {
nicholas@2864 405 $s.interface.scales.push(s);
nicholas@2864 406 });
nicholas@2886 407 $s.selectedScale = scale.name;
nicholas@2864 408 };
nicholas@2886 409 $s.selectedScale = undefined;
nicholas@2886 410
nicholas@2886 411 $s.configure = function () {
nicholas@2886 412 if ($s.selectedTestPrototype === undefined) {
nicholas@2886 413 return;
nicholas@2886 414 }
nicholas@2886 415 if ($s.selectedTestPrototype.checks && $s.selectedTestPrototype.checks.length >= 1) {
nicholas@2886 416 $s.selectedTestPrototype.checks.forEach(function (entry) {
nicholas@2886 417 var dom = $e[0].querySelector("[name=\"" + entry.name + "\"] input");
nicholas@2886 418 if (entry.support == "none") {
nicholas@2886 419 dom.checked = false;
nicholas@2886 420 dom.disabled = true;
nicholas@2886 421 }
nicholas@2886 422 });
nicholas@2886 423 }
nicholas@2886 424 if ($s.selectedTestPrototype.show && $s.selectedTestPrototype.show.length >= 1) {
nicholas@2886 425 $s.selectedTestPrototype.show.forEach(function (entry) {
nicholas@2886 426 var dom = $e[0].querySelector("[name=\"" + entry.name + "\"] input");
nicholas@2886 427 if (entry.support == "none") {
nicholas@2886 428 dom.checked = false;
nicholas@2886 429 dom.disabled = true;
nicholas@2886 430 }
nicholas@2886 431 });
nicholas@2886 432 }
nicholas@2886 433 if ($s.interface !== specification.interfaces) {
nicholas@2886 434 // Page specific interface nodes
nicholas@2886 435 if ($s.selectedTestPrototype.hasScales !== undefined && ($s.selectedTestPrototype.hasScales == "false" || $s.selectedTestPrototype.hasScales == false)) {
nicholas@2886 436 var elem = $e[0].querySelector("[name=\"scale-selection\"]")
nicholas@2886 437 elem.style.visibility = "hidden";
nicholas@2886 438 elem.style.height = "0px";
nicholas@2886 439 }
nicholas@2886 440 if ($s.selectedTestPrototype.scales && $s.selectedTestPrototype.show.length >= 1) {
nicholas@2886 441 $s.scales = [];
nicholas@2886 442 $s.selectedTestPrototype.scales.forEach(function (scalename) {
nicholas@2886 443 var obj = $s.testSpecifications.scales.find(function (a) {
nicholas@2886 444 return a.name == scalename;
nicholas@2886 445 });
nicholas@2886 446 $s.scales.push(obj);
nicholas@2886 447 });
nicholas@2886 448 if ($s.selectedTestPrototype.scales.includes($s.selectedScale) == false) {
nicholas@2886 449 $s.clearScales();
nicholas@2886 450 }
nicholas@2886 451 if ($s.scales.length == 1) {
nicholas@2886 452 $s.clearScales();
nicholas@2886 453 $s.useScales($s.scales[0]);
nicholas@2886 454 }
nicholas@2886 455 } else {
nicholas@2886 456 $s.scales = $s.testSpecifications.scales;
nicholas@2886 457 }
nicholas@2886 458 }
nicholas@2886 459 };
nicholas@2886 460
nicholas@2886 461 $s.$watch("selectedTestPrototype", $s.configure);
nicholas@2886 462 $s.configure();
nicholas@2853 463 }]);
nicholas@2859 464 AngularInterface.controller("page", ['$scope', '$element', '$window', function ($s, $e, $w) {
n@2907 465 $s.schema = $w.specification.schema.querySelector("element[name=\"page\"]");
n@2909 466 $s.page.label = $s.page.label || "default";
nicholas@2859 467 $s.addInterface = function () {
nicholas@2859 468 $s.page.addInterface();
nicholas@2859 469 };
nicholas@2859 470 $s.removeInterface = function (node) {
nicholas@2859 471 var index = $s.page.interfaces.findIndex(function (a) {
nicholas@2859 472 return a == node;
nicholas@2859 473 });
nicholas@2859 474 if (index === -1) {
nicholas@2859 475 throw ("Invalid node");
nicholas@2859 476 }
nicholas@2859 477 $s.page.interfaces.splice(index, 1);
nicholas@2859 478 };
nicholas@2859 479
nicholas@2859 480 $s.addCommentQuestion = function () {
nicholas@2859 481 $s.page.addCommentQuestion();
nicholas@2859 482 };
nicholas@2859 483 $s.removeCommentQuestion = function (node) {
nicholas@2859 484 var index = $s.page.commentQuestions.findIndex(function (a) {
nicholas@2859 485 return a == node;
nicholas@2859 486 });
nicholas@2859 487 if (index === -1) {
nicholas@2859 488 throw ("Invalid node");
nicholas@2859 489 }
nicholas@2859 490 $s.page.commentQuestions.splice(index, 1);
nicholas@2859 491 };
nicholas@2859 492 $s.addAudioElement = function () {
nicholas@2859 493 $s.page.addAudioElement();
nicholas@2859 494 };
nicholas@2859 495 $s.removeAudioElement = function (element) {
nicholas@2859 496 var index = $s.page.audioElements.findIndex(function (a) {
nicholas@2859 497 return a == element;
nicholas@2859 498 });
nicholas@2859 499 if (index === -1) {
nicholas@2859 500 throw ("Invalid node");
nicholas@2859 501 }
nicholas@2859 502 $s.page.audioElements.splice(index, 1);
nicholas@2859 503 };
n@2907 504
n@2907 505 $s.placeholder = function (name) {
n@2907 506 var spec = $s.schema.querySelector("attribute[name=\"" + name + "\"]") || $w.specification.schema.querySelector("attribute[name=\"" + name + "\"]");
n@2907 507 var attr = spec.getAttribute("default");
n@2912 508 if (attr === null) {
n@2912 509 return "Not set";
n@2907 510 }
n@2907 511 return attr;
n@2907 512 }
nicholas@2859 513 }]);