comparison test_create/test_create.html @ 2026:9f87a5b96b93

create_test: Added interface node options
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Thu, 04 Jun 2015 09:44:50 +0100
parents 1aeedbe12d2a
children 35682e8e1159
comparison
equal deleted inserted replaced
2025:1aeedbe12d2a 2026:9f87a5b96b93
145 constructPrePost(audioHolderPostTest, options); 145 constructPrePost(audioHolderPostTest, options);
146 146
147 audioHolder.appendChild(audioHolderPreTest); 147 audioHolder.appendChild(audioHolderPreTest);
148 audioHolder.appendChild(audioHolderPostTest); 148 audioHolder.appendChild(audioHolderPostTest);
149 149
150 // Interface Nodes
151
150 // audio-Elements 152 // audio-Elements
151 var audioElementsDOM = []; 153 var audioElementsDOM = [];
152 var commentQuestionDOM = []; 154 var commentQuestionDOM = [];
155 var interfacesDOM = [];
153 for (var j=0; j<audioHolderDOM.childElementCount; j++) { 156 for (var j=0; j<audioHolderDOM.childElementCount; j++) {
154 var child = audioHolderDOM.childNodes[j]; 157 var child = audioHolderDOM.childNodes[j];
155 var name = child.getAttribute('name'); 158 var name = child.getAttribute('name');
156 if (name == 'audio-element') {audioElementsDOM.push(child);} 159 if (name == 'audio-element') {audioElementsDOM.push(child);}
157 else if (name == 'comment-question') {commentQuestionDOM.push(child);} 160 else if (name == 'comment-question') {commentQuestionDOM.push(child);}
161 else if (name == 'interface-options') {interfacesDOM.push(child);}
162 }
163
164 for (var j=0; j<interfacesDOM.length; j++) {
165 var interfaceNode = document.createElement('interface');
166 attribs = interfacesDOM[j].getElementsByClassName('attrib')[0].getElementsByTagName('input');
167 var title = document.createElement('title');
168 title.textContent = attribs[0].value;
169 interfaceNode.appendChild(title);
170
171
172 var markers = interfacesDOM[j].getElementsByClassName('head');
173 for (var k=0; k<markers.length; k++) {
174 var markerNode = document.createElement('scale');
175 attribs = markers[k].getElementsByClassName('attrib')[0].getElementsByTagName('input');
176 markerNode.textContent = attribs[0].value;
177 markerNode.setAttribute('position',attribs[1].value);
178 interfaceNode.appendChild(markerNode);
179 }
180 audioHolder.appendChild(interfaceNode);
158 } 181 }
159 182
160 for (var j=0; j<audioElementsDOM.length; j++) { 183 for (var j=0; j<audioElementsDOM.length; j++) {
161 var audioElement = document.createElement('audioElement'); 184 var audioElement = document.createElement('audioElement');
162 attribs = audioElementsDOM[j].getElementsByClassName('attrib')[0].getElementsByTagName('input'); 185 attribs = audioElementsDOM[j].getElementsByClassName('attrib')[0].getElementsByTagName('input');
378 newCommentButton.onclick = function() { 401 newCommentButton.onclick = function() {
379 event.srcElement.parentElement.appendChild(commentBox()); 402 event.srcElement.parentElement.appendChild(commentBox());
380 }; 403 };
381 node.appendChild(newCommentButton); 404 node.appendChild(newCommentButton);
382 405
406 var newInterface = document.createElement("button");
407 newInterface.textContent = "Add Interface";
408 newInterface.onclick = function() {
409 event.srcElement.parentElement.appendChild(interfaceNode());
410 };
411 node.appendChild(newInterface);
412
383 var removeButton = document.createElement("button"); 413 var removeButton = document.createElement("button");
384 removeButton.textContent = "Remove Audio Holder"; 414 removeButton.textContent = "Remove Audio Holder";
385 removeButton.onclick = removeNode; 415 removeButton.onclick = removeNode;
386 node.appendChild(removeButton); 416 node.appendChild(removeButton);
387 return node; 417 return node;
434 node.appendChild(attributes); 464 node.appendChild(attributes);
435 node.appendChild(removeButton); 465 node.appendChild(removeButton);
436 return node; 466 return node;
437 } 467 }
438 468
469 function interfaceNode() {
470 var selectedInterface = document.getElementById('interface').value;
471 var node = document.createElement('div');
472 node.setAttribute('class','head');
473 node.setAttribute('name','interface-options');
474 var nodeTitle = document.createElement('h4');
475 nodeTitle.textContent = "Interface";
476
477 var attributes = document.createElement('div');
478 attributes.setAttribute('class','attrib');
479 var title = attributePair('Title: ','text',false);
480 title[1].style.width = "500px";
481
482 var addMarker = document.createElement('button');
483 addMarker.textContent = "Add Scale Marker";
484 addMarker.onclick = function() {
485 event.srcElement.parentElement.appendChild(newScaleMarker());
486 };
487
488 title.forEach(function(item){attributes.appendChild(item);},false);
489
490 var removeButton = document.createElement("button");
491 removeButton.textContent = "Remove Interface";
492 removeButton.onclick = removeNode;
493
494 node.appendChild(nodeTitle);
495 node.appendChild(attributes);
496 node.appendChild(addMarker);
497 node.appendChild(removeButton);
498 return node;
499 }
500
501 function newScaleMarker() {
502 var node = document.createElement('div');
503 node.setAttribute('class','head');
504 node.setAttribute('name','interface-options');
505 var nodeTitle = document.createElement('span');
506 nodeTitle.textContent = "Marker";
507 var attributes = document.createElement('div');
508 attributes.setAttribute('class','attrib');
509 var text = attributePair('Text: ','text',true);
510 var position = attributePair('Positon','number',true);
511
512 text.forEach(function(item){attributes.appendChild(item);},false);
513 position.forEach(function(item){attributes.appendChild(item);},false);
514
515 var removeButton = document.createElement("button");
516 removeButton.textContent = "Remove Marker";
517 removeButton.onclick = removeNode;
518
519 node.appendChild(nodeTitle);
520 node.appendChild(attributes);
521 node.appendChild(removeButton);
522 return node;
523 }
439 524
440 function handleDragOver(e) { 525 function handleDragOver(e) {
441 e.stopPropagation(); 526 e.stopPropagation();
442 e.preventDefault(); 527 e.preventDefault();
443 } 528 }
573 attribs[0].value = child.textContent; 658 attribs[0].value = child.textContent;
574 } 659 }
575 audioHolderDOM.children[3].appendChild(node); 660 audioHolderDOM.children[3].appendChild(node);
576 } 661 }
577 } 662 }
663 // Process interface
664 var interfaceNodes = audioHolders[i].getElementsByTagName('interface');
665 for (var j=0; j<interfaceNodes.length; j++) {
666 var node = interfaceNode();
667 var child = interfaceNodes[j];
668 var attribs = node.getElementsByClassName('attrib')[0].getElementsByTagName('input');
669 attribs[0].value = child.getElementsByTagName('title')[0].textContent;
670
671 var markers = child.getElementsByTagName('scale');
672 for (var k=0; k<markers.length; k++) {
673 var markerNode = newScaleMarker();
674 attribs = markerNode.getElementsByClassName('attrib')[0].getElementsByTagName('input');
675 attribs[0].value = markers[k].textContent;
676 attribs[1].value = markers[k].getAttribute('position');
677 node.appendChild(markerNode);
678 }
679 audioHolderDOM.appendChild(node);
680 }
681
578 682
579 // Process audio-element 683 // Process audio-element
580 var audioElements = audioHolders[i].getElementsByTagName('audioElements'); 684 var audioElements = audioHolders[i].getElementsByTagName('audioElements');
581 for (var j=0; j<audioElements.length; j++) { 685 for (var j=0; j<audioElements.length; j++) {
582 var node = audioElementNode(); 686 var node = audioElementNode();