comparison core.js @ 2156:08fab304c10e

Updated specification object to reflect schema changes
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 09 Mar 2016 15:00:19 +0000
parents 9abb207d2f6a
children ba6b9e1aaef5
comparison
equal deleted inserted replaced
2155:9abb207d2f6a 2156:08fab304c10e
1915 1915
1916 this.OptionNode = function() { 1916 this.OptionNode = function() {
1917 this.type = undefined; 1917 this.type = undefined;
1918 this.schema = specification.schema.getAllElementsByName('surveyentry')[0]; 1918 this.schema = specification.schema.getAllElementsByName('surveyentry')[0];
1919 this.id = undefined; 1919 this.id = undefined;
1920 this.name = undefined;
1920 this.mandatory = undefined; 1921 this.mandatory = undefined;
1921 this.statement = undefined; 1922 this.statement = undefined;
1922 this.boxsize = undefined; 1923 this.boxsize = undefined;
1923 this.options = []; 1924 this.options = [];
1924 this.min = undefined; 1925 this.min = undefined;
1970 var node = doc.createElement('surveyentry'); 1971 var node = doc.createElement('surveyentry');
1971 node.setAttribute('type',this.type); 1972 node.setAttribute('type',this.type);
1972 var statement = doc.createElement('statement'); 1973 var statement = doc.createElement('statement');
1973 statement.textContent = this.statement; 1974 statement.textContent = this.statement;
1974 node.appendChild(statement); 1975 node.appendChild(statement);
1975 switch(this.type) 1976 if (this.type != "statement") {
1976 {
1977 case "statement":
1978 break;
1979 case "question":
1980 node.id = this.id; 1977 node.id = this.id;
1978 if (this.name != undefined) { node.setAttribute("name",this.name);}
1981 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} 1979 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
1982 if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);} 1980 switch(this.type)
1983 break; 1981 {
1984 case "number": 1982 case "question":
1985 node.id = this.id; 1983 if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
1986 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} 1984 break;
1987 if (this.min != undefined) {node.setAttribute("min", this.min);} 1985 case "number":
1988 if (this.max != undefined) {node.setAttribute("max", this.max);} 1986 if (this.min != undefined) {node.setAttribute("min", this.min);}
1989 break; 1987 if (this.max != undefined) {node.setAttribute("max", this.max);}
1990 case "checkbox": 1988 break;
1991 case "radio": 1989 case "checkbox":
1992 node.id = this.id; 1990 case "radio":
1993 for (var i=0; i<this.options.length; i++) 1991 for (var i=0; i<this.options.length; i++)
1994 { 1992 {
1995 var option = this.options[i]; 1993 var option = this.options[i];
1996 var optionNode = doc.createElement("option"); 1994 var optionNode = doc.createElement("option");
1997 optionNode.setAttribute("name",option.name); 1995 optionNode.setAttribute("name",option.name);
1998 optionNode.textContent = option.text; 1996 optionNode.textContent = option.text;
1999 node.appendChild(optionNode); 1997 node.appendChild(optionNode);
2000 } 1998 }
2001 break; 1999 break;
2002 } 2000 }
2001 }
2003 return node; 2002 return node;
2004 }; 2003 };
2005 }; 2004 };
2006 this.decode = function(parent,xml) { 2005 this.decode = function(parent,xml) {
2007 this.location = xml.getAttribute('location'); 2006 this.location = xml.getAttribute('location');
2264 return AHNode; 2263 return AHNode;
2265 }; 2264 };
2266 2265
2267 this.commentQuestionNode = function() { 2266 this.commentQuestionNode = function() {
2268 this.id = null; 2267 this.id = null;
2268 this.name = undefined;
2269 this.type = undefined; 2269 this.type = undefined;
2270 this.options = []; 2270 this.options = [];
2271 this.statement = undefined; 2271 this.statement = undefined;
2272 this.schema = specification.schema.getAllElementsByName('commentquestion')[0]; 2272 this.schema = specification.schema.getAllElementsByName('commentquestion')[0];
2273 this.decode = function(parent,xml) 2273 this.decode = function(parent,xml)
2274 { 2274 {
2275 this.id = xml.id; 2275 this.id = xml.id;
2276 this.name = xml.getAttribute('name');
2276 this.type = xml.getAttribute('type'); 2277 this.type = xml.getAttribute('type');
2277 this.statement = xml.getElementsByTagName('statement')[0].textContent; 2278 this.statement = xml.getElementsByTagName('statement')[0].textContent;
2278 var optNodes = xml.getElementsByTagName('option'); 2279 var optNodes = xml.getElementsByTagName('option');
2279 for (var i=0; i<optNodes.length; i++) 2280 for (var i=0; i<optNodes.length; i++)
2280 { 2281 {
2289 this.encode = function(root) 2290 this.encode = function(root)
2290 { 2291 {
2291 var node = root.createElement("commentquestion"); 2292 var node = root.createElement("commentquestion");
2292 node.id = this.id; 2293 node.id = this.id;
2293 node.setAttribute("type",this.type); 2294 node.setAttribute("type",this.type);
2295 if (this.name != undefined){node.setAttribute("name",this.name);}
2294 var statement = root.createElement("statement"); 2296 var statement = root.createElement("statement");
2295 statement.textContent = this.statement; 2297 statement.textContent = this.statement;
2296 node.appendChild(statement); 2298 node.appendChild(statement);
2297 for (var option of this.options) 2299 for (var option of this.options)
2298 { 2300 {
2306 }; 2308 };
2307 2309
2308 this.audioElementNode = function() { 2310 this.audioElementNode = function() {
2309 this.url = null; 2311 this.url = null;
2310 this.id = null; 2312 this.id = null;
2313 this.name = null;
2311 this.parent = null; 2314 this.parent = null;
2312 this.type = null; 2315 this.type = null;
2313 this.marker = null; 2316 this.marker = null;
2314 this.enforce = false; 2317 this.enforce = false;
2315 this.gain = 0.0; 2318 this.gain = 0.0;