n@1118: /** n@1118: * core.js n@1118: * n@1118: * Main script to run, calls all other core functions and manages loading/store to backend. n@1118: * Also contains all global variables. n@1118: */ n@1118: n@1118: /* create the web audio API context and store in audioContext*/ n@1118: var audioContext; // Hold the browser web audio API n@1118: var projectXML; // Hold the parsed setup XML n@1124: var schemaXSD; // Hold the parsed schema XSD n@1118: var specification; n@1118: var interfaceContext; n@1124: var storage; n@1118: var popup; // Hold the interfacePopup object n@1118: var testState; n@1118: var currentTrackOrder = []; // Hold the current XML tracks in their (randomised) order n@1118: var audioEngineContext; // The custome AudioEngine object n@1118: var projectReturn; // Hold the URL for the return n@1118: n@1118: n@1118: // Add a prototype to the bufferSourceNode to reference to the audioObject holding it n@1118: AudioBufferSourceNode.prototype.owner = undefined; n@1118: // Add a prototype to the bufferNode to hold the desired LINEAR gain n@1120: AudioBuffer.prototype.playbackGain = undefined; n@1118: // Add a prototype to the bufferNode to hold the computed LUFS loudness n@1118: AudioBuffer.prototype.lufs = undefined; n@1118: n@1148: // Firefox does not have an XMLDocument.prototype.getElementsByName n@1148: // and there is no searchAll style command, this custom function will n@1148: // search all children recusrively for the name. Used for XSD where all n@1148: // element nodes must have a name and therefore can pull the schema node n@1148: XMLDocument.prototype.getAllElementsByName = function(name) n@1148: { n@1148: name = String(name); n@1148: var selected = this.documentElement.getAllElementsByName(name); n@1148: return selected; n@1148: } n@1148: n@1148: Element.prototype.getAllElementsByName = function(name) n@1148: { n@1148: name = String(name); n@1148: var selected = []; n@1148: var node = this.firstElementChild; n@1148: while(node != null) n@1148: { n@1148: if (node.getAttribute('name') == name) n@1148: { n@1148: selected.push(node); n@1148: } n@1148: if (node.childElementCount > 0) n@1148: { n@1148: selected = selected.concat(node.getAllElementsByName(name)); n@1148: } n@1148: node = node.nextElementSibling; n@1148: } n@1148: return selected; n@1148: } n@1148: n@1148: XMLDocument.prototype.getAllElementsByTagName = function(name) n@1148: { n@1148: name = String(name); n@1148: var selected = this.documentElement.getAllElementsByTagName(name); n@1148: return selected; n@1148: } n@1148: n@1148: Element.prototype.getAllElementsByTagName = function(name) n@1148: { n@1148: name = String(name); n@1148: var selected = []; n@1148: var node = this.firstElementChild; n@1148: while(node != null) n@1148: { n@1148: if (node.nodeName == name) n@1148: { n@1148: selected.push(node); n@1148: } n@1148: if (node.childElementCount > 0) n@1148: { n@1148: selected = selected.concat(node.getAllElementsByTagName(name)); n@1148: } n@1148: node = node.nextElementSibling; n@1148: } n@1148: return selected; n@1148: } n@1148: n@1148: // Firefox does not have an XMLDocument.prototype.getElementsByName n@1148: if (typeof XMLDocument.prototype.getElementsByName != "function") { n@1148: XMLDocument.prototype.getElementsByName = function(name) n@1148: { n@1148: name = String(name); n@1148: var node = this.documentElement.firstElementChild; n@1148: var selected = []; n@1148: while(node != null) n@1148: { n@1148: if (node.getAttribute('name') == name) n@1148: { n@1148: selected.push(node); n@1148: } n@1148: node = node.nextElementSibling; n@1148: } n@1148: return selected; n@1148: } n@1148: } n@1148: n@1118: window.onload = function() { n@1118: // Function called once the browser has loaded all files. n@1118: // This should perform any initial commands such as structure / loading documents n@1118: n@1118: // Create a web audio API context n@1118: // Fixed for cross-browser support n@1118: var AudioContext = window.AudioContext || window.webkitAudioContext; n@1118: audioContext = new AudioContext; n@1118: n@1118: // Create test state n@1118: testState = new stateMachine(); n@1118: n@1118: // Create the popup interface object n@1118: popup = new interfacePopup(); n@1170: n@1170: // Create the specification object n@1118: specification = new Specification(); n@1118: n@1118: // Create the interface object n@1118: interfaceContext = new Interface(specification); n@1124: n@1124: // Create the storage object n@1124: storage = new Storage(); n@1118: // Define window callbacks for interface n@1118: window.onresize = function(event){interfaceContext.resizeWindow(event);}; n@1118: }; n@1118: n@1118: function loadProjectSpec(url) { n@1118: // Load the project document from the given URL, decode the XML and instruct audioEngine to get audio data n@1118: // If url is null, request client to upload project XML document n@1124: var xmlhttp = new XMLHttpRequest(); n@1124: xmlhttp.open("GET",'test-schema.xsd',true); n@1124: xmlhttp.onload = function() n@1124: { n@1124: schemaXSD = xmlhttp.response; n@1124: var parse = new DOMParser(); n@1124: specification.schema = parse.parseFromString(xmlhttp.response,'text/xml'); n@1124: var r = new XMLHttpRequest(); n@1124: r.open('GET',url,true); n@1124: r.onload = function() { n@1124: loadProjectSpecCallback(r.response); n@1124: }; n@1124: r.send(); n@1118: }; n@1124: xmlhttp.send(); n@1118: }; n@1118: n@1118: function loadProjectSpecCallback(response) { n@1118: // Function called after asynchronous download of XML project specification n@1118: //var decode = $.parseXML(response); n@1118: //projectXML = $(decode); n@1118: n@1124: // First perform XML schema validation n@1124: var Module = { n@1124: xml: response, n@1124: schema: schemaXSD, n@1124: arguments:["--noout", "--schema", 'test-schema.xsd','document.xml'] n@1124: }; n@1124: n@1124: var xmllint = validateXML(Module); n@1124: console.log(xmllint); n@1124: if(xmllint != 'document.xml validates\n') n@1124: { n@1124: document.getElementsByTagName('body')[0].innerHTML = null; n@1124: var msg = document.createElement("h3"); n@1124: msg.textContent = "FATAL ERROR"; n@1124: var span = document.createElement("h4"); n@1124: span.textContent = "The XML validator returned the following errors when decoding your XML file"; n@1124: document.getElementsByTagName('body')[0].appendChild(msg); n@1124: document.getElementsByTagName('body')[0].appendChild(span); n@1124: xmllint = xmllint.split('\n'); n@1124: for (var i in xmllint) n@1124: { n@1124: document.getElementsByTagName('body')[0].appendChild(document.createElement('br')); n@1124: var span = document.createElement("span"); n@1124: span.textContent = xmllint[i]; n@1124: document.getElementsByTagName('body')[0].appendChild(span); n@1124: } n@1124: return; n@1124: } n@1124: n@1118: var parse = new DOMParser(); n@1118: projectXML = parse.parseFromString(response,'text/xml'); n@1118: var errorNode = projectXML.getElementsByTagName('parsererror'); n@1118: if (errorNode.length >= 1) n@1118: { n@1118: var msg = document.createElement("h3"); n@1118: msg.textContent = "FATAL ERROR"; n@1118: var span = document.createElement("span"); n@1118: span.textContent = "The XML parser returned the following errors when decoding your XML file"; n@1118: document.getElementsByTagName('body')[0].innerHTML = null; n@1118: document.getElementsByTagName('body')[0].appendChild(msg); n@1118: document.getElementsByTagName('body')[0].appendChild(span); n@1118: document.getElementsByTagName('body')[0].appendChild(errorNode[0]); n@1118: return; n@1118: } n@1118: n@1118: // Build the specification n@1118: specification.decode(projectXML); n@1124: storage.initialise(); n@1139: /// CHECK FOR SAMPLE RATE COMPATIBILITY n@1139: if (specification.sampleRate != undefined) { n@1139: if (Number(specification.sampleRate) != audioContext.sampleRate) { n@1139: var errStr = 'Sample rates do not match! Requested '+Number(specification.sampleRate)+', got '+audioContext.sampleRate+'. Please set the sample rate to match before completing this test.'; n@1139: alert(errStr); n@1139: return; n@1139: } n@1139: } n@1118: n@1118: // Detect the interface to use and load the relevant javascripts. n@1118: var interfaceJS = document.createElement('script'); n@1118: interfaceJS.setAttribute("type","text/javascript"); n@1129: switch(specification.interface) n@1129: { n@1129: case "APE": n@1141: interfaceJS.setAttribute("src","interfaces/ape.js"); n@1118: n@1118: // APE comes with a css file n@1118: var css = document.createElement('link'); n@1118: css.rel = 'stylesheet'; n@1118: css.type = 'text/css'; n@1141: css.href = 'interfaces/ape.css'; n@1118: n@1118: document.getElementsByTagName("head")[0].appendChild(css); n@1129: break; n@1129: n@1129: case "MUSHRA": n@1141: interfaceJS.setAttribute("src","interfaces/mushra.js"); n@1118: n@1118: // MUSHRA comes with a css file n@1118: var css = document.createElement('link'); n@1118: css.rel = 'stylesheet'; n@1118: css.type = 'text/css'; n@1141: css.href = 'interfaces/mushra.css'; n@1118: n@1118: document.getElementsByTagName("head")[0].appendChild(css); n@1129: break; n@1129: n@1129: case "AB": n@1141: interfaceJS.setAttribute("src","interfaces/AB.js"); n@1129: n@1129: // AB comes with a css file n@1129: var css = document.createElement('link'); n@1129: css.rel = 'stylesheet'; n@1129: css.type = 'text/css'; n@1141: css.href = 'interfaces/AB.css'; n@1129: n@1129: document.getElementsByTagName("head")[0].appendChild(css); n@1145: break; n@1145: case "Bipolar": n@1145: case "ACR": n@1145: case "DCR": n@1145: case "CCR": n@1143: case "ABC": n@1143: // Above enumerate to horizontal sliders n@1143: interfaceJS.setAttribute("src","interfaces/horizontal-sliders.js"); n@1143: n@1143: // horizontal-sliders comes with a css file n@1143: var css = document.createElement('link'); n@1143: css.rel = 'stylesheet'; n@1143: css.type = 'text/css'; n@1143: css.href = 'interfaces/horizontal-sliders.css'; n@1143: n@1143: document.getElementsByTagName("head")[0].appendChild(css); n@1145: break; n@1145: case "discrete": n@1145: case "likert": n@1145: // Above enumerate to horizontal discrete radios n@1145: interfaceJS.setAttribute("src","interfaces/discrete.js"); n@1145: n@1145: // horizontal-sliders comes with a css file n@1145: var css = document.createElement('link'); n@1145: css.rel = 'stylesheet'; n@1145: css.type = 'text/css'; n@1145: css.href = 'interfaces/discrete.css'; n@1145: n@1145: document.getElementsByTagName("head")[0].appendChild(css); n@1145: break; n@1118: } n@1118: document.getElementsByTagName("head")[0].appendChild(interfaceJS); n@1118: n@1118: // Create the audio engine object n@1118: audioEngineContext = new AudioEngine(specification); n@1118: n@1124: $(specification.pages).each(function(index,elem){ n@1118: $(elem.audioElements).each(function(i,audioElem){ n@1124: var URL = elem.hostURL + audioElem.url; n@1118: var buffer = null; n@1118: for (var i=0; i 0) n@1118: this.buttonPrevious.style.visibility = 'visible'; n@1118: else n@1118: this.buttonPrevious.style.visibility = 'hidden'; n@1118: }; n@1118: n@1124: this.initState = function(node,store) { n@1118: //Call this with your preTest and postTest nodes when needed to n@1118: // initialise the popup procedure. n@1124: if (node.options.length > 0) { n@1124: this.popupOptions = []; n@1124: this.node = node; n@1124: this.store = store; n@1124: for (var opt of node.options) n@1124: { n@1124: this.popupOptions.push({ n@1124: specification: opt, n@1124: response: null n@1124: }); n@1124: } n@1118: this.currentIndex = 0; n@1118: this.showPopup(); n@1118: this.postNode(); n@1118: } else { n@1118: advanceState(); n@1118: } n@1118: }; n@1118: n@1118: this.proceedClicked = function() { n@1118: // Each time the popup button is clicked! n@1118: var node = this.popupOptions[this.currentIndex]; n@1124: if (node.specification.type == 'question') { n@1118: // Must extract the question data n@1118: var textArea = $(popup.popupContent).find('textarea')[0]; n@1124: if (node.specification.mandatory == true && textArea.value.length == 0) { n@1118: alert('This question is mandatory'); n@1118: return; n@1118: } else { n@1118: // Save the text content n@1124: console.log("Question: "+ node.specification.statement); n@1118: console.log("Question Response: "+ textArea.value); n@1124: node.response = textArea.value; n@1118: } n@1124: } else if (node.specification.type == 'checkbox') { n@1118: // Must extract checkbox data n@1126: console.log("Checkbox: "+ node.specification.statement); n@1124: var inputs = this.popupResponse.getElementsByTagName('input'); n@1124: node.response = []; n@1124: for (var i=0; i node.max && node.max != null) { n@1118: alert('Number is above the maximum value of '+node.max); n@1118: return; n@1118: } n@1124: node.response = input.value; n@1118: } n@1118: this.currentIndex++; n@1118: if (this.currentIndex < this.popupOptions.length) { n@1118: this.postNode(); n@1118: } else { n@1118: // Reached the end of the popupOptions n@1118: this.hidePopup(); n@1124: for (var node of this.popupOptions) n@1124: { n@1124: this.store.postResult(node); n@1118: } n@1118: advanceState(); n@1118: } n@1118: }; n@1118: n@1118: this.previousClick = function() { n@1118: // Triggered when the 'Back' button is clicked in the survey n@1118: if (this.currentIndex > 0) { n@1118: this.currentIndex--; n@1118: this.postNode(); n@1118: } n@1118: }; n@1118: n@1118: this.resize = function(event) n@1118: { n@1118: // Called on window resize; n@1144: if (this.popup != null) { n@1144: this.popup.style.left = (window.innerWidth/2)-250 + 'px'; n@1144: this.popup.style.top = (window.innerHeight/2)-125 + 'px'; n@1144: var blank = document.getElementsByClassName('testHalt')[0]; n@1144: blank.style.width = window.innerWidth; n@1144: blank.style.height = window.innerHeight; n@1144: } n@1118: }; n@1118: } n@1118: n@1118: function advanceState() n@1118: { n@1118: // Just for complete clarity n@1118: testState.advanceState(); n@1118: } n@1118: n@1118: function stateMachine() n@1118: { n@1118: // Object prototype for tracking and managing the test state n@1118: this.stateMap = []; n@1124: this.preTestSurvey = null; n@1124: this.postTestSurvey = null; n@1118: this.stateIndex = null; n@1124: this.currentStateMap = null; n@1124: this.currentStatePosition = null; n@1154: this.currentStore = null; n@1118: this.initialise = function(){ n@1124: n@1124: // Get the data from Specification n@1124: var pageHolder = []; n@1124: for (var page of specification.pages) n@1124: { n@1124: pageHolder.push(page); n@1124: } n@1124: if (specification.randomiseOrder) n@1124: { n@1124: pageHolder = randomiseOrder(pageHolder); n@1124: } n@1124: for (var i=0; i 0) { n@1118: if(this.stateIndex != null) { n@1118: console.log('NOTE - State already initialise'); n@1118: } n@1118: this.stateIndex = -1; n@1118: } else { n@1118: console.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP'); n@1118: } n@1118: }; n@1118: this.advanceState = function(){ n@1118: if (this.stateIndex == null) { n@1118: this.initialise(); n@1118: } n@1118: if (this.stateIndex == -1) { n@1142: this.stateIndex++; n@1118: console.log('Starting test...'); n@1124: if (this.preTestSurvey != null) n@1124: { n@1124: popup.initState(this.preTestSurvey,storage.globalPreTest); n@1142: } else { n@1142: this.advanceState(); n@1118: } n@1124: } else if (this.stateIndex == this.stateMap.length) n@1124: { n@1124: // All test pages complete, post test n@1124: console.log('Ending test ...'); n@1124: this.stateIndex++; n@1124: if (this.postTestSurvey == null) { n@1124: this.advanceState(); n@1118: } else { n@1124: popup.initState(this.postTestSurvey,storage.globalPostTest); n@1124: } n@1124: } else if (this.stateIndex > this.stateMap.length) n@1124: { n@1124: createProjectSave(specification.projectReturn); n@1124: } n@1124: else n@1124: { n@1124: if (this.currentStateMap == null) n@1124: { n@1118: this.currentStateMap = this.stateMap[this.stateIndex]; n@1134: if (this.currentStateMap.randomiseOrder) n@1134: { n@1134: this.currentStateMap.audioElements = randomiseOrder(this.currentStateMap.audioElements); n@1134: } n@1154: this.currentStore = storage.createTestPageStore(this.currentStateMap); n@1124: if (this.currentStateMap.preTest != null) n@1124: { n@1124: this.currentStatePosition = 'pre'; n@1124: popup.initState(this.currentStateMap.preTest,storage.testPages[this.stateIndex].preTest); n@1118: } else { n@1124: this.currentStatePosition = 'test'; n@1124: } n@1124: interfaceContext.newPage(this.currentStateMap,storage.testPages[this.stateIndex]); n@1124: return; n@1124: } n@1124: switch(this.currentStatePosition) n@1124: { n@1124: case 'pre': n@1124: this.currentStatePosition = 'test'; n@1124: break; n@1124: case 'test': n@1124: this.currentStatePosition = 'post'; n@1124: // Save the data n@1124: this.testPageCompleted(); n@1124: if (this.currentStateMap.postTest == null) n@1124: { n@1118: this.advanceState(); n@1124: return; n@1124: } else { n@1124: popup.initState(this.currentStateMap.postTest,storage.testPages[this.stateIndex].postTest); n@1118: } n@1124: break; n@1124: case 'post': n@1124: this.stateIndex++; n@1124: this.currentStateMap = null; n@1124: this.advanceState(); n@1124: break; n@1124: }; n@1118: } n@1118: }; n@1118: n@1124: this.testPageCompleted = function() { n@1118: // Function called each time a test page has been completed n@1124: var storePoint = storage.testPages[this.stateIndex]; n@1124: // First get the test metric n@1124: n@1124: var metric = storePoint.XMLDOM.getElementsByTagName('metric')[0]; n@1118: if (audioEngineContext.metric.enableTestTimer) n@1118: { n@1124: var testTime = storePoint.parent.document.createElement('metricresult'); n@1118: testTime.id = 'testTime'; n@1118: testTime.textContent = audioEngineContext.timer.testDuration; n@1118: metric.appendChild(testTime); n@1118: } n@1124: n@1118: var audioObjects = audioEngineContext.audioObjects; n@1124: for (var ao of audioEngineContext.audioObjects) n@1118: { n@1124: ao.exportXMLDOM(); n@1118: } n@1124: for (var element of interfaceContext.commentQuestions) n@1124: { n@1124: element.exportXMLDOM(storePoint); n@1124: } n@1124: pageXMLSave(storePoint.XMLDOM, this.currentStateMap); n@1118: }; n@1118: } n@1118: n@1118: function AudioEngine(specification) { n@1118: n@1118: // Create two output paths, the main outputGain and fooGain. n@1118: // Output gain is default to 1 and any items for playback route here n@1118: // Foo gain is used for analysis to ensure paths get processed, but are not heard n@1118: // because web audio will optimise and any route which does not go to the destination gets ignored. n@1118: this.outputGain = audioContext.createGain(); n@1118: this.fooGain = audioContext.createGain(); n@1118: this.fooGain.gain = 0; n@1118: n@1118: // Use this to detect playback state: 0 - stopped, 1 - playing n@1118: this.status = 0; n@1118: n@1118: // Connect both gains to output n@1118: this.outputGain.connect(audioContext.destination); n@1118: this.fooGain.connect(audioContext.destination); n@1118: n@1118: // Create the timer Object n@1118: this.timer = new timer(); n@1118: // Create session metrics n@1118: this.metric = new sessionMetrics(this,specification); n@1118: n@1118: this.loopPlayback = false; n@1118: n@1124: this.pageStore = null; n@1124: n@1118: // Create store for new audioObjects n@1118: this.audioObjects = []; n@1118: n@1118: this.buffers = []; n@1118: this.bufferObj = function() n@1118: { n@1118: this.url = null; n@1118: this.buffer = null; n@1118: this.xmlRequest = new XMLHttpRequest(); n@1118: this.xmlRequest.parent = this; n@1118: this.users = []; n@1116: this.progress = 0; n@1116: this.status = 0; n@1142: this.ready = function() n@1142: { n@1116: if (this.status >= 2) n@1116: { n@1116: this.status = 3; n@1116: } n@1142: for (var i=0; i 0) {this.wasMoved = true;} n@1118: this.movementTracker[this.movementTracker.length] = [time, position]; n@1118: }; n@1118: n@1118: this.startListening = function(time) n@1118: { n@1118: if (this.listenHold == false) n@1118: { n@1118: this.wasListenedTo = true; n@1118: this.listenStart = time; n@1118: this.listenHold = true; n@1118: n@1118: var evnt = document.createElement('event'); n@1118: var testTime = document.createElement('testTime'); n@1118: testTime.setAttribute('start',time); n@1118: var bufferTime = document.createElement('bufferTime'); n@1118: bufferTime.setAttribute('start',this.parent.getCurrentPosition()); n@1118: evnt.appendChild(testTime); n@1118: evnt.appendChild(bufferTime); n@1118: this.listenTracker.push(evnt); n@1118: n@1118: console.log('slider ' + this.parent.id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id n@1118: } n@1118: }; n@1118: n@1118: this.stopListening = function(time,bufferStopTime) n@1118: { n@1118: if (this.listenHold == true) n@1118: { n@1118: var diff = time - this.listenStart; n@1118: this.listenedTimer += (diff); n@1118: this.listenStart = 0; n@1118: this.listenHold = false; n@1118: n@1118: var evnt = this.listenTracker[this.listenTracker.length-1]; n@1118: var testTime = evnt.getElementsByTagName('testTime')[0]; n@1118: var bufferTime = evnt.getElementsByTagName('bufferTime')[0]; n@1118: testTime.setAttribute('stop',time); n@1118: if (bufferStopTime == undefined) { n@1118: bufferTime.setAttribute('stop',this.parent.getCurrentPosition()); n@1118: } else { n@1118: bufferTime.setAttribute('stop',bufferStopTime); n@1118: } n@1118: console.log('slider ' + this.parent.id + ' played for (' + diff + ')'); // DEBUG/SAFETY: show played slider id n@1118: } n@1118: }; n@1118: n@1118: this.exportXMLDOM = function() { n@1124: var storeDOM = []; n@1118: if (audioEngineContext.metric.enableElementTimer) { n@1124: var mElementTimer = storage.document.createElement('metricresult'); n@1118: mElementTimer.setAttribute('name','enableElementTimer'); n@1118: mElementTimer.textContent = this.listenedTimer; n@1124: storeDOM.push(mElementTimer); n@1118: } n@1118: if (audioEngineContext.metric.enableElementTracker) { n@1124: var elementTrackerFull = storage.document.createElement('metricResult'); n@1118: elementTrackerFull.setAttribute('name','elementTrackerFull'); n@1118: for (var k=0; k n@1118: // DD/MM/YY n@1118: // n@1118: // n@1118: var dateTime = new Date(); n@1118: var year = document.createAttribute('year'); n@1118: var month = document.createAttribute('month'); n@1118: var day = document.createAttribute('day'); n@1118: var hour = document.createAttribute('hour'); n@1118: var minute = document.createAttribute('minute'); n@1118: var secs = document.createAttribute('secs'); n@1118: n@1118: year.nodeValue = dateTime.getFullYear(); n@1118: month.nodeValue = dateTime.getMonth()+1; n@1118: day.nodeValue = dateTime.getDate(); n@1118: hour.nodeValue = dateTime.getHours(); n@1118: minute.nodeValue = dateTime.getMinutes(); n@1118: secs.nodeValue = dateTime.getSeconds(); n@1118: n@1118: var hold = document.createElement("datetime"); n@1118: var date = document.createElement("date"); n@1118: date.textContent = year.nodeValue+'/'+month.nodeValue+'/'+day.nodeValue; n@1118: var time = document.createElement("time"); n@1118: time.textContent = hour.nodeValue+':'+minute.nodeValue+':'+secs.nodeValue; n@1118: n@1118: date.setAttributeNode(year); n@1118: date.setAttributeNode(month); n@1118: date.setAttributeNode(day); n@1118: time.setAttributeNode(hour); n@1118: time.setAttributeNode(minute); n@1118: time.setAttributeNode(secs); n@1118: n@1118: hold.appendChild(date); n@1118: hold.appendChild(time); n@1118: return hold; n@1118: n@1118: } n@1118: n@1118: function Specification() { n@1118: // Handles the decoding of the project specification XML into a simple JavaScript Object. n@1118: n@1124: this.interface = null; n@1173: this.projectReturn = "null"; n@1124: this.randomiseOrder = null; n@1124: this.testPages = null; n@1124: this.pages = []; n@1124: this.metrics = null; n@1124: this.interfaces = null; n@1124: this.loudness = null; n@1124: this.errors = []; n@1124: this.schema = null; n@1118: n@1124: this.processAttribute = function(attribute,schema) n@1124: { n@1124: // attribute is the string returned from getAttribute on the XML n@1124: // schema is the node n@1124: if (schema.getAttribute('name') == undefined && schema.getAttribute('ref') != undefined) n@1124: { n@1148: schema = this.schema.getAllElementsByName(schema.getAttribute('ref'))[0]; n@1124: } n@1124: var defaultOpt = schema.getAttribute('default'); n@1124: if (attribute == null) { n@1124: attribute = defaultOpt; n@1124: } n@1124: var dataType = schema.getAttribute('type'); n@1124: if (typeof dataType == "string") { dataType = dataType.substr(3);} n@1124: else {dataType = "string";} n@1124: if (attribute == null) n@1124: { n@1124: return attribute; n@1124: } n@1124: switch(dataType) n@1124: { n@1124: case "boolean": n@1124: if (attribute == 'true'){attribute = true;}else{attribute=false;} n@1124: break; n@1124: case "negativeInteger": n@1124: case "positiveInteger": n@1124: case "nonNegativeInteger": n@1124: case "nonPositiveInteger": n@1124: case "integer": n@1124: case "decimal": n@1124: case "short": n@1124: attribute = Number(attribute); n@1124: break; n@1124: case "string": n@1124: default: n@1124: attribute = String(attribute); n@1124: break; n@1124: } n@1124: return attribute; n@1124: }; n@1118: n@1118: this.decode = function(projectXML) { n@1124: this.errors = []; n@1118: // projectXML - DOM Parsed document n@1118: this.projectXML = projectXML.childNodes[0]; n@1118: var setupNode = projectXML.getElementsByTagName('setup')[0]; n@1148: var schemaSetup = this.schema.getAllElementsByName('setup')[0]; n@1124: // First decode the attributes n@1148: var attributes = schemaSetup.getAllElementsByTagName('xs:attribute'); n@1124: for (var i in attributes) n@1118: { n@1124: if (isNaN(Number(i)) == true){break;} n@1124: var attributeName = attributes[i].getAttribute('name'); n@1124: var projectAttr = setupNode.getAttribute(attributeName); n@1124: projectAttr = this.processAttribute(projectAttr,attributes[i]); n@1124: switch(typeof projectAttr) n@1118: { n@1124: case "number": n@1124: case "boolean": n@1124: eval('this.'+attributeName+' = '+projectAttr); n@1124: break; n@1124: case "string": n@1124: eval('this.'+attributeName+' = "'+projectAttr+'"'); n@1124: break; n@1118: } n@1124: n@1118: } n@1118: n@1170: this.metrics = new this.metricNode(); n@1118: n@1124: this.metrics.decode(this,setupNode.getElementsByTagName('metric')[0]); n@1124: n@1124: // Now process the survey node options n@1124: var survey = setupNode.getElementsByTagName('survey'); n@1124: for (var i in survey) { n@1124: if (isNaN(Number(i)) == true){break;} n@1124: var location = survey[i].getAttribute('location'); n@1124: if (location == 'pre' || location == 'before') n@1124: { n@1124: if (this.preTest != null){this.errors.push("Already a pre/before test survey defined! Ignoring second!!");} n@1124: else { n@1124: this.preTest = new this.surveyNode(); n@1170: this.preTest.decode(this,survey[i]); n@1124: } n@1124: } else if (location == 'post' || location == 'after') { n@1124: if (this.postTest != null){this.errors.push("Already a post/after test survey defined! Ignoring second!!");} n@1124: else { n@1124: this.postTest = new this.surveyNode(); n@1170: this.postTest.decode(this,survey[i]); n@1124: } n@1118: } n@1118: } n@1118: n@1124: var interfaceNode = setupNode.getElementsByTagName('interface'); n@1124: if (interfaceNode.length > 1) n@1124: { n@1124: this.errors.push("Only one node in the node allowed! Others except first ingnored!"); n@1124: } n@1124: this.interfaces = new this.interfaceNode(); n@1124: if (interfaceNode.length != 0) n@1124: { n@1124: interfaceNode = interfaceNode[0]; n@1148: this.interfaces.decode(this,interfaceNode,this.schema.getAllElementsByName('interface')[1]); n@1118: } n@1118: n@1124: // Page tags n@1124: var pageTags = projectXML.getElementsByTagName('page'); n@1148: var pageSchema = this.schema.getAllElementsByName('page')[0]; n@1124: for (var i=0; i n@1172: var commentboxprefix = root.createElement("commentboxprefix"); n@1172: commentboxprefix.textContent = this.commentBoxPrefix; n@1172: AHNode.appendChild(commentboxprefix); n@1172: n@1118: for (var i=0; i n@1118: for (var i=0; i tag. n@1118: this.interfaceObjects = []; n@1118: this.interfaceObject = function(){}; n@1118: n@1118: this.resizeWindow = function(event) n@1118: { n@1118: popup.resize(event); n@1118: for(var i=0; i= 600) n@1118: { n@1118: boxwidth = 600; n@1118: } n@1118: else if (boxwidth < 400) n@1118: { n@1118: boxwidth = 400; n@1118: } n@1118: this.trackComment.style.width = boxwidth+"px"; n@1118: this.trackCommentBox.style.width = boxwidth-6+"px"; n@1118: }; n@1118: this.resize(); n@1118: }; n@1118: n@1118: this.commentQuestions = []; n@1118: n@1118: this.commentBox = function(commentQuestion) { n@1118: this.specification = commentQuestion; n@1118: // Create document objects to hold the comment boxes n@1118: this.holder = document.createElement('div'); n@1118: this.holder.className = 'comment-div'; n@1118: // Create a string next to each comment asking for a comment n@1118: this.string = document.createElement('span'); n@1124: this.string.innerHTML = commentQuestion.statement; n@1118: // Create the HTML5 comment box 'textarea' n@1118: this.textArea = document.createElement('textarea'); n@1118: this.textArea.rows = '4'; n@1118: this.textArea.cols = '100'; n@1118: this.textArea.className = 'trackComment'; n@1118: var br = document.createElement('br'); n@1118: // Add to the holder. n@1118: this.holder.appendChild(this.string); n@1118: this.holder.appendChild(br); n@1118: this.holder.appendChild(this.textArea); n@1118: n@1118: this.exportXMLDOM = function() { n@1118: var root = document.createElement('comment'); n@1118: root.id = this.specification.id; n@1118: root.setAttribute('type',this.specification.type); n@1118: root.textContent = this.textArea.value; n@1118: console.log("Question: "+this.string.textContent); n@1118: console.log("Response: "+root.textContent); n@1118: return root; n@1118: }; n@1118: this.resize = function() n@1118: { n@1118: var boxwidth = (window.innerWidth-100)/2; n@1118: if (boxwidth >= 600) n@1118: { n@1118: boxwidth = 600; n@1118: } n@1118: else if (boxwidth < 400) n@1118: { n@1118: boxwidth = 400; n@1118: } n@1118: this.holder.style.width = boxwidth+"px"; n@1118: this.textArea.style.width = boxwidth-6+"px"; n@1118: }; n@1118: this.resize(); n@1118: }; n@1118: n@1118: this.radioBox = function(commentQuestion) { n@1118: this.specification = commentQuestion; n@1118: // Create document objects to hold the comment boxes n@1118: this.holder = document.createElement('div'); n@1118: this.holder.className = 'comment-div'; n@1118: // Create a string next to each comment asking for a comment n@1118: this.string = document.createElement('span'); n@1118: this.string.innerHTML = commentQuestion.statement; n@1118: var br = document.createElement('br'); n@1118: // Add to the holder. n@1118: this.holder.appendChild(this.string); n@1118: this.holder.appendChild(br); n@1118: this.options = []; n@1118: this.inputs = document.createElement('div'); n@1118: this.span = document.createElement('div'); n@1118: this.inputs.align = 'center'; n@1118: this.inputs.style.marginLeft = '12px'; n@1118: this.span.style.marginLeft = '12px'; n@1118: this.span.align = 'center'; n@1118: this.span.style.marginTop = '15px'; n@1118: n@1118: var optCount = commentQuestion.options.length; n@1124: for (var optNode of commentQuestion.options) n@1118: { n@1118: var div = document.createElement('div'); n@1118: div.style.width = '80px'; n@1118: div.style.float = 'left'; n@1118: var input = document.createElement('input'); n@1118: input.type = 'radio'; n@1118: input.name = commentQuestion.id; n@1124: input.setAttribute('setvalue',optNode.name); n@1118: input.className = 'comment-radio'; n@1118: div.appendChild(input); n@1118: this.inputs.appendChild(div); n@1118: n@1118: n@1118: div = document.createElement('div'); n@1118: div.style.width = '80px'; n@1118: div.style.float = 'left'; n@1118: div.align = 'center'; n@1118: var span = document.createElement('span'); n@1124: span.textContent = optNode.text; n@1118: span.className = 'comment-radio-span'; n@1118: div.appendChild(span); n@1118: this.span.appendChild(div); n@1118: this.options.push(input); n@1118: } n@1118: this.holder.appendChild(this.span); n@1118: this.holder.appendChild(this.inputs); n@1118: n@1118: this.exportXMLDOM = function() { n@1118: var root = document.createElement('comment'); n@1118: root.id = this.specification.id; n@1118: root.setAttribute('type',this.specification.type); n@1118: var question = document.createElement('question'); n@1118: question.textContent = this.string.textContent; n@1118: var response = document.createElement('response'); n@1118: var i=0; n@1118: while(this.options[i].checked == false) { n@1118: i++; n@1118: if (i >= this.options.length) { n@1118: break; n@1118: } n@1118: } n@1118: if (i >= this.options.length) { n@1118: response.textContent = 'null'; n@1118: } else { n@1118: response.textContent = this.options[i].getAttribute('setvalue'); n@1118: response.setAttribute('number',i); n@1118: } n@1118: console.log('Comment: '+question.textContent); n@1118: console.log('Response: '+response.textContent); n@1118: root.appendChild(question); n@1118: root.appendChild(response); n@1118: return root; n@1118: }; n@1118: this.resize = function() n@1118: { n@1118: var boxwidth = (window.innerWidth-100)/2; n@1118: if (boxwidth >= 600) n@1118: { n@1118: boxwidth = 600; n@1118: } n@1118: else if (boxwidth < 400) n@1118: { n@1118: boxwidth = 400; n@1118: } n@1118: this.holder.style.width = boxwidth+"px"; n@1118: var text = this.holder.children[2]; n@1118: var options = this.holder.children[3]; n@1118: var optCount = options.children.length; n@1118: var spanMargin = Math.floor(((boxwidth-20-(optCount*80))/(optCount))/2)+'px'; n@1118: var options = options.firstChild; n@1118: var text = text.firstChild; n@1118: options.style.marginRight = spanMargin; n@1118: options.style.marginLeft = spanMargin; n@1118: text.style.marginRight = spanMargin; n@1118: text.style.marginLeft = spanMargin; n@1118: while(options.nextSibling != undefined) n@1118: { n@1118: options = options.nextSibling; n@1118: text = text.nextSibling; n@1118: options.style.marginRight = spanMargin; n@1118: options.style.marginLeft = spanMargin; n@1118: text.style.marginRight = spanMargin; n@1118: text.style.marginLeft = spanMargin; n@1118: } n@1118: }; n@1118: this.resize(); n@1118: }; n@1118: n@1118: this.checkboxBox = function(commentQuestion) { n@1118: this.specification = commentQuestion; n@1118: // Create document objects to hold the comment boxes n@1118: this.holder = document.createElement('div'); n@1118: this.holder.className = 'comment-div'; n@1118: // Create a string next to each comment asking for a comment n@1118: this.string = document.createElement('span'); n@1118: this.string.innerHTML = commentQuestion.statement; n@1118: var br = document.createElement('br'); n@1118: // Add to the holder. n@1118: this.holder.appendChild(this.string); n@1118: this.holder.appendChild(br); n@1118: this.options = []; n@1118: this.inputs = document.createElement('div'); n@1118: this.span = document.createElement('div'); n@1118: this.inputs.align = 'center'; n@1118: this.inputs.style.marginLeft = '12px'; n@1118: this.span.style.marginLeft = '12px'; n@1118: this.span.align = 'center'; n@1118: this.span.style.marginTop = '15px'; n@1118: n@1118: var optCount = commentQuestion.options.length; n@1118: for (var i=0; i= 600) n@1118: { n@1118: boxwidth = 600; n@1118: } n@1118: else if (boxwidth < 400) n@1118: { n@1118: boxwidth = 400; n@1118: } n@1118: this.holder.style.width = boxwidth+"px"; n@1118: var text = this.holder.children[2]; n@1118: var options = this.holder.children[3]; n@1118: var optCount = options.children.length; n@1118: var spanMargin = Math.floor(((boxwidth-20-(optCount*80))/(optCount))/2)+'px'; n@1118: var options = options.firstChild; n@1118: var text = text.firstChild; n@1118: options.style.marginRight = spanMargin; n@1118: options.style.marginLeft = spanMargin; n@1118: text.style.marginRight = spanMargin; n@1118: text.style.marginLeft = spanMargin; n@1118: while(options.nextSibling != undefined) n@1118: { n@1118: options = options.nextSibling; n@1118: text = text.nextSibling; n@1118: options.style.marginRight = spanMargin; n@1118: options.style.marginLeft = spanMargin; n@1118: text.style.marginRight = spanMargin; n@1118: text.style.marginLeft = spanMargin; n@1118: } n@1118: }; n@1118: this.resize(); n@1118: }; n@1118: n@1118: this.createCommentBox = function(audioObject) { n@1118: var node = new this.elementCommentBox(audioObject); n@1118: this.commentBoxes.push(node); n@1118: audioObject.commentDOM = node; n@1118: return node; n@1118: }; n@1118: n@1118: this.sortCommentBoxes = function() { n@1138: this.commentBoxes.sort(function(a,b){return a.id - b.id;}); n@1118: }; n@1118: n@1118: this.showCommentBoxes = function(inject, sort) { n@1118: if (sort) {interfaceContext.sortCommentBoxes();} n@1138: for (var box of interfaceContext.commentBoxes) { n@1138: inject.appendChild(box.trackComment); n@1118: } n@1118: }; n@1118: n@1118: this.deleteCommentBoxes = function() { n@1118: this.commentBoxes = []; n@1118: }; n@1118: n@1118: this.createCommentQuestion = function(element) { n@1118: var node; n@1124: if (element.type == 'question') { n@1118: node = new this.commentBox(element); n@1118: } else if (element.type == 'radio') { n@1118: node = new this.radioBox(element); n@1118: } else if (element.type == 'checkbox') { n@1118: node = new this.checkboxBox(element); n@1118: } n@1118: this.commentQuestions.push(node); n@1118: return node; n@1118: }; n@1118: n@1118: this.deleteCommentQuestions = function() n@1118: { n@1118: this.commentQuestions = []; n@1118: }; n@1118: n@1118: this.playhead = new function() n@1118: { n@1118: this.object = document.createElement('div'); n@1118: this.object.className = 'playhead'; n@1118: this.object.align = 'left'; n@1118: var curTime = document.createElement('div'); n@1118: curTime.style.width = '50px'; n@1118: this.curTimeSpan = document.createElement('span'); n@1118: this.curTimeSpan.textContent = '00:00'; n@1118: curTime.appendChild(this.curTimeSpan); n@1118: this.object.appendChild(curTime); n@1118: this.scrubberTrack = document.createElement('div'); n@1118: this.scrubberTrack.className = 'playhead-scrub-track'; n@1118: n@1118: this.scrubberHead = document.createElement('div'); n@1118: this.scrubberHead.id = 'playhead-scrubber'; n@1118: this.scrubberTrack.appendChild(this.scrubberHead); n@1118: this.object.appendChild(this.scrubberTrack); n@1118: n@1118: this.timePerPixel = 0; n@1118: this.maxTime = 0; n@1118: n@1118: this.playbackObject; n@1118: n@1118: this.setTimePerPixel = function(audioObject) { n@1118: //maxTime must be in seconds n@1118: this.playbackObject = audioObject; n@1118: this.maxTime = audioObject.buffer.buffer.duration; n@1118: var width = 490; //500 - 10, 5 each side of the tracker head n@1118: this.timePerPixel = this.maxTime/490; n@1118: if (this.maxTime < 60) { n@1118: this.curTimeSpan.textContent = '0.00'; n@1118: } else { n@1118: this.curTimeSpan.textContent = '00:00'; n@1118: } n@1118: }; n@1118: n@1118: this.update = function() { n@1118: // Update the playhead position, startPlay must be called n@1118: if (this.timePerPixel > 0) { n@1118: var time = this.playbackObject.getCurrentPosition(); n@1167: if (time > 0 && time < this.maxTime) { n@1118: var width = 490; n@1118: var pix = Math.floor(time/this.timePerPixel); n@1118: this.scrubberHead.style.left = pix+'px'; n@1118: if (this.maxTime > 60.0) { n@1118: var secs = time%60; n@1118: var mins = Math.floor((time-secs)/60); n@1118: secs = secs.toString(); n@1118: secs = secs.substr(0,2); n@1118: mins = mins.toString(); n@1118: this.curTimeSpan.textContent = mins+':'+secs; n@1118: } else { n@1118: time = time.toString(); n@1118: this.curTimeSpan.textContent = time.substr(0,4); n@1118: } n@1118: } else { n@1118: this.scrubberHead.style.left = '0px'; n@1118: if (this.maxTime < 60) { n@1118: this.curTimeSpan.textContent = '0.00'; n@1118: } else { n@1118: this.curTimeSpan.textContent = '00:00'; n@1118: } n@1118: } n@1118: } n@1118: }; n@1118: n@1118: this.interval = undefined; n@1118: n@1118: this.start = function() { n@1118: if (this.playbackObject != undefined && this.interval == undefined) { n@1118: if (this.maxTime < 60) { n@1118: this.interval = setInterval(function(){interfaceContext.playhead.update();},10); n@1118: } else { n@1118: this.interval = setInterval(function(){interfaceContext.playhead.update();},100); n@1118: } n@1118: } n@1118: }; n@1118: this.stop = function() { n@1118: clearInterval(this.interval); n@1118: this.interval = undefined; n@1118: if (this.maxTime < 60) { n@1118: this.curTimeSpan.textContent = '0.00'; n@1118: } else { n@1118: this.curTimeSpan.textContent = '00:00'; n@1118: } n@1118: }; n@1118: }; n@1154: n@1154: this.volume = new function() n@1154: { n@1154: // An in-built volume module which can be viewed on page n@1154: // Includes trackers on page-by-page data n@1154: // Volume does NOT reset to 0dB on each page load n@1154: this.valueLin = 1.0; n@1154: this.valueDB = 0.0; n@1154: this.object = document.createElement('div'); n@1154: this.object.id = 'master-volume-holder'; n@1154: this.slider = document.createElement('input'); n@1154: this.slider.id = 'master-volume-control'; n@1154: this.slider.type = 'range'; n@1154: this.valueText = document.createElement('span'); n@1154: this.valueText.id = 'master-volume-feedback'; n@1154: this.valueText.textContent = '0dB'; n@1154: n@1154: this.slider.min = -60; n@1154: this.slider.max = 12; n@1154: this.slider.value = 0; n@1154: this.slider.step = 1; n@1154: this.slider.onmousemove = function(event) n@1154: { n@1154: interfaceContext.volume.valueDB = event.currentTarget.value; n@1154: interfaceContext.volume.valueLin = decibelToLinear(interfaceContext.volume.valueDB); n@1154: interfaceContext.volume.valueText.textContent = interfaceContext.volume.valueDB+'dB'; n@1154: audioEngineContext.outputGain.gain.value = interfaceContext.volume.valueLin; n@1154: } n@1154: this.slider.onmouseup = function(event) n@1154: { n@1154: var storePoint = testState.currentStore.XMLDOM.children[0].getAllElementsByName('volumeTracker'); n@1154: if (storePoint.length == 0) n@1154: { n@1154: storePoint = storage.document.createElement('metricresult'); n@1154: storePoint.setAttribute('name','volumeTracker'); n@1154: testState.currentStore.XMLDOM.children[0].appendChild(storePoint); n@1154: } n@1154: else { n@1154: storePoint = storePoint[0]; n@1154: } n@1154: var node = storage.document.createElement('movement'); n@1154: node.setAttribute('test-time',audioEngineContext.timer.getTestTime()); n@1154: node.setAttribute('volume',interfaceContext.volume.valueDB); n@1154: node.setAttribute('format','dBFS'); n@1154: storePoint.appendChild(node); n@1154: } n@1154: n@1155: var title = document.createElement('div'); n@1155: title.innerHTML = 'Master Volume Control'; n@1155: title.style.fontSize = '0.75em'; n@1155: title.style.width = "100%"; n@1155: title.align = 'center'; n@1155: this.object.appendChild(title); n@1155: n@1154: this.object.appendChild(this.slider); n@1154: this.object.appendChild(this.valueText); n@1154: } n@1118: // Global Checkers n@1118: // These functions will help enforce the checkers n@1118: this.checkHiddenAnchor = function() n@1118: { n@1124: for (var ao of audioEngineContext.audioObjects) n@1118: { n@1124: if (ao.specification.type == "anchor") n@1118: { n@1125: if (ao.interfaceDOM.getValue() > (ao.specification.marker/100) && ao.specification.marker > 0) { n@1124: // Anchor is not set below n@1124: console.log('Anchor node not below marker value'); n@1124: alert('Please keep listening'); n@1167: this.storeErrorNode('Anchor node not below marker value'); n@1124: return false; n@1124: } n@1118: } n@1118: } n@1118: return true; n@1118: }; n@1118: n@1118: this.checkHiddenReference = function() n@1118: { n@1124: for (var ao of audioEngineContext.audioObjects) n@1118: { n@1124: if (ao.specification.type == "reference") n@1118: { n@1125: if (ao.interfaceDOM.getValue() < (ao.specification.marker/100) && ao.specification.marker > 0) { n@1124: // Anchor is not set below n@1167: console.log('Reference node not above marker value'); n@1167: this.storeErrorNode('Reference node not above marker value'); n@1124: alert('Please keep listening'); n@1124: return false; n@1124: } n@1118: } n@1118: } n@1118: return true; n@1118: }; n@1118: n@1118: this.checkFragmentsFullyPlayed = function () n@1118: { n@1118: // Checks the entire file has been played back n@1118: // NOTE ! This will return true IF playback is Looped!!! n@1118: if (audioEngineContext.loopPlayback) n@1118: { n@1118: console.log("WARNING - Looped source: Cannot check fragments are fully played"); n@1118: return true; n@1118: } n@1118: var check_pass = true; n@1118: var error_obj = []; n@1118: for (var i = 0; i= time) n@1118: { n@1118: passed = true; n@1118: break; n@1118: } n@1118: } n@1118: if (passed == false) n@1118: { n@1118: check_pass = false; n@1140: console.log("Continue listening to track-"+audioEngineContext.audioObjects.interfaceDOM.getPresentedId()); n@1140: error_obj.push(audioEngineContext.audioObjects.interfaceDOM.getPresentedId()); n@1118: } n@1118: } n@1118: if (check_pass == false) n@1118: { n@1118: var str_start = "You have not completely listened to fragments "; n@1118: for (var i=0; i 0) n@1124: { n@1124: aeNode.setAttribute('marker',element.marker); n@1124: } n@1124: } n@1124: var ae_metric = this.parent.document.createElement('metric'); n@1124: aeNode.appendChild(ae_metric); n@1124: this.XMLDOM.appendChild(aeNode); n@1124: } n@1124: n@1124: // Add any commentQuestions n@1124: for (var element of this.specification.commentQuestions) n@1124: { n@1124: var cqNode = this.parent.document.createElement('commentquestion'); n@1124: cqNode.id = element.id; n@1124: cqNode.setAttribute('type',element.type); n@1124: var statement = this.parent.document.createElement('statement'); n@1124: statement.textContent = cqNode.statement; n@1124: cqNode.appendChild(statement); n@1124: var response = this.parent.document.createElement('response'); n@1124: cqNode.appendChild(response); n@1124: this.XMLDOM.appendChild(cqNode); n@1124: } n@1124: n@1124: this.parent.root.appendChild(this.XMLDOM); n@1124: }; n@1124: this.finish = function() n@1124: { n@1124: if (this.state == 0) n@1124: { n@1124: var projectDocument = specification.projectXML; n@1124: projectDocument.setAttribute('file-name',url); n@1124: this.root.appendChild(projectDocument); n@1124: this.root.appendChild(returnDateNode()); n@1124: this.root.appendChild(interfaceContext.returnNavigator()); n@1124: } n@1124: this.state = 1; n@1124: return this.root; n@1124: }; n@1124: }