Mercurial > hg > webaudioevaluationtool
changeset 105:3c6d3f013c40
jQuery use for childNodes for manipulating set up XML. Now works on Safari
author | Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk> |
---|---|
date | Sun, 17 May 2015 21:35:30 +0100 |
parents | e4436132dbd9 |
children | f2c05f147dd2 |
files | ape.js |
diffstat | 1 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/ape.js Sun May 17 16:45:09 2015 +0100 +++ b/ape.js Sun May 17 21:35:30 2015 +0100 @@ -242,7 +242,7 @@ currentState = 'preTest'; // Create Pre-Test Box - if (preTest != undefined && preTest.children.length >= 1) + if (preTest != undefined && preTest.childElementCount >= 1) { showPopup(); preTestPopupStart(preTest); @@ -540,7 +540,7 @@ // Now process any pre-test commands var preTest = $(testXMLSetups[id]).find('PreTest')[0]; - if (preTest.children.length > 0) + if (preTest.childElementCount > 0) { currentState = 'testRunPre-'+id; preTestPopupStart(preTest); @@ -559,15 +559,15 @@ preTestOption.id = 'preTest'; preTestOption.style.marginTop = '25px'; preTestOption.align = "center"; - var child = preTest.children[0]; + var child = $(preTest).children()[0]; if (child.nodeName == 'statement') { - preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>'; + preTestOption.innerHTML = '<span>'+child.textContent+'</span>'; } else if (child.nodeName == 'question') { var questionId = child.attributes['id'].value; var textHold = document.createElement('span'); - textHold.innerHTML = child.innerHTML; + textHold.innerHTML = child.textContent; textHold.id = questionId + 'response'; var textEnter = document.createElement('textarea'); preTestOption.appendChild(textHold); @@ -619,11 +619,11 @@ // Need to find and parse preTest again! var preTestOption = document.getElementById('preTest'); // Check if current state is a question! - if (preTest.children[index].nodeName == 'question') { - var questionId = preTest.children[index].attributes['id'].value; + if ($(preTest).children()[index].nodeName == 'question') { + var questionId = $(preTest).children()[index].attributes['id'].value; var questionHold = document.createElement('comment'); var questionResponse = document.getElementById(questionId + 'response'); - var mandatory = preTest.children[index].attributes['mandatory']; + var mandatory = $(preTest).children()[index].attributes['mandatory']; if (mandatory != undefined){ if (mandatory.value == 'true') {mandatory = true;} else {mandatory = false;} @@ -636,17 +636,17 @@ postPopupResponse(questionHold); } index++; - if (index < preTest.children.length) + if (index < preTest.childElementCount) { // More to process - var child = preTest.children[index]; + var child = $(preTest).children()[index]; if (child.nodeName == 'statement') { - preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>'; + preTestOption.innerHTML = '<span>'+child.textContent+'</span>'; } else if (child.nodeName == 'question') { var textHold = document.createElement('span'); - textHold.innerHTML = child.innerHTML; + textHold.innerHTML = child.textContent; var textEnter = document.createElement('textarea'); textEnter.id = child.attributes['id'].value + 'response'; var br = document.createElement('br'); @@ -751,7 +751,7 @@ if (postXML == undefined) { testEnded(testId); } - else if (postXML.children.length > 0) + else if (postXML.childElementCount > 0) { currentState = 'testRunPost-'+testId; showPopup();