n@893: /** n@893: * core.js n@893: * n@893: * Main script to run, calls all other core functions and manages loading/store to backend. n@893: * Also contains all global variables. n@893: */ n@893: n@893: /* create the web audio API context and store in audioContext*/ n@893: var audioContext; // Hold the browser web audio API n@893: var projectXML; // Hold the parsed setup XML n@893: var specification; n@893: var interfaceContext; n@893: var popup; // Hold the interfacePopup object n@893: var testState; n@893: var currentTrackOrder = []; // Hold the current XML tracks in their (randomised) order n@893: var audioEngineContext; // The custome AudioEngine object n@893: var projectReturn; // Hold the URL for the return n@893: n@893: n@893: // Add a prototype to the bufferSourceNode to reference to the audioObject holding it n@893: AudioBufferSourceNode.prototype.owner = undefined; n@893: n@893: window.onload = function() { n@893: // Function called once the browser has loaded all files. n@893: // This should perform any initial commands such as structure / loading documents n@893: n@893: // Create a web audio API context n@893: // Fixed for cross-browser support n@893: var AudioContext = window.AudioContext || window.webkitAudioContext; n@893: audioContext = new AudioContext; n@893: n@893: // Create test state n@893: testState = new stateMachine(); n@893: n@893: // Create the audio engine object n@893: audioEngineContext = new AudioEngine(); n@893: n@893: // Create the popup interface object n@893: popup = new interfacePopup(); n@893: n@893: // Create the specification object n@893: specification = new Specification(); n@893: n@893: // Create the interface object n@893: interfaceContext = new Interface(specification); n@893: }; n@893: n@893: function interfacePopup() { n@893: // Creates an object to manage the popup n@893: this.popup = null; n@893: this.popupContent = null; n@893: this.buttonProceed = null; n@893: this.buttonPrevious = null; n@893: this.popupOptions = null; n@893: this.currentIndex = null; n@893: this.responses = null; n@893: n@893: this.createPopup = function(){ n@893: // Create popup window interface n@893: var insertPoint = document.getElementById("topLevelBody"); n@893: var blank = document.createElement('div'); n@893: blank.className = 'testHalt'; n@893: n@893: this.popup = document.createElement('div'); n@893: this.popup.id = 'popupHolder'; n@893: this.popup.className = 'popupHolder'; n@893: this.popup.style.position = 'absolute'; n@893: this.popup.style.left = (window.innerWidth/2)-250 + 'px'; n@893: this.popup.style.top = (window.innerHeight/2)-125 + 'px'; n@893: n@893: this.popupContent = document.createElement('div'); n@893: this.popupContent.id = 'popupContent'; n@893: this.popupContent.style.marginTop = '25px'; n@893: this.popupContent.align = 'center'; n@893: this.popup.appendChild(this.popupContent); n@893: n@893: this.buttonProceed = document.createElement('button'); n@893: this.buttonProceed.className = 'popupButton'; n@893: this.buttonProceed.style.left = '440px'; n@893: this.buttonProceed.style.top = '215px'; n@893: this.buttonProceed.innerHTML = 'Next'; n@893: this.buttonProceed.onclick = function(){popup.proceedClicked();}; n@893: n@893: this.buttonPrevious = document.createElement('button'); n@893: this.buttonPrevious.className = 'popupButton'; n@893: this.buttonPrevious.style.left = '10px'; n@893: this.buttonPrevious.style.top = '215px'; n@893: this.buttonPrevious.innerHTML = 'Back'; n@893: this.buttonPrevious.onclick = function(){popup.previousClick();}; n@893: n@893: this.popup.style.zIndex = -1; n@893: this.popup.style.visibility = 'hidden'; n@893: blank.style.zIndex = -2; n@893: blank.style.visibility = 'hidden'; n@893: insertPoint.appendChild(this.popup); n@893: insertPoint.appendChild(blank); n@893: }; n@893: n@893: this.showPopup = function(){ n@893: if (this.popup == null) { n@893: this.createPopup(); n@893: } n@893: this.popup.style.zIndex = 3; n@893: this.popup.style.visibility = 'visible'; n@893: var blank = document.getElementsByClassName('testHalt')[0]; n@893: blank.style.zIndex = 2; n@893: blank.style.visibility = 'visible'; n@893: }; n@893: n@893: this.hidePopup = function(){ n@893: this.popup.style.zIndex = -1; n@893: this.popup.style.visibility = 'hidden'; n@893: var blank = document.getElementsByClassName('testHalt')[0]; n@893: blank.style.zIndex = -2; n@893: blank.style.visibility = 'hidden'; n@893: }; n@893: n@893: this.postNode = function() { n@893: // This will take the node from the popupOptions and display it n@893: var node = this.popupOptions[this.currentIndex]; n@893: this.popupContent.innerHTML = null; n@893: if (node.type == 'statement') { n@893: var span = document.createElement('span'); n@893: span.textContent = node.statement; n@893: this.popupContent.appendChild(span); n@893: } else if (node.type == 'question') { n@893: var span = document.createElement('span'); n@893: span.textContent = node.question; n@893: var textArea = document.createElement('textarea'); n@893: switch (node.boxsize) { n@893: case 'small': n@893: textArea.cols = "20"; n@893: textArea.rows = "1"; n@893: break; n@893: case 'normal': n@893: textArea.cols = "30"; n@893: textArea.rows = "2"; n@893: break; n@893: case 'large': n@893: textArea.cols = "40"; n@893: textArea.rows = "5"; n@893: break; n@893: case 'huge': n@893: textArea.cols = "50"; n@893: textArea.rows = "10"; n@893: break; n@893: } n@893: var br = document.createElement('br'); n@893: this.popupContent.appendChild(span); n@893: this.popupContent.appendChild(br); n@893: this.popupContent.appendChild(textArea); n@893: this.popupContent.childNodes[2].focus(); n@893: } else if (node.type == 'checkbox') { n@893: var span = document.createElement('span'); n@893: span.textContent = node.statement; n@893: this.popupContent.appendChild(span); n@893: var optHold = document.createElement('div'); n@893: optHold.id = 'option-holder'; n@893: optHold.align = 'left'; n@893: for (var i=0; i 0) n@893: this.popupContent.appendChild(this.buttonPrevious); n@893: }; n@893: n@893: this.initState = function(node) { n@893: //Call this with your preTest and postTest nodes when needed to n@893: // initialise the popup procedure. n@893: this.popupOptions = node.options; n@893: if (this.popupOptions.length > 0) { n@893: if (node.type == 'pretest') { n@893: this.responses = document.createElement('PreTest'); n@893: } else if (node.type == 'posttest') { n@893: this.responses = document.createElement('PostTest'); n@893: } else { n@893: console.log ('WARNING - popup node neither pre or post!'); n@893: this.responses = document.createElement('responses'); n@893: } n@893: this.currentIndex = 0; n@893: this.showPopup(); n@893: this.postNode(); n@893: } else { n@893: advanceState(); n@893: } n@893: }; n@893: n@893: this.proceedClicked = function() { n@893: // Each time the popup button is clicked! n@893: var node = this.popupOptions[this.currentIndex]; n@893: if (node.type == 'question') { n@893: // Must extract the question data n@893: var textArea = $(popup.popupContent).find('textarea')[0]; n@893: if (node.mandatory == true && textArea.value.length == 0) { n@893: alert('This question is mandatory'); n@893: return; n@893: } else { n@893: // Save the text content n@893: var hold = document.createElement('comment'); n@893: hold.id = node.id; n@893: hold.innerHTML = textArea.value; n@893: console.log("Question: "+ node.question); n@893: console.log("Question Response: "+ textArea.value); n@893: this.responses.appendChild(hold); n@893: } n@893: } else if (node.type == 'checkbox') { n@893: // Must extract checkbox data n@893: var optHold = document.getElementById('option-holder'); n@893: var hold = document.createElement('checkbox'); n@893: console.log("Checkbox: "+ node.statement); n@893: hold.id = node.id; n@893: for (var i=0; i node.max && node.max != null) { n@893: alert('Number is above the maximum value of '+node.max); n@893: return; n@893: } n@893: var hold = document.createElement('number'); n@893: hold.id = node.id; n@893: hold.textContent = input.value; n@893: this.responses.appendChild(hold); n@893: } n@893: this.currentIndex++; n@893: if (this.currentIndex < this.popupOptions.length) { n@893: this.postNode(); n@893: } else { n@893: // Reached the end of the popupOptions n@893: this.hidePopup(); n@893: if (this.responses.nodeName == testState.stateResults[testState.stateIndex].nodeName) { n@893: testState.stateResults[testState.stateIndex] = this.responses; n@893: } else { n@893: testState.stateResults[testState.stateIndex].appendChild(this.responses); n@893: } n@893: advanceState(); n@893: } n@893: }; n@893: n@893: this.previousClick = function() { n@893: // Triggered when the 'Back' button is clicked in the survey n@893: if (this.currentIndex > 0) { n@893: this.currentIndex--; n@893: var node = this.popupOptions[this.currentIndex]; n@893: if (node.type != 'statement') { n@893: var prevResp = this.responses.childNodes[this.responses.childElementCount-1]; n@893: this.responses.removeChild(prevResp); n@893: } n@893: this.postNode(); n@893: if (node.type == 'question') { n@893: this.popupContent.getElementsByTagName('textarea')[0].value = prevResp.textContent; n@893: } else if (node.type == 'checkbox') { n@893: var options = this.popupContent.getElementsByTagName('input'); n@893: var savedOptions = prevResp.getElementsByTagName('option'); n@893: for (var i=0; i 0) { n@893: if(this.stateIndex != null) { n@893: console.log('NOTE - State already initialise'); n@893: } n@893: this.stateIndex = -1; n@893: var that = this; n@893: for (var id=0; id= this.stateMap.length) { n@893: console.log('Test Completed'); n@893: createProjectSave(specification.projectReturn); n@893: } else { n@893: this.currentStateMap = this.stateMap[this.stateIndex]; n@893: if (this.currentStateMap.type == "audioHolder") { n@893: console.log('Loading test page'); n@893: loadTest(this.currentStateMap); n@893: this.initialiseInnerState(this.currentStateMap); n@893: } else if (this.currentStateMap.type == "pretest" || this.currentStateMap.type == "posttest") { n@893: if (this.currentStateMap.options.length >= 1) { n@893: popup.initState(this.currentStateMap); n@893: } else { n@893: this.advanceState(); n@893: } n@893: } else { n@893: this.advanceState(); n@893: } n@893: } n@893: } else { n@893: this.advanceInnerState(); n@893: } n@893: }; n@893: n@893: this.testPageCompleted = function(store, testXML, testId) { n@893: // Function called each time a test page has been completed n@893: // Can be used to over-rule default behaviour n@893: n@893: pageXMLSave(store, testXML); n@893: }; n@893: n@893: this.initialiseInnerState = function(node) { n@893: // Parses the received testXML for pre and post test options n@893: this.currentStateMap = []; n@893: var preTest = node.preTest; n@893: var postTest = node.postTest; n@893: if (preTest == undefined) {preTest = document.createElement("preTest");} n@893: if (postTest == undefined){postTest= document.createElement("postTest");} n@893: this.currentStateMap.push(preTest); n@893: this.currentStateMap.push(node); n@893: this.currentStateMap.push(postTest); n@893: this.currentIndex = -1; n@893: this.advanceInnerState(); n@893: }; n@893: n@893: this.advanceInnerState = function() { n@893: this.currentIndex++; n@893: if (this.currentIndex >= this.currentStateMap.length) { n@893: this.currentIndex = null; n@893: this.currentStateMap = this.stateMap[this.stateIndex]; n@893: this.advanceState(); n@893: } else { n@893: if (this.currentStateMap[this.currentIndex].type == "audioHolder") { n@893: console.log("Loading test page"+this.currentTestId); n@893: } else if (this.currentStateMap[this.currentIndex].type == "pretest") { n@893: popup.initState(this.currentStateMap[this.currentIndex]); n@893: } else if (this.currentStateMap[this.currentIndex].type == "posttest") { n@893: popup.initState(this.currentStateMap[this.currentIndex]); n@893: } else { n@893: this.advanceInnerState(); n@893: } n@893: } n@893: }; n@893: n@893: this.previousState = function(){}; n@893: } n@893: n@893: function testEnded(testId) n@893: { n@893: pageXMLSave(testId); n@893: if (testXMLSetups.length-1 > testId) n@893: { n@893: // Yes we have another test to perform n@893: testId = (Number(testId)+1); n@893: currentState = 'testRun-'+testId; n@893: loadTest(testId); n@893: } else { n@893: console.log('Testing Completed!'); n@893: currentState = 'postTest'; n@893: // Check for any post tests n@893: var xmlSetup = projectXML.find('setup'); n@893: var postTest = xmlSetup.find('PostTest')[0]; n@893: popup.initState(postTest); n@893: } n@893: } n@893: n@893: function loadProjectSpec(url) { n@893: // Load the project document from the given URL, decode the XML and instruct audioEngine to get audio data n@893: // If url is null, request client to upload project XML document n@893: var r = new XMLHttpRequest(); n@893: r.open('GET',url,true); n@893: r.onload = function() { n@893: loadProjectSpecCallback(r.response); n@893: }; n@893: r.send(); n@893: }; n@893: n@893: function loadProjectSpecCallback(response) { n@893: // Function called after asynchronous download of XML project specification n@893: //var decode = $.parseXML(response); n@893: //projectXML = $(decode); n@893: n@893: var parse = new DOMParser(); n@893: projectXML = parse.parseFromString(response,'text/xml'); n@893: n@893: // Build the specification n@893: specification.decode(); n@893: n@893: testState.stateMap.push(specification.preTest); n@893: n@893: // New check if we need to randomise the test order n@893: if (specification.randomiseOrder) n@893: { n@893: specification.audioHolders = randomiseOrder(specification.audioHolders); n@893: } n@893: n@893: $(specification.audioHolders).each(function(index,elem){ n@893: testState.stateMap.push(elem); n@893: }); n@893: n@893: testState.stateMap.push(specification.postTest); n@893: n@893: // Obtain the metrics enabled n@893: $(specification.metrics).each(function(index,node){ n@893: var enabled = node.textContent; n@893: switch(node.enabled) n@893: { n@893: case 'testTimer': n@893: sessionMetrics.prototype.enableTestTimer = true; n@893: break; n@893: case 'elementTimer': n@893: sessionMetrics.prototype.enableElementTimer = true; n@893: break; n@893: case 'elementTracker': n@893: sessionMetrics.prototype.enableElementTracker = true; n@893: break; n@893: case 'elementListenTracker': n@893: sessionMetrics.prototype.enableElementListenTracker = true; n@893: break; n@893: case 'elementInitialPosition': n@893: sessionMetrics.prototype.enableElementInitialPosition = true; n@893: break; n@893: case 'elementFlagListenedTo': n@893: sessionMetrics.prototype.enableFlagListenedTo = true; n@893: break; n@893: case 'elementFlagMoved': n@893: sessionMetrics.prototype.enableFlagMoved = true; n@893: break; n@893: case 'elementFlagComments': n@893: sessionMetrics.prototype.enableFlagComments = true; n@893: break; n@893: } n@893: }); n@893: n@893: n@893: n@893: // Detect the interface to use and load the relevant javascripts. n@893: var interfaceJS = document.createElement('script'); n@893: interfaceJS.setAttribute("type","text/javascript"); n@893: if (specification.interfaceType == 'APE') { n@893: interfaceJS.setAttribute("src","ape.js"); n@893: n@893: // APE comes with a css file n@893: var css = document.createElement('link'); n@893: css.rel = 'stylesheet'; n@893: css.type = 'text/css'; n@893: css.href = 'ape.css'; n@893: n@893: document.getElementsByTagName("head")[0].appendChild(css); n@893: } n@893: document.getElementsByTagName("head")[0].appendChild(interfaceJS); n@893: n@893: // Define window callbacks for interface n@893: window.onresize = function(event){resizeWindow(event);}; n@893: } n@893: n@893: function createProjectSave(destURL) { n@893: // Save the data from interface into XML and send to destURL n@893: // If destURL is null then download XML in client n@893: // Now time to render file locally n@893: var xmlDoc = interfaceXMLSave(); n@893: var parent = document.createElement("div"); n@893: parent.appendChild(xmlDoc); n@893: var file = [parent.innerHTML]; n@893: if (destURL == "null" || destURL == undefined) { n@893: var bb = new Blob(file,{type : 'application/xml'}); n@893: var dnlk = window.URL.createObjectURL(bb); n@893: var a = document.createElement("a"); n@893: a.hidden = ''; n@893: a.href = dnlk; n@893: a.download = "save.xml"; n@893: a.textContent = "Save File"; n@893: n@893: popup.showPopup(); n@893: popup.popupContent.innerHTML = null; n@893: popup.popupContent.appendChild(a); n@893: } else { n@893: var xmlhttp = new XMLHttpRequest; n@893: xmlhttp.open("POST",destURL,true); n@893: xmlhttp.setRequestHeader('Content-Type', 'text/xml'); n@893: xmlhttp.onerror = function(){ n@893: console.log('Error saving file to server! Presenting download locally'); n@893: createProjectSave(null); n@893: }; n@893: xmlhttp.onreadystatechange = function() { n@893: console.log(xmlhttp.status); n@893: if (xmlhttp.status != 200 && xmlhttp.readyState == 4) { n@893: createProjectSave(null); n@893: } n@893: }; n@893: xmlhttp.send(file); n@893: } n@893: } n@893: n@893: // Only other global function which must be defined in the interface class. Determines how to create the XML document. n@893: function interfaceXMLSave(){ n@893: // Create the XML string to be exported with results n@893: var xmlDoc = document.createElement("BrowserEvaluationResult"); n@893: xmlDoc.appendChild(returnDateNode()); n@893: for (var i=0; i n@893: // DD/MM/YY n@893: // n@893: // n@893: var dateTime = new Date(); n@893: var year = document.createAttribute('year'); n@893: var month = document.createAttribute('month'); n@893: var day = document.createAttribute('day'); n@893: var hour = document.createAttribute('hour'); n@893: var minute = document.createAttribute('minute'); n@893: var secs = document.createAttribute('secs'); n@893: n@893: year.nodeValue = dateTime.getFullYear(); n@893: month.nodeValue = dateTime.getMonth()+1; n@893: day.nodeValue = dateTime.getDate(); n@893: hour.nodeValue = dateTime.getHours(); n@893: minute.nodeValue = dateTime.getMinutes(); n@893: secs.nodeValue = dateTime.getSeconds(); n@893: n@893: var hold = document.createElement("datetime"); n@893: var date = document.createElement("date"); n@893: date.textContent = year.nodeValue+'/'+month.nodeValue+'/'+day.nodeValue; n@893: var time = document.createElement("time"); n@893: time.textContent = hour.nodeValue+':'+minute.nodeValue+':'+secs.nodeValue; n@893: n@893: date.setAttributeNode(year); n@893: date.setAttributeNode(month); n@893: date.setAttributeNode(day); n@893: time.setAttributeNode(hour); n@893: time.setAttributeNode(minute); n@893: time.setAttributeNode(secs); n@893: n@893: hold.appendChild(date); n@893: hold.appendChild(time); n@893: return hold n@893: n@893: } n@893: n@893: function testWaitIndicator() { n@893: if (audioEngineContext.checkAllReady() == false) { n@893: var hold = document.createElement("div"); n@893: hold.id = "testWaitIndicator"; n@893: hold.className = "indicator-box"; n@893: hold.style.zIndex = 3; n@893: var span = document.createElement("span"); n@893: span.textContent = "Please wait! Elements still loading"; n@893: hold.appendChild(span); n@893: var blank = document.createElement('div'); n@893: blank.className = 'testHalt'; n@893: blank.id = "testHaltBlank"; n@893: var body = document.getElementsByTagName('body')[0]; n@893: body.appendChild(hold); n@893: body.appendChild(blank); n@893: testWaitTimerIntervalHolder = setInterval(function(){ n@893: var ready = audioEngineContext.checkAllReady(); n@893: if (ready) { n@893: var elem = document.getElementById('testWaitIndicator'); n@893: var blank = document.getElementById('testHaltBlank'); n@893: var body = document.getElementsByTagName('body')[0]; n@893: body.removeChild(elem); n@893: body.removeChild(blank); n@893: clearInterval(testWaitTimerIntervalHolder); n@893: } n@893: },500,false); n@893: } n@893: } n@893: n@893: var testWaitTimerIntervalHolder = null; n@893: n@893: function Specification() { n@893: // Handles the decoding of the project specification XML into a simple JavaScript Object. n@893: n@893: this.interfaceType; n@893: this.projectReturn; n@893: this.randomiseOrder; n@893: this.collectMetrics; n@893: this.preTest; n@893: this.postTest; n@893: this.metrics =[]; n@893: n@893: this.audioHolders = []; n@893: n@893: this.decode = function() { n@893: // projectXML - DOM Parsed document n@893: var setupNode = projectXML.getElementsByTagName('setup')[0]; n@893: this.interfaceType = setupNode.getAttribute('interface'); n@893: this.projectReturn = setupNode.getAttribute('projectReturn'); n@893: if (setupNode.getAttribute('randomiseOrder') == "true") { n@893: this.randomiseOrder = true; n@893: } else {this.randomiseOrder = false;} n@893: if (setupNode.getAttribute('collectMetrics') == "true") { n@893: this.collectMetrics = true; n@893: } else {this.collectMetrics = false;} n@893: var metricCollection = setupNode.getElementsByTagName('Metric'); n@893: n@893: this.preTest = new this.prepostNode('pretest',setupNode.getElementsByTagName('PreTest')); n@893: this.postTest = new this.prepostNode('posttest',setupNode.getElementsByTagName('PostTest')); n@893: n@893: if (metricCollection.length > 0) { n@893: metricCollection = metricCollection[0].getElementsByTagName('metricEnable'); n@893: for (var i=0; i tag. n@893: this.interfaceObjects = []; n@893: this.interfaceObject = function(){}; n@893: n@893: this.commentBoxes = []; n@893: this.elementCommentBox = function(audioObject) { n@893: var element = audioObject.specification; n@893: this.audioObject = audioObject; n@893: this.id = audioObject.id; n@893: var audioHolderObject = audioObject.specification.parent; n@893: // Create document objects to hold the comment boxes n@893: this.trackComment = document.createElement('div'); n@893: this.trackComment.className = 'comment-div'; n@893: this.trackComment.id = 'comment-div-'+audioObject.id; n@893: // Create a string next to each comment asking for a comment n@893: this.trackString = document.createElement('span'); n@893: this.trackString.innerHTML = audioHolderObject.commentBoxPrefix+' '+audioObject.id; n@893: // Create the HTML5 comment box 'textarea' n@893: this.trackCommentBox = document.createElement('textarea'); n@893: this.trackCommentBox.rows = '4'; n@893: this.trackCommentBox.cols = '100'; n@893: this.trackCommentBox.name = 'trackComment'+audioObject.id; n@893: this.trackCommentBox.className = 'trackComment'; n@893: var br = document.createElement('br'); n@893: // Add to the holder. n@893: this.trackComment.appendChild(this.trackString); n@893: this.trackComment.appendChild(br); n@893: this.trackComment.appendChild(this.trackCommentBox); n@893: n@893: this.exportXMLDOM = function() { n@893: var root = document.createElement('comment'); n@893: if (this.audioObject.specification.parent.elementComments) { n@893: var question = document.createElement('question'); n@893: question.textContent = this.trackString.textContent; n@893: var response = document.createElement('response'); n@893: response.textContent = this.trackCommentBox.value; n@893: root.appendChild(question); n@893: root.appendChild(response); n@893: } n@893: return root; n@893: }; n@893: }; n@893: n@893: this.commentQuestions = []; n@893: n@893: this.commentBox = function(commentQuestion) { n@893: this.specification = commentQuestion; n@893: // Create document objects to hold the comment boxes n@893: this.holder = document.createElement('div'); n@893: this.holder.className = 'comment-div'; n@893: // Create a string next to each comment asking for a comment n@893: this.string = document.createElement('span'); n@893: this.string.innerHTML = commentQuestion.question; n@893: // Create the HTML5 comment box 'textarea' n@893: this.textArea = document.createElement('textarea'); n@893: this.textArea.rows = '4'; n@893: this.textArea.cols = '100'; n@893: this.textArea.className = 'trackComment'; n@893: var br = document.createElement('br'); n@893: // Add to the holder. n@893: this.holder.appendChild(this.string); n@893: this.holder.appendChild(br); n@893: this.holder.appendChild(this.textArea); n@893: n@893: this.exportXMLDOM = function() { n@893: var root = document.createElement('comment'); n@893: root.id = this.specification.id; n@893: root.setAttribute('type',this.specification.type); n@893: root.textContent = this.textArea.value; n@893: return root; n@893: }; n@893: }; n@893: n@893: this.radioBox = function(commentQuestion) { n@893: this.specification = commentQuestion; n@893: // Create document objects to hold the comment boxes n@893: this.holder = document.createElement('div'); n@893: this.holder.className = 'comment-div'; n@893: // Create a string next to each comment asking for a comment n@893: this.string = document.createElement('span'); n@893: this.string.innerHTML = commentQuestion.statement; n@893: var br = document.createElement('br'); n@893: // Add to the holder. n@893: this.holder.appendChild(this.string); n@893: this.holder.appendChild(br); n@893: this.options = []; n@893: this.inputs = document.createElement('div'); n@893: this.span = document.createElement('div'); n@893: this.inputs.align = 'center'; n@893: this.inputs.style.marginLeft = '12px'; n@893: this.span.style.marginLeft = '12px'; n@893: this.span.align = 'center'; n@893: this.span.style.marginTop = '15px'; n@893: n@893: var optCount = commentQuestion.options.length; n@893: var spanMargin = Math.floor(((600-(optCount*100))/(optCount))/2)+'px'; n@893: console.log(spanMargin); n@893: for (var i=0; i= this.options.length) { n@893: break; n@893: } n@893: } n@893: if (i >= this.options.length) { n@893: response.textContent = 'null'; n@893: } else { n@893: response.textContent = this.options[i].getAttribute('setvalue'); n@893: response.setAttribute('number',i); n@893: } n@893: console.log('Comment: '+question.textContent); n@893: console.log('Response: '+response.textContent); n@893: root.appendChild(question); n@893: root.appendChild(response); n@893: return root; n@893: }; n@893: }; n@893: n@893: this.checkboxBox = function(commentQuestion) { n@893: this.specification = commentQuestion; n@893: // Create document objects to hold the comment boxes n@893: this.holder = document.createElement('div'); n@893: this.holder.className = 'comment-div'; n@893: // Create a string next to each comment asking for a comment n@893: this.string = document.createElement('span'); n@893: this.string.innerHTML = commentQuestion.statement; n@893: var br = document.createElement('br'); n@893: // Add to the holder. n@893: this.holder.appendChild(this.string); n@893: this.holder.appendChild(br); n@893: this.options = []; n@893: this.inputs = document.createElement('div'); n@893: this.span = document.createElement('div'); n@893: this.inputs.align = 'center'; n@893: this.inputs.style.marginLeft = '12px'; n@893: this.span.style.marginLeft = '12px'; n@893: this.span.align = 'center'; n@893: this.span.style.marginTop = '15px'; n@893: n@893: var optCount = commentQuestion.options.length; n@893: var spanMargin = Math.floor(((600-(optCount*100))/(optCount))/2)+'px'; n@893: console.log(spanMargin); n@893: for (var i=0; i 0) { n@893: var node = this.commentBoxes.pop(0); n@893: holder[node.id] = node; n@893: } n@893: this.commentBoxes = holder; n@893: }; n@893: n@893: this.showCommentBoxes = function(inject, sort) { n@893: if (sort) {interfaceContext.sortCommentBoxes();} n@893: for (var i=0; i 0) { n@897: var time = this.playbackObject.getCurrentPosition(); n@894: var width = 490; n@897: var pix = Math.floor(time/this.timePerPixel); n@894: this.scrubberHead.style.left = pix+'px'; n@894: if (this.maxTime > 60.0) { n@894: var secs = time%60; n@894: var mins = Math.floor((time-secs)/60); n@894: secs = secs.toString(); n@894: secs = secs.substr(0,2); n@894: mins = mins.toString(); n@894: this.curTimeSpan.textContent = mins+':'+secs; n@894: } else { n@894: time = time.toString(); n@894: this.curTimeSpan.textContent = time.substr(0,4); n@894: } n@894: } n@894: }; n@897: n@897: this.interval = undefined; n@897: n@897: this.start = function() { n@897: if (this.playbackObject != undefined && this.interval == undefined) { n@897: this.interval = setInterval(function(){interfaceContext.playhead.update();},100); n@897: } n@897: }; n@897: this.stop = function() { n@897: clearInterval(this.interval); n@897: this.interval = undefined; n@897: }; n@894: }; n@893: } n@893: