changeset 1092:e4b378468589

Merge
author Brecht De Man <BrechtDeMan@users.noreply.github.com>
date Thu, 10 Mar 2016 10:38:31 +0100
parents cfbd8ff10757
children f4f9cde581aa
files core.js test_create/test_create.html
diffstat 2 files changed, 56 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/core.js	Wed Mar 09 15:44:47 2016 +0000
+++ b/core.js	Thu Mar 10 10:38:31 2016 +0100
@@ -351,6 +351,7 @@
                 if (response.getAttribute("state") == "OK") {
                     var file = response.getElementsByTagName("file")[0];
                     console.log("Save: OK, written "+file.getAttribute("bytes")+"B");
+                    popup.popupContent.textContent = "Thank you. Your session has been saved.";
                 } else {
                     var message = response.getElementsByTagName("message");
                     console.log("Save: Error! "+message.textContent);
@@ -1916,6 +1917,7 @@
 			this.type = undefined;
 			this.schema = specification.schema.getAllElementsByName('surveyentry')[0];
 			this.id = undefined;
+            this.name = undefined;
 			this.mandatory = undefined;
 			this.statement = undefined;
 			this.boxsize = undefined;
@@ -1971,34 +1973,32 @@
 				var statement = doc.createElement('statement');
 				statement.textContent = this.statement;
 				node.appendChild(statement);
-				switch(this.type)
-				{
-				case "statement":
-					break;
-				case "question":
+                if (this.type != "statement") {
                     node.id = this.id;
+                    if (this.name != undefined) { node.setAttribute("name",this.name);}
                     if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
-                    if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
-                    break;
-                case "number":
-                    node.id = this.id;
-                    if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
-                    if (this.min != undefined) {node.setAttribute("min", this.min);}
-                    if (this.max != undefined) {node.setAttribute("max", this.max);}
-                    break;
-				case "checkbox":
-				case "radio":
-					node.id = this.id;
-					for (var i=0; i<this.options.length; i++)
-					{
-						var option = this.options[i];
-						var optionNode = doc.createElement("option");
-						optionNode.setAttribute("name",option.name);
-						optionNode.textContent = option.text;
-						node.appendChild(optionNode);
-					}
-					break;
-				}
+                    switch(this.type)
+                    {
+                    case "question":
+                        if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
+                        break;
+                    case "number":
+                        if (this.min != undefined) {node.setAttribute("min", this.min);}
+                        if (this.max != undefined) {node.setAttribute("max", this.max);}
+                        break;
+                    case "checkbox":
+                    case "radio":
+                        for (var i=0; i<this.options.length; i++)
+                        {
+                            var option = this.options[i];
+                            var optionNode = doc.createElement("option");
+                            optionNode.setAttribute("name",option.name);
+                            optionNode.textContent = option.text;
+                            node.appendChild(optionNode);
+                        }
+                        break;
+                    }
+                }
 				return node;
 			};
 		};
@@ -2265,6 +2265,7 @@
 		
 		this.commentQuestionNode = function() {
 			this.id = null;
+            this.name = undefined;
 			this.type = undefined;
 			this.options = [];
 			this.statement = undefined;
@@ -2272,6 +2273,7 @@
 			this.decode = function(parent,xml)
 			{
 				this.id = xml.id;
+                this.name = xml.getAttribute('name');
 				this.type = xml.getAttribute('type');
 				this.statement = xml.getElementsByTagName('statement')[0].textContent;
 				var optNodes = xml.getElementsByTagName('option');
@@ -2290,6 +2292,7 @@
 				var node = root.createElement("commentquestion");
                 node.id = this.id;
                 node.setAttribute("type",this.type);
+                if (this.name != undefined){node.setAttribute("name",this.name);}
                 var statement = root.createElement("statement");
                 statement.textContent = this.statement;
                 node.appendChild(statement);
@@ -2307,6 +2310,7 @@
 		this.audioElementNode = function() {
 			this.url = null;
 			this.id = null;
+            this.name = null;
 			this.parent = null;
 			this.type = null;
 			this.marker = null;
--- a/test_create/test_create.html	Wed Mar 09 15:44:47 2016 +0000
+++ b/test_create/test_create.html	Thu Mar 10 10:38:31 2016 +0100
@@ -180,6 +180,7 @@
                     this.type = undefined;
                     this.schema = specification.schema.getAllElementsByName('surveyentry')[0];
                     this.id = undefined;
+                    this.name = undefined;
                     this.mandatory = undefined;
                     this.statement = undefined;
                     this.boxsize = undefined;
@@ -235,33 +236,31 @@
                         var statement = doc.createElement('statement');
                         statement.textContent = this.statement;
                         node.appendChild(statement);
-                        switch(this.type)
-                        {
-                        case "statement":
-                            break;
-                        case "question":
+                        if (this.type != "statement") {
                             node.id = this.id;
+                            if (this.name != undefined) { node.setAttribute("name",this.name);}
                             if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
-                            if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
-                            break;
-                        case "number":
-                            node.id = this.id;
-                            if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
-                            if (this.min != undefined) {node.setAttribute("min", this.min);}
-                            if (this.max != undefined) {node.setAttribute("max", this.max);}
-                            break;
-                        case "checkbox":
-                        case "radio":
-                            node.id = this.id;
-                            for (var i=0; i<this.options.length; i++)
+                            switch(this.type)
                             {
-                                var option = this.options[i];
-                                var optionNode = doc.createElement("option");
-                                optionNode.setAttribute("name",option.name);
-                                optionNode.textContent = option.text;
-                                node.appendChild(optionNode);
+                            case "question":
+                                if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
+                                break;
+                            case "number":
+                                if (this.min != undefined) {node.setAttribute("min", this.min);}
+                                if (this.max != undefined) {node.setAttribute("max", this.max);}
+                                break;
+                            case "checkbox":
+                            case "radio":
+                                for (var i=0; i<this.options.length; i++)
+                                {
+                                    var option = this.options[i];
+                                    var optionNode = doc.createElement("option");
+                                    optionNode.setAttribute("name",option.name);
+                                    optionNode.textContent = option.text;
+                                    node.appendChild(optionNode);
+                                }
+                                break;
                             }
-                            break;
                         }
                         return node;
                     };
@@ -529,6 +528,7 @@
 
                 this.commentQuestionNode = function() {
                     this.id = null;
+                    this.name = undefined;
                     this.type = undefined;
                     this.options = [];
                     this.statement = undefined;
@@ -536,6 +536,7 @@
                     this.decode = function(parent,xml)
                     {
                         this.id = xml.id;
+                        this.name = xml.getAttribute('name');
                         this.type = xml.getAttribute('type');
                         this.statement = xml.getElementsByTagName('statement')[0].textContent;
                         var optNodes = xml.getElementsByTagName('option');
@@ -554,6 +555,7 @@
                         var node = root.createElement("commentquestion");
                         node.id = this.id;
                         node.setAttribute("type",this.type);
+                        if (this.name != undefined){node.setAttribute("name",this.name);}
                         var statement = root.createElement("statement");
                         statement.textContent = this.statement;
                         node.appendChild(statement);
@@ -571,6 +573,7 @@
                 this.audioElementNode = function() {
                     this.url = null;
                     this.id = null;
+                    this.name = null;
                     this.parent = null;
                     this.type = null;
                     this.marker = null;