n@3096: function escapeHTML(e){return e.split("&").join("&").split("<").join("<").split('"').join(""")}function qualifyURL(e){var t=document.createElement("div");return t.innerHTML='x',t.firstChild.href}function loadProjectSpec(e){var t=new XMLHttpRequest;t.open("GET","xml/test-schema.xsd",!0),t.onload=function(){specification.processSchema(t.response);var i=new XMLHttpRequest;i.open("GET",e,!0),i.onload=function(){loadProjectSpecCallback(i.response)},i.onerror=function(){document.getElementsByTagName("body")[0].innerHTML=null;var e=document.createElement("h3");e.textContent="FATAL ERROR";var t=document.createElement("p");t.textContent="There was an error when loading your XML file. Please check your path in the URL. After the path to this page, there should be '?url=path/to/your/file.xml'. Check the spelling of your filename as well. If you are still having issues, check the log of the python server or your webserver distribution for 404 codes for your file.",document.getElementsByTagName("body")[0].appendChild(e),document.getElementsByTagName("body")[0].appendChild(t)},i.send()},t.send()}function loadProjectSpecCallback(e){var t,i,n=(new DOMParser).parseFromString(e,"text/xml"),o=n.getElementsByTagName("parsererror");if(o.length>=1)return t=document.createElement("h3"),t.textContent="FATAL ERROR",i=document.createElement("span"),i.textContent="The XML parser returned the following errors when decoding your XML file",document.getElementsByTagName("body")[0].innerHTML=null,document.getElementsByTagName("body")[0].appendChild(t),document.getElementsByTagName("body")[0].appendChild(i),void document.getElementsByTagName("body")[0].appendChild(o[0]);if(void 0===n||void 0===n.firstChild)return t=document.createElement("h3"),t.textContent="FATAL ERROR",i=document.createElement("span"),i.textContent="The project XML was not decoded properly, try refreshing your browser and clearing caches. If the problem persists, contact the test creator.",document.getElementsByTagName("body")[0].innerHTML=null,document.getElementsByTagName("body")[0].appendChild(t),void document.getElementsByTagName("body")[0].appendChild(i);if("waet"==n.firstChild.nodeName){var s={xml:e,schema:specification.getSchemaString(),arguments:["--noout","--schema","test-schema.xsd","document.xml"]};projectXML=n;var r=validateXML(s);if(console.log(r),"document.xml validates\n"!=r){document.getElementsByTagName("body")[0].innerHTML=null,(t=document.createElement("h3")).textContent="FATAL ERROR",(i=document.createElement("h4")).textContent="The XML validator returned the following errors when decoding your XML file",document.getElementsByTagName("body")[0].appendChild(t),document.getElementsByTagName("body")[0].appendChild(i),r=r.split("\n");for(var a in r)document.getElementsByTagName("body")[0].appendChild(document.createElement("br")),(i=document.createElement("span")).textContent=r[a],document.getElementsByTagName("body")[0].appendChild(i);return}specification.decode(projectXML),storage.initialise()}else if("waetresult"==n.firstChild.nodeName){(projectXML=document.implementation.createDocument(null,"waet")).firstChild.appendChild(n.getElementsByTagName("waet")[0].getElementsByTagName("setup")[0].cloneNode(!0));for(var c,l=n.firstChild.firstChild;null!==l;){if("survey"==l.nodeName)if("complete"==l.getAttribute("state"))for(var u=l.getAttribute("location"),h=projectXML.getElementsByTagName("setup")[0].getElementsByTagName("survey")[0];null!==h;){if("pre"==u||"before"==u){if("pre"==h.getAttribute("location")||"before"==h.getAttribute("location")){projectXML.getElementsByTagName("setup")[0].removeChild(h);break}}else if("post"==h.getAttribute("location")||"after"==h.getAttribute("location")){projectXML.getElementsByTagName("setup")[0].removeChild(h);break}h=h.nextElementSibling}else c=l,l=l.previousElementSibling,n.firstChild.removeChild(c);else"page"==l.nodeName&&"empty"==l.getAttribute("state")&&(projectXML.firstChild.appendChild(n.getElementById(l.getAttribute("ref")).cloneNode(!0)),c=l,l=l.previousElementSibling,n.firstChild.removeChild(c));l=l.nextElementSibling}specification.decode(projectXML),storage.initialise(n)}if(isFinite(specification.sampleRate)&&Number(specification.sampleRate)!=audioContext.sampleRate){var p="Sample rates do not match! Requested "+Number(specification.sampleRate)+", got "+audioContext.sampleRate+". Please set the sample rate to match before completing this test.";interfaceContext.lightbox.post("Error",p)}else{var d=new XMLHttpRequest;d.open("GET","interfaces/interfaces.json"),d.onerror=function(e){throw e},d.onload=function(){if(200!==d.status)throw new Error(d.status);var e=specification.interface,t=document.getElementsByTagName("head")[0],i=JSON.parse(d.responseText).interfaces.find(function(t){return t.name==e});if(!i)throw"Cannot load desired interface";i.scripts.forEach(function(e){var i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("src",e),t.appendChild(i)}),i.css.forEach(function(e){var i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",e),t.appendChild(i)})},d.send(),void 0!==gReturnURL&&(console.log("returnURL Overide from "+specification.returnURL+" to "+gReturnURL),specification.returnURL=gReturnURL),void 0!==gSaveFilenamePrefix&&(specification.saveFilenamePrefix=gSaveFilenamePrefix),audioEngineContext=new AudioEngine(specification)}}function createProjectSave(e){window.onbeforeunload=null;var t=storage.finish(),i=document.createElement("div");i.appendChild(t);var n=[i.innerHTML];if("local"==e){var o=new Blob(n,{type:"application/xml"}),s=window.URL.createObjectURL(o),r=document.createElement("a");r.hidden="",r.href=s,r.download="save.xml",r.textContent="Save File",popup.showPopup(),popup.popupContent.innerHTML="Please save the file below to give to your test supervisor
",popup.popupContent.appendChild(r)}else{"string"==typeof specification.projectReturn&&"http"==specification.projectReturn.substr(0,4)&&specification.projectReturn,storage.SessionKey.finish().then(function(e){"string"==typeof specification.returnURL&&specification.returnURL.length>0?window.location=specification.returnURL:popup.popupContent.textContent=specification.exitText},function(e){console.log("Save: Error! "+e.textContent),createProjectSave("local")}),popup.showPopup(),popup.popupContent.innerHTML=null,popup.popupContent.textContent="Submitting. Please Wait","function"==typeof popup.hideNextButton&&popup.hideNextButton(),"function"==typeof popup.hidePreviousButton&&popup.hidePreviousButton()}}function errorSessionDump(e){popup.showPopup(),popup.popupContent.innerHTML=null;var t=document.createElement("error"),i=document.createElement("div");"object"==typeof e?(t.appendChild(e),popup.popupContent.appendChild(e)):(t.textContent=e,popup.popupContent.innerHTML="ERROR : "+e);var n=interfaceXMLSave();n.appendChild(t),i.appendChild(n);var o=[i.innerHTML],s=new Blob(o,{type:"application/xml"}),r=window.URL.createObjectURL(s),a=document.createElement("a");a.hidden="",a.href=r,a.download="save.xml",a.textContent="Save File",popup.popupContent.appendChild(a)}function interfaceXMLSave(){return storage.finish()}function linearToDecibel(e){return 20*Math.log10(e)}function decibelToLinear(e){return Math.pow(10,e/20)}function secondsToSamples(e,t){return Math.round(e*t)}function samplesToSeconds(e,t){return e/t}function randomString(e){for(var t="",i=0;ie.length&&(t=e.length);for(var i=[];t>0;){var n=Math.floor(Math.random()*e.length);i.push(e.splice(n,1)[0]),t--}return i}function interfacePopup(){function e(e,r){function a(e){var t=this.popupOptions.findIndex(function(t,i,n){return t.specification.id==e},this);this.currentIndex=t-1}var c;if("question"===e.specification.type)c=t;else if("checkbox"===e.specification.type)c=i;else if("radio"===e.specification.type)c=n;else if("number"===e.specification.type)c=o;else{if("slider"!==e.specification.type)return;c=s}for(var l=0;lNumber(i.value))return!0;break;case"lessThan":if(tNumber(e.value))return!0;break;case"lessThan":if(t0;)this.popupTitle.appendChild(o[0]);"question"==e.specification.type?function(e){var t=document.createElement("textarea");switch(e.specification.boxsize){case"small":t.cols="20",t.rows="1";break;case"normal":t.cols="30",t.rows="2";break;case"large":t.cols="40",t.rows="5";break;case"huge":t.cols="50",t.rows="10"}void 0===e.response?e.response="":t.value=e.response,this.popupResponse.appendChild(t),t.focus(),this.popupResponse.style.textAlign="center",this.popupResponse.style.left="0%"}.call(this,e):"checkbox"==e.specification.type?function(e){null===e.response&&(e.response=[]);var t=document.createElement("table");t.className="popup-option-list",t.border="0";var i=[];e.specification.options.forEach(function(t,n){var o=document.createElement("tr");i.push(o);var s=document.createElement("td");o.appendChild(s);var r=document.createElement("input");r.id=t.name,r.type="checkbox",s.appendChild(r),s=document.createElement("td"),o.appendChild(s);var a=document.createElement("span");a.textContent=t.text,s.appendChild(a),(o=document.createElement("div")).setAttribute("name","option"),o.className="popup-option-checbox";var c;e.response.length>0&&(c=e.response.find(function(e){return e.name==t.name})),void 0!==c?!0===c.checked&&(r.checked="true"):e.response.push({name:t.name,text:t.text,checked:!1})}),e.specification.randomise&&(i=randomiseOrder(i)),i.forEach(function(e){t.appendChild(e)}),this.popupResponse.appendChild(t)}.call(this,e):"radio"==e.specification.type?function(e){null===e.response&&(e.response={name:"",text:""});var t=document.createElement("table");t.className="popup-option-list",t.border="0";var i=[];e.specification.options.forEach(function(t,n){var o=document.createElement("tr");i.push(o);var s=document.createElement("td");o.appendChild(s);var r=document.createElement("input");r.id=t.name,r.type="radio",r.name=e.specification.id,s.appendChild(r),s=document.createElement("td"),o.appendChild(s);var a=document.createElement("span");a.textContent=t.text,s.appendChild(a),(o=document.createElement("div")).setAttribute("name","option"),o.className="popup-option-checkbox",e.response.name===t.name&&(r.checked=!0)}),e.specification.randomise&&(i=randomiseOrder(i)),i.forEach(function(e){t.appendChild(e)}),this.popupResponse.appendChild(t)}.call(this,e):"number"==e.specification.type?function(e){var t=document.createElement("input");t.type="textarea",null!==e.specification.min&&(t.min=e.specification.min),null!==e.specification.max&&(t.max=e.specification.max),null!==e.specification.step&&(t.step=e.specification.step),void 0!==e.response&&(t.value=e.response),this.popupResponse.appendChild(t),this.popupResponse.style.textAlign="center",this.popupResponse.style.left="0%"}.call(this,e):"video"==e.specification.type?function(e){var t=document.createElement("video");t.src=e.specification.url,this.popupResponse.appendChild(t)}.call(this,e):"youtube"==e.specification.type?function(e){var t=document.createElement("iframe");t.className="youtube",t.src=e.specification.url,this.popupResponse.appendChild(t)}.call(this,e):"slider"==e.specification.type&&function(e){var t=document.createElement("div"),i=document.createElement("input");i.type="range",i.style.width="90%",null!==e.specification.min&&(i.min=e.specification.min),null!==e.specification.max&&(i.max=e.specification.max),void 0!==e.response&&(i.value=e.response),t.className="survey-slider-text-holder";var n=document.createElement("span"),o=document.createElement("span");n.textContent=e.specification.leftText,o.textContent=e.specification.rightText,t.appendChild(n),t.appendChild(o),this.popupResponse.appendChild(i),this.popupResponse.appendChild(t),this.popupResponse.style.textAlign="center"}.call(this,e),this.currentIndex+1==this.popupOptions.length?"pre"==this.node.location?this.buttonProceed.textContent="Start":this.buttonProceed.textContent="Submit":this.buttonProceed.textContent="Next",this.currentIndex>0?this.buttonPrevious.style.visibility="visible":this.buttonPrevious.style.visibility="hidden"},this.initState=function(e,t){e.options.length>0?(this.popupOptions=[],this.node=e,this.store=t,e.options.forEach(function(e){this.popupOptions.push({specification:e,response:null})},this),this.currentIndex=0,this.showPopup(),this.postNode()):advanceState()},this.proceedClicked=function(){if(0===testState.stateIndex&&specification.calibration)return interfaceContext.calibrationModuleObject.collect(),void advanceState();var t=this.popupOptions[this.currentIndex],i=!0,n=(new Date-r)/1e3;n1&&(s+="s"),void interfaceContext.lightbox.post("Error",s)}}else if(ot.specification.max)return t.specification.min==t.specification.max?interfaceContext.lightbox.post("Error","You must only select "+t.specification.min):interfaceContext.lightbox.post("Error","You must select between "+t.specification.min+" and "+t.specification.max),!1;for(i=0;it.specification.max&&null!==t.specification.max?(interfaceContext.lightbox.post("Error","Number is above the maximum value of "+t.specification.max),!1):(t.response=i.value,e.call(this,t,t.response),!0)}.call(this,t):"slider"==t.specification.type&&(i=function(t){var i=this.popupContent.getElementsByTagName("input")[0];return t.response=i.value,e.call(this,t,t.response),!0}.call(this,t)),!1!==i&&(this.currentIndex++,this.currentIndex0&&(this.currentIndex--,this.postNode())},this.resize=function(e){if(null!==this.popup){this.popup.style.left=window.innerWidth/2-250+"px",this.popup.style.top=window.innerHeight/2-125+"px";var t=document.getElementsByClassName("testHalt")[0];t.style.width=window.innerWidth,t.style.height=window.innerHeight}},this.hideNextButton=function(){this.buttonProceed.style.visibility="hidden"},this.hidePreviousButton=function(){this.buttonPrevious.style.visibility="hidden"},this.showNextButton=function(){this.buttonProceed.style.visibility="visible"},this.showPreviousButton=function(){this.buttonPrevious.style.visibility="visible"}}function advanceState(){testState.advanceState()}function stateMachine(){function e(e,t){var i=[];return e.forEach(function(t,n){t.alwaysInclude&&i.push(e.splice(n,1)[0])}),i.concat(randomSubArray(e,t-i.length))}this.stateMap=[],this.preTestSurvey=null,this.postTestSurvey=null,this.stateIndex=null,this.currentStateMap=null,this.currentStatePosition=null,this.currentStore=null,this.initialise=function(){var t=[];specification.pages.forEach(function(e){(null!==e.position||e.alwaysInclude)&&(e.alwaysInclude=!0),t.push(e)}),specification.numPages>0&&(specification.randomiseOrder=!0,t=e(t,specification.numPages));var i=[];t.forEach(function(e){if(void 0!==e.position){i.push(e);var n=t.indexOf(e);t.splice(n,1)}}),specification.randomiseOrder&&(t=randomiseOrder(t)),i.forEach(function(e){t.splice(e.position,0,e)}),t.forEach(function(t,i){t.presentedId=i,this.stateMap.push(t);t.audioElements;!function(t){var i=[],n=[],o=[];t.audioElements.forEach(function(e){e.label.length>0||void 0!==e.postion?i.push(e):"outside-reference"===e.type?n.push(e):o.push(e)}),(t.poolSize>0||t.randomiseOrder)&&(t.randomiseOrder=!0,0===t.poolSize&&(t.poolSize=t.audioElements.length),t.poolSize-=i.length,o=e(o,t.poolSize)),t.randomiseOrder&&(o=randomiseOrder(o)),i=i.concat(o),t.audioElements=i.concat(n),t.audioElements.forEach(function(e,t){e.position=t})}(t),storage.createTestPageStore(t),audioEngineContext.loadPageData(t)},this),null!==specification.preTest&&(this.preTestSurvey=specification.preTest),null!==specification.postTest&&(this.postTestSurvey=specification.postTest),this.stateMap.length>0?(null!==this.stateIndex&&console.log("NOTE - State already initialise"),this.stateIndex=-2,console.log("Starting test...")):console.log("FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP")},this.advanceState=function(){if(null===this.stateIndex&&this.initialise(),this.stateIndex>-2&&storage.update(),-2==this.stateIndex)this.stateIndex++,void 0!==this.preTestSurvey?popup.initState(this.preTestSurvey,storage.globalPreTest):this.advanceState();else if(-1==this.stateIndex)this.stateIndex++,specification.calibration?(popup.showPopup(),popup.popupTitle.textContent="Calibration. Set the levels so all tones are of equal amplitude. Move your mouse over the sliders to hear the tones. The red slider is the reference tone",interfaceContext.calibrationModuleObject=new interfaceContext.calibrationModule,interfaceContext.calibrationModuleObject.build(popup.popupResponse),popup.hidePreviousButton()):this.advanceState();else if(this.stateIndex==this.stateMap.length)console.log("Ending test ..."),this.stateIndex++,void 0===this.postTestSurvey?this.advanceState():popup.initState(this.postTestSurvey,storage.globalPostTest);else if(this.stateIndex>this.stateMap.length)createProjectSave(specification.projectReturn);else{if(popup.hidePopup(),null===this.currentStateMap)return this.currentStateMap=this.stateMap[this.stateIndex],this.currentStore=storage.testPages[this.stateIndex],void 0!==this.currentStateMap.preTest?(this.currentStatePosition="pre",popup.initState(this.currentStateMap.preTest,storage.testPages[this.stateIndex].preTest)):this.currentStatePosition="test",void interfaceContext.newPage(this.currentStateMap,storage.testPages[this.stateIndex]);switch(this.currentStatePosition){case"pre":this.currentStatePosition="test";break;case"test":if(this.currentStatePosition="post",this.testPageCompleted(),void 0===this.currentStateMap.postTest)return void this.advanceState();popup.initState(this.currentStateMap.postTest,storage.testPages[this.stateIndex].postTest);break;case"post":this.stateIndex++,this.currentStateMap=null,this.advanceState()}}},this.testPageCompleted=function(){var e=storage.testPages[this.stateIndex],t=e.XMLDOM.getElementsByTagName("metric")[0];if(audioEngineContext.metric.enableTestTimer){var i=e.parent.document.createElement("metricresult");i.id="testTime",i.textContent=audioEngineContext.timer.testDuration,t.appendChild(i)}audioEngineContext.audioObjects;audioEngineContext.audioObjects.forEach(function(e){e.exportXMLDOM()}),interfaceContext.commentQuestions.forEach(function(t){t.exportXMLDOM(e)}),pageXMLSave(e.XMLDOM,this.currentStateMap),e.complete()},this.getCurrentTestPage=function(){return this.stateIndex>=0&&this.stateIndex=0&&this.stateIndex=2&&(this.status=3);for(var e=0;e=e.length))return t(e[s].url).then(n.bind(this)).catch(i.bind(this));!function(){this.status=-1;for(var t=0;tthis.audioObjects.length)throw"FATAL - Passed id was undefined - AudioEngineContext.play(id)";var i=this.audioObjects[t].specification.maxNumberPlays||this.audioObjects[t].specification.parent.maxNumberPlays||e.maxNumberPlays;if(void 0!==i&&this.audioObjects[t].numberOfPlays>=i)interfaceContext.lightbox.post("Error","Cannot play this fragment more than "+i+" times");else if(1===this.status){if(this.timer.startTest(),interfaceContext.playhead.setTimePerPixel(this.audioObjects[t]),this.synchPlayback)(function(t){var i=audioContext.currentTime+.1;e.crossFade,this.audioObjects.forEach(function(e){e.setupPlayback(),e.bufferStart(i),e.id===t?e.listenStart(i):e.listenStop(i)})}).call(this,t);else{if(!1===this.bufferReady(t))return void console.log("Cannot play. Buffer not ready");(function(t){var i=audioContext.currentTime+.1,n=i+e.crossFade;this.audioObjects.forEach(function(e){e.id===t?(e.setupPlayback(),e.bufferStart(i),e.listenStart(i)):(e.listenStop(i),e.bufferStop(n))})}).call(this,t)}interfaceContext.playhead.start()}},this.stop=function(){if(1==this.status){var e=audioContext.currentTime+.1;this.audioObjects.forEach(function(t){t.listenStop(e),t.bufferStop(e)}),interfaceContext.playhead.stop()}},this.newTrack=function(e){var t=this.audioObjects.length;this.audioObjects[t]=new audioObject(t);var i=testState.currentStateMap.hostURL+e.url,n=this.buffers.find(function(e){return e.hasUrl(i)});void 0===n&&(console.log("[WARN]: Buffer was not loaded in pre-test! "+i),n=new this.bufferObj,this.buffers.push(n),n.getMedia(i)),this.audioObjects[t].specification=e,this.audioObjects[t].url=i;for(var o=this.pageStore.XMLDOM.getElementsByTagName("audioelement"),s=0;s0&&(this.bufferNode.stop(e),this.bufferNode=void 0),this.outputGain.gain.linearRampToValueAtTime(0,e),this.interfaceDOM.stopPlayback()},this.getCurrentPosition=function(){var e=audioEngineContext.timer.getTestTime();if(void 0!==this.bufferNode){var t=(e-this.bufferNode.playbackStartTime)%this.buffer.buffer.duration;return isNaN(t)?0:t}return 0},this.exportXMLDOM=function(){var e=storage.document.createElement("file");if(e.setAttribute("sampleRate",this.buffer.buffer.sampleRate),e.setAttribute("channels",this.buffer.buffer.numberOfChannels),e.setAttribute("sampleCount",this.buffer.buffer.length),e.setAttribute("duration",this.buffer.buffer.duration),this.storeDOM.appendChild(e),"outside-reference"!=this.specification.type){var t=this.interfaceDOM.exportXMLDOM(this);if(null!==t)if(void 0===t.length)this.storeDOM.appendChild(t);else for(var i=0;i0&&(this.wasMoved=!0),t!=(this.movementTracker.length>0?this.movementTracker[this.movementTracker.length-1]:-1)[1]&&(this.movementTracker[this.movementTracker.length]=[e,t])},this.startListening=function(e){if(!1===this.listenHold){this.wasListenedTo=!0,this.listenStart=e,this.listenHold=!0;var t=document.createElement("event"),i=document.createElement("testTime");i.setAttribute("start",e);var n=document.createElement("bufferTime");n.setAttribute("start",this.parent.getCurrentPosition()),t.appendChild(i),t.appendChild(n),this.listenTracker.push(t),console.log("slider "+this.parent.id+" played ("+e+")")}},this.stopListening=function(e,t){if(!0===this.listenHold){var i=e-this.listenStart;this.listenedTimer+=i,this.listenStart=0,this.listenHold=!1;var n=this.listenTracker[this.listenTracker.length-1],o=n.getElementsByTagName("testTime")[0],s=n.getElementsByTagName("bufferTime")[0];o.setAttribute("stop",e),void 0===t?s.setAttribute("stop",this.parent.getCurrentPosition()):s.setAttribute("stop",t),console.log("slider "+this.parent.id+" played for ("+i+")")}},this.exportXMLDOM=function(e){var t=[];return audioEngineContext.metric.enableElementTimer&&t.push(function(e){var t=storage.document.createElement("metricresult");return t.setAttribute("name","enableElementTimer"),t.textContent=this.listenedTimer,e.appendChild(t),t}.call(this,e)),audioEngineContext.metric.enableElementTracker&&t.push(function(e){var t=storage.document.createElement("metricresult");t.setAttribute("name","elementTrackerFull");for(var i=0;i=0)throw"Key "+e+" already bounded!";return this.keys.push({key:e,audioObject:t}),!0},deregisterKeyBinding:function(e){var t=this.keys.findIndex(function(t){return t.key==e});if(-1==t)throw"Key "+e+" not bounded!";return this.keys.splice(t,1),!0},resetKeyBindings:function(){this.keys=[]},handleEvent:function(e){" "===e.key?audioEngineContext.audioObjects.some(function(e){return e.playing})&&document.activeElement.className.indexOf("trackComment")>=0==!1&&(e.preventDefault(),audioEngineContext.stop()):function(e){var t=this.keys.findIndex(function(t){return t.key==e});t>=0&&audioEngineContext.play(this.keys[t].audioObject.id)}.call(this,e.key),console.log(e)}};return document.addEventListener("keydown",e,!1),e}(),this.interfaceObjects=[],this.interfaceObject=function(){},this.resizeWindow=function(e){popup.resize(e),this.volume.resize(),this.lightbox.resize(),this.commentBoxes.boxes.forEach(function(e){e.resize()}),this.commentQuestions.forEach(function(e){e.resize()});try{resizeWindow(e)}catch(e){console.log("Warning - Interface does not have Resize option"),console.log(e)}},this.returnNavigator=function(){var e=storage.document.createElement("navigator"),t=storage.document.createElement("platform");t.textContent=navigator.platform;var i=storage.document.createElement("vendor");i.textContent=navigator.vendor;var n=storage.document.createElement("uagent");n.textContent=navigator.userAgent;var o=storage.document.createElement("window");return o.setAttribute("innerWidth",window.innerWidth),o.setAttribute("innerHeight",window.innerHeight),e.appendChild(t),e.appendChild(i),e.appendChild(n),e.appendChild(o),e},this.returnDateNode=function(){var e=new Date,t=storage.document.createElement("datetime"),i=storage.document.createElement("date"),n=storage.document.createElement("time");return i.setAttribute("year",e.getFullYear()),i.setAttribute("month",e.getMonth()+1),i.setAttribute("day",e.getDate()),n.setAttribute("hour",e.getHours()),n.setAttribute("minute",e.getMinutes()),n.setAttribute("secs",e.getSeconds()),t.appendChild(i),t.appendChild(n),t},this.lightbox={parent:this,root:document.createElement("div"),content:document.createElement("div"),accept:document.createElement("button"),blanker:document.createElement("div"),post:function(e,t){switch(e){case"Error":this.content.className="lightbox-error";break;case"Warning":this.content.className="lightbox-warning";break;default:this.content.className="lightbox-message"}var i=document.createElement("p");i.textContent=t,this.content.appendChild(i),this.show()},show:function(){this.root.style.visibility="visible",this.blanker.style.visibility="visible",this.accept.focus()},clear:function(){this.root.style.visibility="",this.blanker.style.visibility="",this.content.textContent=""},handleEvent:function(e){e.currentTarget==this.accept&&this.clear()},resize:function(e){this.root.style.left=window.innerWidth/2-250+"px"},isVisible:function(){return"visible"==this.root.style.visibility}},this.lightbox.root.appendChild(this.lightbox.content),this.lightbox.root.appendChild(this.lightbox.accept),this.lightbox.root.className="popupHolder",this.lightbox.root.id="lightbox-root",this.lightbox.accept.className="popupButton",this.lightbox.accept.style.bottom="10px",this.lightbox.accept.textContent="OK",this.lightbox.accept.style.left="237.5px",this.lightbox.accept.addEventListener("click",this.lightbox),this.lightbox.blanker.className="testHalt",this.lightbox.blanker.id="lightbox-blanker",document.getElementsByTagName("body")[0].appendChild(this.lightbox.root),document.getElementsByTagName("body")[0].appendChild(this.lightbox.blanker),this.commentBoxes=function(){var e={};return e.boxes=[],e.injectPoint=null,e.elementCommentBox=function(e){e.specification;this.audioObject=e,this.id=e.id;var t=e.specification.parent;this.trackComment=document.createElement("div"),this.trackComment.className="comment-div",this.trackComment.id="comment-div-"+e.id,this.trackString=document.createElement("span"),this.trackString.innerHTML=t.commentBoxPrefix+" "+e.interfaceDOM.getPresentedId(),this.trackCommentBox=document.createElement("textarea"),this.trackCommentBox.rows="4",this.trackCommentBox.cols="100",this.trackCommentBox.name="trackComment"+e.id,this.trackCommentBox.className="trackComment";var i=document.createElement("br");this.trackComment.appendChild(this.trackString),this.trackComment.appendChild(i),this.trackComment.appendChild(this.trackCommentBox),this.exportXMLDOM=function(){var e=document.createElement("comment"),t=document.createElement("question");t.textContent=this.trackString.textContent;var i=document.createElement("response");return i.textContent=this.trackCommentBox.value,console.log("Comment frag-"+this.id+": "+i.textContent),e.appendChild(t),e.appendChild(i),e},this.resize=function(){var e=(window.innerWidth-100)/2;e>=600?e=600:e<400&&(e=400),this.trackComment.style.width=e+"px",this.trackCommentBox.style.width=e-6+"px"},this.resize(),this.highlight=function(e){!0===e?$(this.trackComment).addClass("comment-box-playing"):$(this.trackComment).removeClass("comment-box-playing")}},e.createCommentBox=function(e){var t=new this.elementCommentBox(e);return this.boxes.push(t),e.commentDOM=t,t},e.sortCommentBoxes=function(){this.boxes.sort(function(e,t){return e.id-t.id})},e.showCommentBoxes=function(e,t){this.injectPoint=e,t&&this.sortCommentBoxes(),this.boxes.forEach(function(t){e.appendChild(t.trackComment)})},e.deleteCommentBoxes=function(){null!==this.injectPoint&&(this.boxes.forEach(function(e){this.injectPoint.removeChild(e.trackComment)},this),this.injectPoint=null),this.boxes=[]},e.highlightById=function(e){(void 0===e||"number"!=typeof e||e>=this.boxes.length)&&(console.log("Error - Invalid id"),e=-1),this.boxes.forEach(function(t){t.id===e?t.highlight(!0):t.highlight(!1)})},e}(),this.commentQuestions=[],this.commentBox=function(e){this.specification=e,this.holder=document.createElement("div"),this.holder.className="comment-div",this.string=document.createElement("span"),this.string.innerHTML=e.statement,this.textArea=document.createElement("textarea"),this.textArea.rows="4",this.textArea.cols="100",this.textArea.className="trackComment";var t=document.createElement("br");this.holder.appendChild(this.string),this.holder.appendChild(t),this.holder.appendChild(this.textArea),this.exportXMLDOM=function(e){var t=e.parent.document.createElement("comment");t.id=this.specification.id,t.setAttribute("type",this.specification.type),console.log("Question: "+this.string.textContent),console.log("Response: "+t.textContent);var i=e.parent.document.createElement("question");i.textContent=this.string.textContent;var n=e.parent.document.createElement("response");return n.textContent=this.textArea.value,t.appendChild(i),t.appendChild(n),e.XMLDOM.appendChild(t),t},this.resize=function(){var e=(window.innerWidth-100)/2;e>=600?e=600:e<400&&(e=400),this.holder.style.width=e+"px",this.textArea.style.width=e-6+"px"},this.resize(),this.check=function(){return!this.specification.mandatory||0!==this.textArea.value.length}},this.radioBox=function(e){this.specification=e,this.holder=document.createElement("div"),this.holder.className="comment-div",this.string=document.createElement("span"),this.string.innerHTML=e.statement,this.holder.appendChild(this.string),this.options=[],this.inputs=document.createElement("div"),this.inputs.className="comment-checkbox-inputs-holder";for(var t=e.options.length,i=0;i=this.options.length););return o>=this.options.length?n.textContent="null":(n.textContent=this.options[o].getAttribute("setvalue"),n.setAttribute("number",o)),console.log("Comment: "+i.textContent),console.log("Response: "+n.textContent),t.appendChild(i),t.appendChild(n),e.XMLDOM.appendChild(t),t},this.resize=function(){var e=(window.innerWidth-100)/2;e>=600?e=600:e<400&&(e=400),this.holder.style.width=e+"px"},this.check=function(){var e=this.options.some(function(e){return e.checked});return!this.specification.mandatory||!1!==e},this.resize()},this.checkboxBox=function(e){this.specification=e,this.holder=document.createElement("div"),this.holder.className="comment-div",this.string=document.createElement("span"),this.string.innerHTML=e.statement,this.holder.appendChild(this.string),this.options=[],this.inputs=document.createElement("div"),this.inputs.className="comment-checkbox-inputs-holder";for(var t=e.options.length,i=0;i=600?e=600:e<400&&(e=400),this.holder.style.width=e+"px"},this.check=function(){var e=this.options.some(function(e){return e.checked});return!this.specification.mandatory||!1!==e},this.resize()},this.sliderBox=function(e){this.specification=e,this.holder=document.createElement("div"),this.holder.className="comment-div",this.string=document.createElement("span"),this.string.innerHTML=e.statement,this.slider=document.createElement("input"),this.slider.type="range",this.slider.min=e.min,this.slider.max=e.max,this.slider.step=e.step,this.slider.value=e.value;var t=document.createElement("br"),i=document.createElement("div");i.className="comment-slider-text-holder",this.leftText=document.createElement("span"),this.leftText.textContent=e.leftText,this.rightText=document.createElement("span"),this.rightText.textContent=e.rightText,i.appendChild(this.leftText),i.appendChild(this.rightText),this.holder.appendChild(this.string),this.holder.appendChild(t),this.holder.appendChild(this.slider),this.holder.appendChild(i),this.exportXMLDOM=function(e){var t=e.parent.document.createElement("comment");t.id=this.specification.id,t.setAttribute("type",this.specification.type),console.log("Question: "+this.string.textContent),console.log("Response: "+this.slider.value);var i=e.parent.document.createElement("question");i.textContent=this.string.textContent;var n=e.parent.document.createElement("response");return n.textContent=this.slider.value,t.appendChild(i),t.appendChild(n),e.XMLDOM.appendChild(t),t},this.resize=function(){var e=(window.innerWidth-100)/2;e>=600?e=600:e<400&&(e=400),this.holder.style.width=e+"px",this.slider.style.width=e-24+"px"},this.check=function(){return!0},this.resize()},this.createCommentQuestion=function(e){var t;return"question"==e.type?t=new this.commentBox(e):"radio"==e.type?t=new this.radioBox(e):"checkbox"==e.type?t=new this.checkboxBox(e):"slider"==e.type&&(t=new this.sliderBox(e)),this.commentQuestions.push(t),t},this.deleteCommentQuestions=function(){this.commentQuestions=[]},this.checkCommentQuestions=function(){if(0===this.commentQuestions.reduce(function(e,t){return!1===t.check()&&e.push(t),e},[]).length)return!0;interfaceContext.lightbox.post("Message","Not all the mandatory comment boxes below have been filled.")},this.outsideReferenceDOM=function(e,t,i){this.parent=e,this.outsideReferenceHolder=document.createElement("button"),this.outsideReferenceHolder.className="outside-reference",this.outsideReferenceHolder.setAttribute("track-id",t),this.outsideReferenceHolder.textContent=this.parent.specification.label||"Reference",this.outsideReferenceHolder.disabled=!0,this.handleEvent=function(e){audioEngineContext.play(this.parent.id)},this.outsideReferenceHolder.addEventListener("click",this),i.appendChild(this.outsideReferenceHolder),this.enable=function(){1==this.parent.state&&(this.outsideReferenceHolder.disabled=!1)},this.updateLoading=function(e){100!=e?(e=(e=String(e)).split(".")[0],this.outsideReferenceHolder.textContent=e+"%"):this.outsideReferenceHolder.textContent=this.parent.specification.label||"Reference"},this.startPlayback=function(){$(".track-slider").removeClass("track-slider-playing"),$(".comment-div").removeClass("comment-box-playing"),this.outsideReferenceHolder.style.backgroundColor="#FDD"},this.stopPlayback=function(){this.outsideReferenceHolder.style.backgroundColor=""},this.exportXMLDOM=function(e){return null},this.getValue=function(){return 0},this.getPresentedId=function(){return this.parent.specification.label||"Reference"},this.canMove=function(){return!1},this.error=function(){this.outsideReferenceHolder.textContent="Error",this.outsideReferenceHolder.style.backgroundColor="#F00"}},this.playhead=function(){var e={};e.object=document.createElement("div"),e.object.className="playhead",e.object.align="left";var t=document.createElement("div");return t.style.width="50px",e.curTimeSpan=document.createElement("span"),e.curTimeSpan.textContent="00:00",t.appendChild(e.curTimeSpan),e.object.appendChild(t),e.scrubberTrack=document.createElement("div"),e.scrubberTrack.className="playhead-scrub-track",e.scrubberHead=document.createElement("div"),e.scrubberHead.id="playhead-scrubber",e.scrubberTrack.appendChild(e.scrubberHead),e.object.appendChild(e.scrubberTrack),e.timePerPixel=0,e.maxTime=0,e.playbackObject=void 0,e.setTimePerPixel=function(e){this.playbackObject=e,this.maxTime=e.buffer.buffer.duration;this.timePerPixel=this.maxTime/490,this.maxTime<60?this.curTimeSpan.textContent="0.00":this.curTimeSpan.textContent="00:00"},e.update=function(){if(this.timePerPixel>0){var e=this.playbackObject.getCurrentPosition();if(e>0&&e60){var i=e%60,n=Math.floor((e-i)/60);i=(i=i.toString()).substr(0,2),n=n.toString(),this.curTimeSpan.textContent=n+":"+i}else e=e.toString(),this.curTimeSpan.textContent=e.substr(0,4)}else this.scrubberHead.style.left="0px",this.maxTime<60?this.curTimeSpan.textContent="0.00":this.curTimeSpan.textContent="00:00"}void 0!==this.playbackObject&&void 0===this.interval&&window.requestAnimationFrame(this.update.bind(this))},e.interval=void 0,e.start=function(){void 0!==this.playbackObject&&void 0===this.interval&&window.requestAnimationFrame(this.update.bind(this))},e.stop=function(){this.timePerPixel=0},e}(),this.volume=function(){var e={};e.valueLin=1,e.valueDB=0,e.root=document.createElement("div"),e.root.id="master-volume-root",e.object=document.createElement("div"),e.object.className="master-volume-holder-float",e.object.appendChild(e.root),e.slider=document.createElement("input"),e.slider.id="master-volume-control",e.slider.type="range",e.valueText=document.createElement("span"),e.valueText.id="master-volume-feedback",e.valueText.textContent="0dB",e.slider.min=-60,e.slider.max=12,e.slider.value=0,e.slider.step=1,e.handleEvent=function(e){"mousemove"!=e.type&&"mouseup"!=e.type||(this.valueDB=Number(this.slider.value),this.valueLin=decibelToLinear(this.valueDB),this.valueText.textContent=this.valueDB+"dB",audioEngineContext.outputGain.gain.value=this.valueLin),"mouseup"==e.type&&this.onmouseup(),this.slider.value=this.valueDB,e.stopPropagation&&e.stopPropagation()},e.onmouseup=function(){var e=testState.currentStore.XMLDOM.getElementsByTagName("metric")[0].getAllElementsByName("volumeTracker");0===e.length?((e=storage.document.createElement("metricresult")).setAttribute("name","volumeTracker"),testState.currentStore.XMLDOM.getElementsByTagName("metric")[0].appendChild(e)):e=e[0];var t=storage.document.createElement("movement");t.setAttribute("test-time",audioEngineContext.timer.getTestTime()),t.setAttribute("volume",this.valueDB),t.setAttribute("format","dBFS"),e.appendChild(t)},e.slider.addEventListener("mousemove",e),e.root.addEventListener("mouseup",e);var t=document.createElement("div");return t.innerHTML="Master Volume Control",t.style.fontSize="0.75em",t.style.width="100%",t.align="center",e.root.appendChild(t),e.root.appendChild(e.slider),e.root.appendChild(e.valueText),e.resize=function(e){window.innerWidth<1e3?this.object.className="master-volume-holder-inline":this.object.className="master-volume-holder-float"},e}(),this.imageHolder=function(){var e={};return e.root=document.createElement("div"),e.root.id="imageController",e.img=document.createElement("img"),e.root.appendChild(e.img),e.setImage=function(t){e.img.src="","string"==typeof t&&void 0!==t.length&&(e.img.src=t)},e}(),this.calibrationModuleObject=null,this.calibrationModule=function(){this.storeDOM=storage.document.createElement("calibration"),storage.root.appendChild(this.storeDOM),this.calibrationNodes=[],this.holder=null,this.build=function(e){var t=62.5;for(this.holder=document.createElement("div"),this.holder.className="calibration-holder",this.calibrationNodes=[];t<2e4;){var i={root:document.createElement("div"),input:document.createElement("input"),oscillator:audioContext.createOscillator(),gain:audioContext.createGain(),f:t,parent:this,handleEvent:function(e){switch(e.type){case"mouseenter":this.oscillator.start(0);break;case"mouseleave":this.oscillator.stop(0),this.oscillator=audioContext.createOscillator(),this.oscillator.connect(this.gain),this.oscillator.frequency.value=this.f;break;case"mousemove":var t=Math.pow(10,this.input.value/20);1e3==this.f?(audioEngineContext.outputGain.gain.value=t,interfaceContext.volume.slider.value=this.input.value):this.gain.gain.value=t}},disconnect:function(){this.gain.disconnect()}};i.root.className="calibration-slider",i.root.appendChild(i.input),i.oscillator.connect(i.gain),i.gain.connect(audioEngineContext.outputGain),i.gain.gain.value=2*Math.random(),i.input.value=i.gain.gain.value,i.input.setAttribute("orient","vertical"),i.input.type="range",i.input.min=-12,i.input.max=0,i.input.step=.25,1e3!=t?i.input.value=12*Math.random()-6:(i.input.value=0,i.root.style.backgroundColor="rgb(255,125,125)"),i.input.addEventListener("mousemove",i),i.input.addEventListener("mouseenter",i),i.input.addEventListener("mouseleave",i),i.gain.gain.value=Math.pow(10,i.input.value/20),i.oscillator.frequency.value=t,this.calibrationNodes.push(i),this.holder.appendChild(i.root),t*=2}e.appendChild(this.holder)},this.collect=function(){this.calibrationNodes.forEach(function(e){var t=storage.document.createElement("calibrationresult");t.setAttribute("frequency",e.f),t.setAttribute("range-min",e.input.min),t.setAttribute("range-max",e.input.max),t.setAttribute("gain-lin",e.gain.gain.value),this.storeDOM.appendChild(t)},this)}},this.checkHiddenAnchor=function(e){return!audioEngineContext.audioObjects.filter(function(e){return"anchor"===e.specification.type}).some(function(e){return e.interfaceDOM.getValue()>e.specification.marker/100&&e.specification.marker>0})||(console.log("Anchor node not below marker value"),e?interfaceContext.lightbox.post("Message",e):interfaceContext.lightbox.post("Message","Please keep listening"),this.storeErrorNode("Anchor node not below marker value"),!1)},this.checkHiddenReference=function(e){return!audioEngineContext.audioObjects.filter(function(e){return"reference"===e.specification.type}).some(function(e){return e.interfaceDOM.getValue()0})||(console.log("Reference node not below marker value"),e?interfaceContext.lightbox.post("Message",e):interfaceContext.lightbox.post("Message","Please keep listening"),this.storeErrorNode("Reference node not below marker value"),!1)},this.checkFragmentsFullyPlayed=function(e){if(audioEngineContext.loopPlayback)return console.log("WARNING - Looped source: Cannot check fragments are fully played"),!0;var t,i=!0,n=[];for(t=0;t=s){a=!0;break}}!1===a&&(i=!1,console.log("Continue listening to track-"+o.interfaceDOM.getPresentedId()),n.push(o.interfaceDOM.getPresentedId()))}if(!1===i){var h="You have not completely listened to fragments ";for(t=0;to.min?(n+="At least one fragment must be below the "+o.min+" mark.",i=!1):s.max=t)});if(0===e.length)return!0;var t=[];e.forEach(function(e){t.push(e.interfaceDOM.getPresentedId())});var i="You have not played fragments "+t.join(", ")+" enough. Please keep listening";return interfaceContext.lightbox.post("Message",i),this.storeErrorNode(i),!1},this.sortFragmentsByScore=function(){for(var e=audioEngineContext.audioObjects.filter(function(e){return"outside-reference"!==e.specification.type}),t=[],i=0;t.push(i++)o?1:n122)&&(i=97),i-=97;break;case"capital":((i=i.charCodeAt(0))<65||i>90)&&(i=65),i-=65;break;case"number":i=Number(i),isFinite(i)||(i=1);break;default:i=0}if("number"==typeof t)return n(e,t,i);if(t.length&&t.length>0){var o,s=[],r=t.length;for(o=0;o=300)console.log("WARNING - Could not update at this time");else{var e=(new DOMParser).parseFromString(r.responseText,"application/xml").getElementsByTagName("response")[0];if("OK"==e.getAttribute("state")){var t=e.getElementsByTagName("file")[0];console.log("Intermediate save: OK, written "+t.getAttribute("bytes")+"B"),n(!0)}else{var i=e.getElementsByTagName("message");console.log("Intermediate save: Error! "+i.textContent),s("Intermediate save: Error! "+i.textContent)}}},r.onerror=function(){s(Error("Network Error"))},r.send([t.innerHTML])})}var i="";void 0!==window.returnURL&&(i=String(window.returnURL));var n=null,o=null,s={};return Object.defineProperties(s,{key:{get:function(){return o},set:function(e){throw"Cannot set read-only property"}},request:{value:new XMLHttpRequest},parent:{value:e},requestKey:{value:function(){n=new Promise(function(t,n){var o=new XMLHttpRequest;o.open("GET",i+"php/requestKey.php?saveFilenamePrefix="+e.filenamePrefix,!0),o.onload=function(){200==o.status?t(o.response):n(Error(o.statusText))},o.onerror=function(){n(Error("Network Error"))},o.send()}).then(function(t){function i(){throw o=null,"An unspecified error occured, no server key could be generated"}var n=(new DOMParser).parseFromString(t,"text/xml");if(0===t.length&&i(),n.getElementsByTagName("state").length>0){if("OK"==n.getElementsByTagName("state")[0].textContent)return o=n.getAllElementsByTagName("key")[0].textContent,e.root.setAttribute("key",o),e.root.setAttribute("state","empty"),!0;if("ERROR"==n.getElementsByTagName("state")[0].textContent)return o=null,console.error('Could not generate server key. Server responded with error message: "'+n.getElementsByTagName("message")[0].textContent+'"'),!1}else i();return!0})}},update:{value:function(){if(null===this.key||void 0===n)throw"Cannot save as key == null";this.parent.root.setAttribute("state","update"),n=n.then(t)}},finish:{value:function(){if(null===this.key||void 0===n)throw"Cannot save as key == null";return this.parent.finish(),n.then(t()).then(function(){console.log("OK")},function(){createProjectSave("local")})}}}),s}(this),this.createTestPageStore=function(e){var t=new this.pageNode(this,e);return this.testPages.push(t),this.testPages[this.testPages.length-1]},this.surveyNode=function(e,t,i){this.specification=i,this.parent=e,this.state="empty",this.XMLDOM=this.parent.document.createElement("survey"),this.XMLDOM.setAttribute("location",this.specification.location),this.XMLDOM.setAttribute("state",this.state),this.specification.options.forEach(function(e){if("statement"!=e.type){var t=this.parent.document.createElement("surveyresult");t.setAttribute("ref",e.id),t.setAttribute("type",e.type),this.XMLDOM.appendChild(t)}},this),t.appendChild(this.XMLDOM),this.postResult=function(e){function t(e,t){var i=e.createElement("response");return i.setAttribute("name",t.name),i.setAttribute("checked",t.checked),i}if("statement"!=e.specification.type){for(var i=this.XMLDOM.firstChild;null!==i&&i.getAttribute("ref")!=e.specification.id;)i=i.nextElementSibling;switch(i.setAttribute("duration",e.elapsedTime),e.specification.type){case"number":case"question":case"slider":i.appendChild(function(e,t){var i=e.createElement("response");return i.textContent=t,i}(this.parent.document,e.response));break;case"radio":i.appendChild(function(e,t){var i=e.createElement("response");return null!==t.response&&(i.setAttribute("name",t.response.name),i.textContent=t.response.text),i}(this.parent.document,e));break;case"checkbox":if(void 0===e.response){i.appendChild(this.parent.document.createElement("response"));break}for(var n=0;n0&&t.setAttribute("marker",e.marker);var i=this.parent.document.createElement("metric");t.appendChild(i),this.XMLDOM.appendChild(t)},this),this.parent.root.appendChild(this.XMLDOM),this.complete=function(){this.state="complete",this.XMLDOM.setAttribute("state","complete")}},this.update=function(){this.SessionKey.update()},this.finish=function(){return this.state=1,this.root.setAttribute("state","complete"),this.root},Object.defineProperties(this,{filenamePrefix:{get:function(){return e},set:function(t){return"string"!=typeof t&&(t=String(t)),e=t,t}}})}var audioContext,projectXML,schemaXSD,specification,interfaceContext,storage,popup,testState,audioEngineContext,gReturnURL,gSaveFilenamePrefix,currentTrackOrder=[];AudioBufferSourceNode.prototype.owner=void 0,AudioBufferSourceNode.prototype.playbackStartTime=void 0,AudioBuffer.prototype.playbackGain=void 0,AudioBuffer.prototype.lufs=void 0,XMLDocument.prototype.getAllElementsByName=function(e){e=String(e);return this.documentElement.getAllElementsByName(e)},Element.prototype.getAllElementsByName=function(e){e=String(e);for(var t=[],i=this.firstElementChild;null!==i;)i.getAttribute("name")==e&&t.push(i),i.childElementCount>0&&(t=t.concat(i.getAllElementsByName(e))),i=i.nextElementSibling;return t},XMLDocument.prototype.getAllElementsByTagName=function(e){e=String(e);return this.documentElement.getAllElementsByTagName(e)},Element.prototype.getAllElementsByTagName=function(e){e=String(e);for(var t=[],i=this.firstElementChild;null!==i;)i.nodeName==e&&t.push(i),i.childElementCount>0&&(t=t.concat(i.getAllElementsByTagName(e))),i=i.nextElementSibling;return t},"function"!=typeof XMLDocument.prototype.getElementsByName&&(XMLDocument.prototype.getElementsByName=function(e){e=String(e);for(var t=this.documentElement.firstElementChild,i=[];null!==t;)t.getAttribute("name")==e&&i.push(t),t=t.nextElementSibling;return i});var window_depedancy_callback,check_dependancies=function(){return"function"==typeof jQuery&&("function"==typeof Specification&&("function"==typeof calculateLoudness&&("function"==typeof WAVE&&"function"==typeof validateXML)))},onload=function(){var e=window.AudioContext||window.webkitAudioContext;if(audioContext=new e,testState=new stateMachine,popup=new interfacePopup,specification=new Specification,interfaceContext=new Interface(specification),storage=new Storage,window.onresize=function(e){interfaceContext.resizeWindow(e)},0!==window.location.search.length){var t,i=window.location.search.split("?")[1].split("&");for(var n in i){i[n]=i[n].split("=");var o=i[n][0],s=decodeURIComponent(i[n][1]);switch(o){case"url":t=s,specification.url=t;break;case"returnURL":gReturnURL=s;break;case"saveFilenamePrefix":storage.filenamePrefix=s}}loadProjectSpec(t),window.onbeforeunload=function(){return"Please only leave this page once you have completed the tests. Are you sure you have completed all testing?"}}interfaceContext.lightbox.resize()};window_depedancy_callback=window.setInterval(function(){check_dependancies()?(window.clearInterval(window_depedancy_callback),onload()):document.getElementById("topLevelBody").innerHTML="

Loading Resources

"},100);