comparison js/specification.js @ 2686:a005429f575b

#180. specification.js passes JSHint
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Sat, 11 Mar 2017 08:14:08 +0000
parents e4e7211842ad
children 66a24a6a0358
comparison
equal deleted inserted replaced
2685:e4e7211842ad 2686:a005429f575b
70 case "integer": 70 case "integer":
71 case "decimal": 71 case "decimal":
72 case "short": 72 case "short":
73 attribute = Number(attribute); 73 attribute = Number(attribute);
74 break; 74 break;
75 case "string":
76 default: 75 default:
77 attribute = String(attribute); 76 attribute = String(attribute);
78 break; 77 break;
79 } 78 }
80 return attribute; 79 return attribute;
313 } 312 }
314 if (this.max !== undefined) { 313 if (this.max !== undefined) {
315 node.setAttribute("max", this.max); 314 node.setAttribute("max", this.max);
316 } else { 315 } else {
317 node.setAttribute("max", "undefined"); 316 node.setAttribute("max", "undefined");
318 } 317 } /* falls through */
319 case "radio": 318 case "radio":
320 for (var i = 0; i < this.options.length; i++) { 319 for (var i = 0; i < this.options.length; i++) {
321 var option = this.options[i]; 320 var option = this.options[i];
322 var optionNode = doc.createElement("option"); 321 var optionNode = doc.createElement("option");
323 optionNode.setAttribute("name", option.name); 322 optionNode.setAttribute("name", option.name);
342 } 341 }
343 break; 342 break;
344 case "video": 343 case "video":
345 if (this.mandatory !== undefined) { 344 if (this.mandatory !== undefined) {
346 node.setAttribute("mandatory", this.mandatory); 345 node.setAttribute("mandatory", this.mandatory);
347 } 346 } /* falls through */
348 case "youtube": 347 case "youtube":
349 if (this.url !== undefined) { 348 if (this.url !== undefined) {
350 node.setAttribute("url", this.url); 349 node.setAttribute("url", this.url);
351 } 350 }
352 break; 351 break;
361 if (this.rightText) { 360 if (this.rightText) {
362 var maxText = doc.createElement("maxText"); 361 var maxText = doc.createElement("maxText");
363 maxText.textContent = this.rightText; 362 maxText.textContent = this.rightText;
364 node.appendChild(maxText); 363 node.appendChild(maxText);
365 } 364 }
365 break;
366 default: 366 default:
367 break; 367 break;
368 } 368 }
369 this.conditions.forEach(function (condition) { 369 this.conditions.forEach(function (condition) {
370 var conditionDOM = doc.createElement("conditional"); 370 var conditionDOM = doc.createElement("conditional");
689 this.min = undefined; 689 this.min = undefined;
690 this.max = undefined; 690 this.max = undefined;
691 this.step = undefined; 691 this.step = undefined;
692 break; 692 break;
693 case "commentquestion": 693 case "commentquestion":
694 this.type = "question";
695 break;
694 default: 696 default:
695 this.type = "question"; 697 throw ("Unknown comment type " + xml.nodeName);
696 break;
697 } 698 }
698 this.statement = xml.getElementsByTagName('statement')[0].textContent; 699 this.statement = xml.getElementsByTagName('statement')[0].textContent;
699 if (this.type == "radio" || this.type == "checkbox") { 700 if (this.type == "radio" || this.type == "checkbox") {
700 var optNodes = xml.getElementsByTagName('option'); 701 var optNodes = xml.getElementsByTagName('option');
701 for (var i = 0; i < optNodes.length; i++) { 702 for (var i = 0; i < optNodes.length; i++) {
743 break; 744 break;
744 case "slider": 745 case "slider":
745 node = root.createElement("commentslider"); 746 node = root.createElement("commentslider");
746 break; 747 break;
747 case "question": 748 case "question":
749 node = root.createElement("commentquestion");
750 break;
748 default: 751 default:
749 node = root.createElement("commentquestion"); 752 throw ("Unknown type " + this.type);
750 break;
751 } 753 }
752 node.id = this.id; 754 node.id = this.id;
753 node.setAttribute("type", this.type); 755 node.setAttribute("type", this.type);
754 if (this.name !== undefined) { 756 if (this.name !== undefined) {
755 node.setAttribute("name", this.name); 757 node.setAttribute("name", this.name);