Mercurial > hg > webaudioevaluationtool
diff js/core.js @ 2310:426995e02e79
Fix for #43. Added scale range check enforcement
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Fri, 29 Apr 2016 11:40:06 +0100 |
parents | e4a2a39838db |
children | 483bd6573747 |
line wrap: on
line diff
--- a/js/core.js Thu Apr 28 16:52:36 2016 +0100 +++ b/js/core.js Fri Apr 29 11:40:06 2016 +0100 @@ -1095,6 +1095,14 @@ pageXMLSave(storePoint.XMLDOM, this.currentStateMap); storePoint.complete(); }; + + this.getCurrentTestPage = function() { + if (this.stateIndex >= 0 && this.stateIndex< this.stateMap.length) { + return this.currentStateMap; + } else { + return null; + } + } } function AudioEngine(specification) { @@ -2783,6 +2791,33 @@ this.storeErrorNode(str); return false; }; + this.checkScaleRange = function(min, max) { + var page = testState.getCurrentTestPage(); + var audioObjects = audioEngineContext.audioObjects; + var state = true; + var str = "Please keep listening. "; + var minRanking = Infinity; + var maxRanking = -Infinity; + for (var ao of audioObjects) { + var rank = ao.interfaceDOM.getValue(); + if (rank < minRanking) {minRanking = rank;} + if (rank > maxRanking) {maxRanking = rank;} + } + if (minRanking*100 > min) { + str += "At least one fragment must be below the "+min+" mark."; + state = false; + } + if (maxRanking*100 < max) { + str += "At least one fragment must be above the "+max+" mark." + state = false; + } + if (!state) { + console.log(str); + this.storeErrorNode(str); + alert(str); + } + return state; + } this.storeErrorNode = function(errorMessage) {