# HG changeset patch # User Nicholas Jillings # Date 1433758646 -3600 # Node ID d5d09345e8ba1512315a72c05339f955bd8e6eea # Parent 8ea4b48bbe11f91856ea831cb1692ac8ae614139 Feature #1208: Added checkbox. Bug-fix on console debug lines not showing question of survery. diff -r 8ea4b48bbe11 -r d5d09345e8ba core.js --- a/core.js Mon Jun 08 11:01:21 2015 +0100 +++ b/core.js Mon Jun 08 11:17:26 2015 +0100 @@ -226,7 +226,7 @@ var hold = document.createElement('comment'); hold.id = node.id; hold.innerHTML = textArea.value; - console.log("Question: "+ node.textContent); + console.log("Question: "+ node.question); console.log("Question Response: "+ textArea.value); this.responses.appendChild(hold); } @@ -240,8 +240,8 @@ var input = optHold.childNodes[i].getElementsByTagName('input')[0]; var statement = optHold.childNodes[i].getElementsByTagName('span')[0]; var response = document.createElement('option'); - response.setAttribute('id',input.id); - response.setAttribute('checked',input.checked); + response.setAttribute('name',input.id); + response.textContent = input.checked; hold.appendChild(response); console.log(input.id +': '+ input.checked); } @@ -1222,6 +1222,19 @@ } child = child.nextElementSibling; } + break; + case 'checkbox': + var child = xml.firstElementChild; + this.options = []; + while (child != undefined) { + if (child.nodeName == 'statement' && this.statement == undefined) { + this.statement = child.textContent; + } else if (child.nodeName == 'option') { + this.options.push(new this.childOption(child)); + } + child = child.nextElementSibling; + } + break; } }; @@ -1422,12 +1435,88 @@ response.textContent = this.options[i].getAttribute('setvalue'); response.setAttribute('number',i); } + console.log('Comment: '+question.textContent); + console.log('Response: '+response.textContent); root.appendChild(question); root.appendChild(response); return root; }; }; + this.checkboxBox = function(commentQuestion) { + this.specification = commentQuestion; + // Create document objects to hold the comment boxes + this.holder = document.createElement('div'); + this.holder.className = 'comment-div'; + // Create a string next to each comment asking for a comment + this.string = document.createElement('span'); + this.string.innerHTML = commentQuestion.statement; + var br = document.createElement('br'); + // Add to the holder. + this.holder.appendChild(this.string); + this.holder.appendChild(br); + this.options = []; + this.inputs = document.createElement('div'); + this.span = document.createElement('div'); + this.inputs.align = 'center'; + this.inputs.style.marginLeft = '12px'; + this.span.style.marginLeft = '12px'; + this.span.align = 'center'; + this.span.style.marginTop = '15px'; + + var optCount = commentQuestion.options.length; + var spanMargin = Math.floor(((600-(optCount*100))/(optCount))/2)+'px'; + console.log(spanMargin); + for (var i=0; i + + Describe this song + + + + + + Please enter the genre