# HG changeset patch # User Nicholas Jillings # Date 1432718164 -3600 # Node ID 2910699456bbef9f0996a0eff993bebadfa38635 # Parent c35bd010cebb96a749ce75157edf1d95cc5a2ea1 Removed redundant code from ape.js diff -r c35bd010cebb -r 2910699456bb ape.js --- a/ape.js Wed May 27 09:46:06 2015 +0100 +++ b/ape.js Wed May 27 10:16:04 2015 +0100 @@ -488,154 +488,13 @@ } } -function preTestPopupStart(preTest) -{ - var popupHolder = document.getElementById('popupHolder'); - popupHolder.innerHTML = null; - // Parse the first box - var preTestOption = document.createElement('div'); - preTestOption.id = 'preTest'; - preTestOption.style.marginTop = '25px'; - preTestOption.align = "center"; - var child = $(preTest).children()[0]; - if (child.nodeName == 'statement') - { - preTestOption.innerHTML = ''+child.textContent+''; - } else if (child.nodeName == 'question') - { - var textHold = document.createElement('span'); - textHold.innerHTML = child.textContent; - var textEnter = document.createElement('textarea'); - textEnter.id = child.attributes['id'].value + 'response'; - var br = document.createElement('br'); - preTestOption.innerHTML = null; - preTestOption.appendChild(textHold); - preTestOption.appendChild(br); - preTestOption.appendChild(textEnter); - } - var nextButton = document.createElement('button'); - nextButton.className = 'popupButton'; - nextButton.value = '0'; - nextButton.innerHTML = 'Next'; - nextButton.onclick = popupButtonClick; - - popupHolder.appendChild(preTestOption); - popupHolder.appendChild(nextButton); -} - -function popupButtonClick() -{ - // Global call from the 'Next' button click - if (currentState == 'preTest') - { - // At the start of the preTest routine! - var xmlTree = projectXML.find('setup'); - var preTest = xmlTree.find('PreTest')[0]; - this.value = preTestButtonClick(preTest,this.value); - } else if (currentState.substr(0,10) == 'testRunPre') - { - //Specific test pre-test - var testId = currentState.substr(11,currentState.length-10); - var preTest = $(testXMLSetups[testId]).find('PreTest')[0]; - this.value = preTestButtonClick(preTest,this.value); - } else if (currentState.substr(0,11) == 'testRunPost') - { - // Specific test post-test - var testId = currentState.substr(12,currentState.length-11); - var preTest = $(testXMLSetups[testId]).find('PostTest')[0]; - this.value = preTestButtonClick(preTest,this.value); - } else if (currentState == 'postTest') - { - // At the end of the test, running global post test - var xmlTree = projectXML.find('setup'); - var PostTest = xmlTree.find('PostTest')[0]; - this.value = preTestButtonClick(PostTest,this.value); - } -} - -function preTestButtonClick(preTest,index) -{ - // Called on click of pre-test button - // 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; - var questionHold = document.createElement('comment'); - var questionResponse = document.getElementById(questionId + 'response'); - var mandatory = $(preTest).children()[index].attributes['mandatory']; - if (mandatory != undefined){ - if (mandatory.value == 'true') {mandatory = true;} - else {mandatory = false;} - } else {mandatory = false;} - if (mandatory == true && questionResponse.value.length == 0) { - return index; - } - questionHold.id = questionId; - questionHold.innerHTML = questionResponse.value; - postPopupResponse(questionHold); - } - index++; - if (index < preTest.childElementCount) - { - // More to process - var child = $(preTest).children()[index]; - if (child.nodeName == 'statement') - { - preTestOption.innerHTML = ''+child.textContent+''; - } else if (child.nodeName == 'question') - { - var textHold = document.createElement('span'); - textHold.innerHTML = child.textContent; - var textEnter = document.createElement('textarea'); - textEnter.id = child.attributes['id'].value + 'response'; - var br = document.createElement('br'); - preTestOption.innerHTML = null; - preTestOption.appendChild(textHold); - preTestOption.appendChild(br); - preTestOption.appendChild(textEnter); - } - } else { - // Time to clear - preTestOption.innerHTML = null; - if (currentState != 'postTest') { - popup.hidePopup(); - // Progress the state! - advanceState(); - } else { - a = createProjectSave(projectReturn); - preTestOption.appendChild(a); - } - } - return index; -} - -function postPopupResponse(response) -{ - if (currentState == 'preTest') { - preTestQuestions.appendChild(response); - } else if (currentState == 'postTest') { - postTestQuestions.appendChild(response); - } else { - // Inside a specific test - if (currentState.substr(0,10) == 'testRunPre') { - // Pre Test - var store = $(currentTestHolder).find('preTest'); - } else { - // Post Test - var store = $(currentTestHolder).find('postTest'); - } - store[0].appendChild(response); - } -} - function dragEnd(ev) { // Function call when a div has been dropped var slider = document.getElementById('slider'); var w = slider.style.width; w = Number(w.substr(0,w.length-2)); - var x = ev.x; + var x = ev.x - ev.screenX; if (x >= 42 && x < w+42) { this.style.left = (x)+'px'; } else {