diff test_create/test_core.js @ 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 23bbd100b403
children 26045169b4b5
line wrap: on
line diff
--- 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();