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