comparison core.js @ 599:d1d7b49fbeea

Merge
author Brecht De Man <b.deman@qmul.ac.uk>
date Thu, 10 Mar 2016 10:38:31 +0100
parents b3404426839d 5a3b74e95d4a
children 0df685136c89
comparison
equal deleted inserted replaced
598:b3404426839d 599:d1d7b49fbeea
349 var xmlDoc = parser.parseFromString(xmlhttp.responseText, "application/xml"); 349 var xmlDoc = parser.parseFromString(xmlhttp.responseText, "application/xml");
350 var response = xmlDoc.getElementsByTagName('response')[0]; 350 var response = xmlDoc.getElementsByTagName('response')[0];
351 if (response.getAttribute("state") == "OK") { 351 if (response.getAttribute("state") == "OK") {
352 var file = response.getElementsByTagName("file")[0]; 352 var file = response.getElementsByTagName("file")[0];
353 console.log("Save: OK, written "+file.getAttribute("bytes")+"B"); 353 console.log("Save: OK, written "+file.getAttribute("bytes")+"B");
354 popup.popupContent.textContent = "Thank you. Your session has been saved.";
354 } else { 355 } else {
355 var message = response.getElementsByTagName("message"); 356 var message = response.getElementsByTagName("message");
356 console.log("Save: Error! "+message.textContent); 357 console.log("Save: Error! "+message.textContent);
357 createProjectSave("local"); 358 createProjectSave("local");
358 } 359 }
1914 1915
1915 this.OptionNode = function() { 1916 this.OptionNode = function() {
1916 this.type = undefined; 1917 this.type = undefined;
1917 this.schema = specification.schema.getAllElementsByName('surveyentry')[0]; 1918 this.schema = specification.schema.getAllElementsByName('surveyentry')[0];
1918 this.id = undefined; 1919 this.id = undefined;
1920 this.name = undefined;
1919 this.mandatory = undefined; 1921 this.mandatory = undefined;
1920 this.statement = undefined; 1922 this.statement = undefined;
1921 this.boxsize = undefined; 1923 this.boxsize = undefined;
1922 this.options = []; 1924 this.options = [];
1923 this.min = undefined; 1925 this.min = undefined;
1969 var node = doc.createElement('surveyentry'); 1971 var node = doc.createElement('surveyentry');
1970 node.setAttribute('type',this.type); 1972 node.setAttribute('type',this.type);
1971 var statement = doc.createElement('statement'); 1973 var statement = doc.createElement('statement');
1972 statement.textContent = this.statement; 1974 statement.textContent = this.statement;
1973 node.appendChild(statement); 1975 node.appendChild(statement);
1974 switch(this.type) 1976 if (this.type != "statement") {
1975 {
1976 case "statement":
1977 break;
1978 case "question":
1979 node.id = this.id; 1977 node.id = this.id;
1978 if (this.name != undefined) { node.setAttribute("name",this.name);}
1980 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} 1979 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
1981 if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);} 1980 switch(this.type)
1982 break; 1981 {
1983 case "number": 1982 case "question":
1984 node.id = this.id; 1983 if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
1985 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} 1984 break;
1986 if (this.min != undefined) {node.setAttribute("min", this.min);} 1985 case "number":
1987 if (this.max != undefined) {node.setAttribute("max", this.max);} 1986 if (this.min != undefined) {node.setAttribute("min", this.min);}
1988 break; 1987 if (this.max != undefined) {node.setAttribute("max", this.max);}
1989 case "checkbox": 1988 break;
1990 case "radio": 1989 case "checkbox":
1991 node.id = this.id; 1990 case "radio":
1992 for (var i=0; i<this.options.length; i++) 1991 for (var i=0; i<this.options.length; i++)
1993 { 1992 {
1994 var option = this.options[i]; 1993 var option = this.options[i];
1995 var optionNode = doc.createElement("option"); 1994 var optionNode = doc.createElement("option");
1996 optionNode.setAttribute("name",option.name); 1995 optionNode.setAttribute("name",option.name);
1997 optionNode.textContent = option.text; 1996 optionNode.textContent = option.text;
1998 node.appendChild(optionNode); 1997 node.appendChild(optionNode);
1999 } 1998 }
2000 break; 1999 break;
2001 } 2000 }
2001 }
2002 return node; 2002 return node;
2003 }; 2003 };
2004 }; 2004 };
2005 this.decode = function(parent,xml) { 2005 this.decode = function(parent,xml) {
2006 this.location = xml.getAttribute('location'); 2006 this.location = xml.getAttribute('location');
2263 return AHNode; 2263 return AHNode;
2264 }; 2264 };
2265 2265
2266 this.commentQuestionNode = function() { 2266 this.commentQuestionNode = function() {
2267 this.id = null; 2267 this.id = null;
2268 this.name = undefined;
2268 this.type = undefined; 2269 this.type = undefined;
2269 this.options = []; 2270 this.options = [];
2270 this.statement = undefined; 2271 this.statement = undefined;
2271 this.schema = specification.schema.getAllElementsByName('commentquestion')[0]; 2272 this.schema = specification.schema.getAllElementsByName('commentquestion')[0];
2272 this.decode = function(parent,xml) 2273 this.decode = function(parent,xml)
2273 { 2274 {
2274 this.id = xml.id; 2275 this.id = xml.id;
2276 this.name = xml.getAttribute('name');
2275 this.type = xml.getAttribute('type'); 2277 this.type = xml.getAttribute('type');
2276 this.statement = xml.getElementsByTagName('statement')[0].textContent; 2278 this.statement = xml.getElementsByTagName('statement')[0].textContent;
2277 var optNodes = xml.getElementsByTagName('option'); 2279 var optNodes = xml.getElementsByTagName('option');
2278 for (var i=0; i<optNodes.length; i++) 2280 for (var i=0; i<optNodes.length; i++)
2279 { 2281 {
2288 this.encode = function(root) 2290 this.encode = function(root)
2289 { 2291 {
2290 var node = root.createElement("commentquestion"); 2292 var node = root.createElement("commentquestion");
2291 node.id = this.id; 2293 node.id = this.id;
2292 node.setAttribute("type",this.type); 2294 node.setAttribute("type",this.type);
2295 if (this.name != undefined){node.setAttribute("name",this.name);}
2293 var statement = root.createElement("statement"); 2296 var statement = root.createElement("statement");
2294 statement.textContent = this.statement; 2297 statement.textContent = this.statement;
2295 node.appendChild(statement); 2298 node.appendChild(statement);
2296 for (var option of this.options) 2299 for (var option of this.options)
2297 { 2300 {
2305 }; 2308 };
2306 2309
2307 this.audioElementNode = function() { 2310 this.audioElementNode = function() {
2308 this.url = null; 2311 this.url = null;
2309 this.id = null; 2312 this.id = null;
2313 this.name = null;
2310 this.parent = null; 2314 this.parent = null;
2311 this.type = null; 2315 this.type = null;
2312 this.marker = null; 2316 this.marker = null;
2313 this.enforce = false; 2317 this.enforce = false;
2314 this.gain = 0.0; 2318 this.gain = 0.0;