Mercurial > hg > webaudioevaluationtool
comparison test_create/test_core.js @ 2158:b4d6552aecb7
Test Create fixes for #1597 #1598 #1656 #1657
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Mon, 14 Mar 2016 12:34:36 +0000 |
parents | 749adcb68e99 |
children | ee5f18d2fc47 |
comparison
equal
deleted
inserted
replaced
2157:686f1fb84d7c | 2158:b4d6552aecb7 |
---|---|
697 this.content.appendChild(spnH); | 697 this.content.appendChild(spnH); |
698 this.dynamic = document.createElement("div"); | 698 this.dynamic = document.createElement("div"); |
699 this.option = null; | 699 this.option = null; |
700 this.parent = null; | 700 this.parent = null; |
701 this.optionLists = []; | 701 this.optionLists = []; |
702 var select = document.createElement("select"); | 702 this.select = document.createElement("select"); |
703 select.setAttribute("name","type"); | 703 this.select.setAttribute("name","type"); |
704 select.addEventListener("change",this,false); | 704 this.select.addEventListener("change",this,false); |
705 this.content.appendChild(select); | 705 this.content.appendChild(this.select); |
706 this.content.appendChild(this.dynamic); | 706 this.content.appendChild(this.dynamic); |
707 this.generate = function(option, parent) | 707 this.generate = function(option, parent) |
708 { | 708 { |
709 this.option = option; | 709 this.option = option; |
710 this.parent = parent; | 710 this.parent = parent; |
711 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration"); | 711 if (this.select.childElementCount == 0) { |
712 for (var i=0; i<optionList.length; i++) | 712 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration"); |
713 { | 713 for (var i=0; i<optionList.length; i++) |
714 var selectOption = document.createElement("option"); | 714 { |
715 selectOption.value = optionList[i].getAttribute("value"); | 715 var selectOption = document.createElement("option"); |
716 selectOption.textContent = selectOption.value; | 716 selectOption.value = optionList[i].getAttribute("value"); |
717 select.appendChild(selectOption); | 717 selectOption.textContent = selectOption.value; |
718 this.select.appendChild(selectOption); | |
719 } | |
718 } | 720 } |
719 if (this.option.type != undefined){ | 721 if (this.option.type != undefined){ |
720 select.value = this.option.type | 722 this.select.value = this.option.type |
721 } else { | 723 } else { |
722 select.value = "statement"; | 724 this.select.value = "statement"; |
723 this.option.type = "statement"; | 725 this.option.type = "statement"; |
724 } | 726 } |
725 | 727 |
726 this.dynamic.innerHTML = null; | 728 this.dynamic.innerHTML = null; |
727 var statement = document.createElement("div"); | 729 var statement = document.createElement("div"); |
743 idText.textContent = "ID: "; | 745 idText.textContent = "ID: "; |
744 idEntry.addEventListener("change",this,false); | 746 idEntry.addEventListener("change",this,false); |
745 idEntry.setAttribute("name","id"); | 747 idEntry.setAttribute("name","id"); |
746 idEntry.value = this.option.id; | 748 idEntry.value = this.option.id; |
747 | 749 |
750 this.dynamic.appendChild(id); | |
751 | |
748 switch(this.option.type) | 752 switch(this.option.type) |
749 { | 753 { |
750 case "statement": | 754 case "statement": |
751 break; | 755 break; |
752 case "question": | 756 case "question": |
753 this.dynamic.appendChild(id); | |
754 var boxsizeSelect = document.createElement("select"); | 757 var boxsizeSelect = document.createElement("select"); |
755 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("boxsize")[0].getAllElementsByTagName("xs:enumeration"); | 758 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("boxsize")[0].getAllElementsByTagName("xs:enumeration"); |
756 for (var i=0; i<optionList.length; i++) | 759 for (var i=0; i<optionList.length; i++) |
757 { | 760 { |
758 var selectOption = document.createElement("option"); | 761 var selectOption = document.createElement("option"); |
882 }; | 885 }; |
883 this.deleteEntry.root.textContent = "Delete Option"; | 886 this.deleteEntry.root.textContent = "Delete Option"; |
884 this.deleteEntry.root.addEventListener("click",this.deleteEntry,false); | 887 this.deleteEntry.root.addEventListener("click",this.deleteEntry,false); |
885 this.rootDOM.appendChild(this.deleteEntry.root); | 888 this.rootDOM.appendChild(this.deleteEntry.root); |
886 } | 889 } |
890 this.addEntry = { | |
891 parent: this, | |
892 root: document.createElement("button"), | |
893 handleEvent: function() { | |
894 var node = {name: "name", text: "text"}; | |
895 var optionsList = this.parent.option.options; | |
896 optionsList.push(node); | |
897 var obj = new optionObject(this.parent,optionsList[optionsList.length-1]); | |
898 this.parent.optionLists.push(obj); | |
899 document.getElementById("popup-option-holder").appendChild(obj.rootDOM); | |
900 } | |
901 } | |
902 this.addEntry.root.textContent = "Add Option"; | |
903 this.addEntry.root.addEventListener("click",this.addEntry); | |
904 this.dynamic.appendChild(this.addEntry.root); | |
887 for (var i=0; i<this.option.options.length; i++) | 905 for (var i=0; i<this.option.options.length; i++) |
888 { | 906 { |
889 var obj = new optionObject(this,this.option.options[i]); | 907 var obj = new optionObject(this,this.option.options[i]); |
890 this.optionLists.push(obj); | 908 this.optionLists.push(obj); |
891 optionHolder.appendChild(obj.rootDOM); | 909 optionHolder.appendChild(obj.rootDOM); |
1140 this.holder; | 1158 this.holder; |
1141 | 1159 |
1142 this.name = schema.getAttribute('name'); | 1160 this.name = schema.getAttribute('name'); |
1143 this.default = schema.getAttribute('default'); | 1161 this.default = schema.getAttribute('default'); |
1144 this.dataType = schema.getAttribute('type'); | 1162 this.dataType = schema.getAttribute('type'); |
1163 if (this.dataType == undefined) { | |
1164 if (schema.childElementCount > 0) { | |
1165 if (schema.children[0].nodeName == "xs:simpleType") { | |
1166 this.dataType = schema.getAllElementsByTagName("xs:restriction")[0].getAttribute("base"); | |
1167 } | |
1168 } | |
1169 } | |
1145 if (typeof this.dataType == "string") { this.dataType = this.dataType.substr(3);} | 1170 if (typeof this.dataType == "string") { this.dataType = this.dataType.substr(3);} |
1146 else {this.dataType = "string";} | 1171 else {this.dataType = "string";} |
1147 var minVar = undefined; | 1172 var minVar = undefined; |
1148 var maxVar = undefined; | 1173 var maxVar = undefined; |
1149 switch(this.dataType) | 1174 switch(this.dataType) |