# HG changeset patch # User Nicholas Jillings # Date 1472812689 -3600 # Node ID 9c167c0d6c26a9afd6a949c8966beb7a009dd0f8 # Parent f0b0809c7ee5b0cb9b2be3c5924b96ab89825e19 Added video and youtube creation to test_create #134 diff -r f0b0809c7ee5 -r 9c167c0d6c26 js/specification.js --- 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; } diff -r f0b0809c7ee5 -r 9c167c0d6c26 test_create/test_core.js --- 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(); diff -r f0b0809c7ee5 -r 9c167c0d6c26 xml/test-schema.xsd --- 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 @@ - +