changeset 2562:9c167c0d6c26

Added video and youtube creation to test_create #134
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Fri, 02 Sep 2016 11:38:09 +0100
parents f0b0809c7ee5
children b2df2be58fc2
files js/specification.js test_create/test_core.js xml/test-schema.xsd
diffstat 3 files changed, 66 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/js/specification.js	Thu Aug 25 10:50:00 2016 +0100
+++ b/js/specification.js	Fri Sep 02 11:38:09 2016 +0100
@@ -290,12 +290,20 @@
                             optionNode.textContent = option.text;
                             node.appendChild(optionNode);
                         }
+                        break;
                     case "number":
                         if (this.min != undefined) {node.setAttribute("min", this.min);}
                         if (this.max != undefined) {node.setAttribute("max", this.max);}
+                        break;
                     case "question":
                         if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
                         if (this.mandatory != undefined) {node.setAttribute("mandatory",this.mandatory);}
+                        break;
+                    case "video":
+                        if (this.mandatory != undefined) {node.setAttribute("mandatory",this.mandatory);}
+                    case "youtube":
+                        if (this.url != undefined) {node.setAttribute("url",this.url);}
+                        break;
                     default:
                         break;
                 }
--- a/test_create/test_core.js	Thu Aug 25 10:50:00 2016 +0100
+++ b/test_create/test_core.js	Fri Sep 02 11:38:09 2016 +0100
@@ -855,6 +855,36 @@
                         maximumEntry.value = this.option.max;
                         this.dynamic.appendChild(maximum);
                         break;
+                    case "video":
+                    case "youtube":
+                        this.dynamic.appendChild(id);
+                        
+                        var mandatory = document.createElement("div");
+                        var mandatoryInput = document.createElement("input");
+                        var mandatoryText = document.createElement("span");
+                        mandatoryText.textContent = "Mandatory: ";
+                        mandatory.appendChild(mandatoryText);
+                        mandatory.appendChild(mandatoryInput);
+                        mandatory.className = "survey-entry-attribute";
+                        mandatoryInput.type = "checkbox";
+                        if (this.option.mandatory) {mandatoryInput.checked = true;} else {mandatoryInput.checked = false;}
+                        mandatoryInput.setAttribute("name","mandatory");
+                        mandatoryInput.addEventListener("change",this,false);
+                        this.dynamic.appendChild(mandatory);
+                        
+                        var url = document.createElement("div");
+                        var urlInput = document.createElement("input");
+                        var urlText = document.createElement("span");
+                        urlText.textContent = "URL: ";
+                        url.appendChild(urlText);
+                        url.appendChild(urlInput);
+                        url.className = "survey-entry-attribute";
+                        urlInput.type = "text";
+                        if (this.option.mandatory) {urlInput.value = this.option.mandatory;} else {urlInput.value = "";}
+                        urlInput.setAttribute("name","url");
+                        urlInput.addEventListener("change",this,false);
+                        this.dynamic.appendChild(url);
+                        break;
                     case "checkbox":
                     case "radio":
                         this.dynamic.appendChild(id);
@@ -938,7 +968,7 @@
                         this.dynamic.appendChild(optionHolder);
                 }
             }
-            this.handleEvent = function()
+            this.handleEvent = function(event)
             {
                 var name = event.currentTarget.getAttribute("name");
                 var nodeName = event.currentTarget.nodeName;
@@ -1888,6 +1918,8 @@
                         var max = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("max")[0]);
                         this.attributeDOM.appendChild(id.holder);
                         this.attributes.push(id);
+                        this.attributeDOM.appendChild(mandatory.holder);
+                        this.attributes.push(mandatory);
                         this.attributeDOM.appendChild(min.holder);
                         this.attributes.push(min);
                         this.attributeDOM.appendChild(max.holder);
@@ -1905,6 +1937,30 @@
                         this.attributeDOM.appendChild(id.holder);
                         this.attributes.push(id);
                         break;
+                    case "video":
+                        this.titleDOM.textContent = "Video";
+                        var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]);
+                        this.attributeDOM.appendChild(id.holder);
+                        this.attributes.push(id);
+                        var mandatory = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("mandatory")[0]);
+                        var url = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("url")[0]);
+                        this.attributeDOM.appendChild(mandatory.holder);
+                        this.attributes.push(mandatory);
+                        this.attributeDOM.appendChild(url.holder);
+                        this.attributes.push(url);
+                        break;
+                    case "youtube":
+                        this.titleDOM.textContent = "YouTube";
+                        var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]);
+                        this.attributeDOM.appendChild(id.holder);
+                        this.attributes.push(id);
+                        var mandatory = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("mandatory")[0]);
+                        var url = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("url")[0]);
+                        this.attributeDOM.appendChild(mandatory.holder);
+                        this.attributes.push(mandatory);
+                        this.attributeDOM.appendChild(url.holder);
+                        this.attributes.push(url);
+                        break;
                 }
             }
             this.build();
--- a/xml/test-schema.xsd	Thu Aug 25 10:50:00 2016 +0100
+++ b/xml/test-schema.xsd	Fri Sep 02 11:38:09 2016 +0100
@@ -295,7 +295,7 @@
                                     </xs:restriction>
                                 </xs:simpleType>
                             </xs:attribute>
-                            <xs:attribute name="url" type="xs:string" use="optional"/>
+                            <xs:attribute name="url" type="xs:string" use="optional" default=""/>
                         </xs:complexType>
                     </xs:element>
                 </xs:sequence>