Mercurial > hg > webaudioevaluationtool
comparison core.js @ 265:ec693ceb2444 Dev_main
Update dev_main
author | Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk> |
---|---|
date | Wed, 22 Jul 2015 12:41:22 +0100 |
parents | 2e19ac736876 |
children | 23f4f4c0a13a |
comparison
equal
deleted
inserted
replaced
243:b4ca52c105ba | 265:ec693ceb2444 |
---|---|
392 if(this.stateIndex != null) { | 392 if(this.stateIndex != null) { |
393 console.log('NOTE - State already initialise'); | 393 console.log('NOTE - State already initialise'); |
394 } | 394 } |
395 this.stateIndex = -1; | 395 this.stateIndex = -1; |
396 var that = this; | 396 var that = this; |
397 var aH_pId = 0; | |
397 for (var id=0; id<this.stateMap.length; id++){ | 398 for (var id=0; id<this.stateMap.length; id++){ |
398 var name = this.stateMap[id].type; | 399 var name = this.stateMap[id].type; |
399 var obj = document.createElement(name); | 400 var obj = document.createElement(name); |
400 if (name == 'audioHolder') { | 401 if (name == 'audioHolder') { |
401 obj.id = this.stateMap[id].id; | 402 obj.id = this.stateMap[id].id; |
403 obj.setAttribute('presentedid',aH_pId); | |
404 aH_pId+=1; | |
402 } | 405 } |
403 this.stateResults.push(obj); | 406 this.stateResults.push(obj); |
404 } | 407 } |
405 } else { | 408 } else { |
406 conolse.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP'); | 409 console.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP'); |
407 } | 410 } |
408 }; | 411 }; |
409 this.advanceState = function(){ | 412 this.advanceState = function(){ |
410 if (this.stateIndex == null) { | 413 if (this.stateIndex == null) { |
411 this.initialise(); | 414 this.initialise(); |
632 }; | 635 }; |
633 xmlhttp.send(file); | 636 xmlhttp.send(file); |
634 } | 637 } |
635 } | 638 } |
636 | 639 |
640 function errorSessionDump(msg){ | |
641 // Create the partial interface XML save | |
642 // Include error node with message on why the dump occured | |
643 var xmlDoc = interfaceXMLSave(); | |
644 var err = document.createElement('error'); | |
645 err.textContent = msg; | |
646 xmlDoc.appendChild(err); | |
647 var parent = document.createElement("div"); | |
648 parent.appendChild(xmlDoc); | |
649 var file = [parent.innerHTML]; | |
650 var bb = new Blob(file,{type : 'application/xml'}); | |
651 var dnlk = window.URL.createObjectURL(bb); | |
652 var a = document.createElement("a"); | |
653 a.hidden = ''; | |
654 a.href = dnlk; | |
655 a.download = "save.xml"; | |
656 a.textContent = "Save File"; | |
657 | |
658 popup.showPopup(); | |
659 popup.popupContent.innerHTML = "ERROR : "+msg; | |
660 popup.popupContent.appendChild(a); | |
661 } | |
662 | |
637 // Only other global function which must be defined in the interface class. Determines how to create the XML document. | 663 // Only other global function which must be defined in the interface class. Determines how to create the XML document. |
638 function interfaceXMLSave(){ | 664 function interfaceXMLSave(){ |
639 // Create the XML string to be exported with results | 665 // Create the XML string to be exported with results |
640 var xmlDoc = document.createElement("BrowserEvaluationResult"); | 666 var xmlDoc = document.createElement("BrowserEvaluationResult"); |
641 var projectDocument = specification.projectXML; | 667 var projectDocument = specification.projectXML; |
883 // Should only be called if there was an error, but sometimes gets called continuously | 909 // Should only be called if there was an error, but sometimes gets called continuously |
884 // Check here if the error is genuine | 910 // Check here if the error is genuine |
885 if (audioObj.state == 0 || audioObj.buffer == undefined) { | 911 if (audioObj.state == 0 || audioObj.buffer == undefined) { |
886 // Genuine error | 912 // Genuine error |
887 console.log('FATAL - Error loading buffer on '+audioObj.id); | 913 console.log('FATAL - Error loading buffer on '+audioObj.id); |
914 if (request.status == 404) | |
915 { | |
916 console.log('FATAL - Fragment '+audioObj.id+' 404 error'); | |
917 console.log('URL: '+audioObj.url); | |
918 errorSessionDump('Fragment '+audioObj.id+' 404 error'); | |
919 } | |
888 } | 920 } |
889 }); | 921 }); |
890 }; | 922 }; |
891 request.send(); | 923 request.send(); |
892 }; | 924 }; |
1254 } | 1286 } |
1255 | 1287 |
1256 this.commonInterface = new function() { | 1288 this.commonInterface = new function() { |
1257 this.OptionNode = function(child) { | 1289 this.OptionNode = function(child) { |
1258 this.type = child.nodeName; | 1290 this.type = child.nodeName; |
1259 if (this.type == 'check') { | 1291 if (this.type == 'option') |
1292 { | |
1293 this.name = child.getAttribute('name'); | |
1294 } | |
1295 else if (this.type == 'check') { | |
1260 this.check = child.getAttribute('name'); | 1296 this.check = child.getAttribute('name'); |
1261 if (this.check == 'scalerange') { | 1297 if (this.check == 'scalerange') { |
1262 this.min = child.getAttribute('min'); | 1298 this.min = child.getAttribute('min'); |
1263 this.max = child.getAttribute('max'); | 1299 this.max = child.getAttribute('max'); |
1264 if (this.min == null) {this.min = 1;} | 1300 if (this.min == null) {this.min = 1;} |
1620 if (this.audioObject.specification.parent.elementComments) { | 1656 if (this.audioObject.specification.parent.elementComments) { |
1621 var question = document.createElement('question'); | 1657 var question = document.createElement('question'); |
1622 question.textContent = this.trackString.textContent; | 1658 question.textContent = this.trackString.textContent; |
1623 var response = document.createElement('response'); | 1659 var response = document.createElement('response'); |
1624 response.textContent = this.trackCommentBox.value; | 1660 response.textContent = this.trackCommentBox.value; |
1661 console.log("Comment frag-"+this.id+": "+response.textContent); | |
1625 root.appendChild(question); | 1662 root.appendChild(question); |
1626 root.appendChild(response); | 1663 root.appendChild(response); |
1627 } | 1664 } |
1628 return root; | 1665 return root; |
1629 }; | 1666 }; |
1653 this.exportXMLDOM = function() { | 1690 this.exportXMLDOM = function() { |
1654 var root = document.createElement('comment'); | 1691 var root = document.createElement('comment'); |
1655 root.id = this.specification.id; | 1692 root.id = this.specification.id; |
1656 root.setAttribute('type',this.specification.type); | 1693 root.setAttribute('type',this.specification.type); |
1657 root.textContent = this.textArea.value; | 1694 root.textContent = this.textArea.value; |
1695 console.log("Question: "+this.string.textContent); | |
1696 console.log("Response: "+root.textContent); | |
1658 return root; | 1697 return root; |
1659 }; | 1698 }; |
1660 }; | 1699 }; |
1661 | 1700 |
1662 this.radioBox = function(commentQuestion) { | 1701 this.radioBox = function(commentQuestion) { |
1968 } | 2007 } |
1969 } | 2008 } |
1970 return true; | 2009 return true; |
1971 }; | 2010 }; |
1972 } | 2011 } |
1973 |