Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 2909:e2b241c88b74
ITU-R BS.1116 compliant template
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Tue, 01 Aug 2017 10:09:26 +0100 |
parents | 033027759cf7 |
children | fc41c3d909b7 |
comparison
equal
deleted
inserted
replaced
2908:9c26e579e64d | 2909:e2b241c88b74 |
---|---|
1214 this.currentStateMap = null; | 1214 this.currentStateMap = null; |
1215 this.currentStatePosition = null; | 1215 this.currentStatePosition = null; |
1216 this.currentStore = null; | 1216 this.currentStore = null; |
1217 this.initialise = function () { | 1217 this.initialise = function () { |
1218 | 1218 |
1219 function randomiseElements(page) { | |
1220 // Get the elements which are fixed / labelled | |
1221 var fixed = [], | |
1222 or = [], | |
1223 remainder = []; | |
1224 page.audioElements.forEach(function (a) { | |
1225 if (a.label.length > 0 || a.postion !== undefined) { | |
1226 fixed.push(a); | |
1227 } else if (a.type === "outside-reference") { | |
1228 or.push(a); | |
1229 } else { | |
1230 remainder.push(a); | |
1231 } | |
1232 }) | |
1233 if (page.poolSize > 0 || page.randomiseOrder) { | |
1234 page.randomiseOrder = true; | |
1235 if (page.poolSize === 0) { | |
1236 page.poolSize = page.audioElements.length; | |
1237 } | |
1238 page.poolSize -= fixed.length; | |
1239 remainder = pickSubPool(remainder, page.poolSize); | |
1240 } | |
1241 // Randomise the remainders | |
1242 if (page.randomiseOrder) { | |
1243 remainder = randomiseOrder(remainder); | |
1244 } | |
1245 fixed = fixed.concat(remainder); | |
1246 page.audioElements = fixed.concat(or); | |
1247 page.audioElements.forEach(function (a, i) { | |
1248 a.position = i; | |
1249 }); | |
1250 } | |
1251 | |
1219 // Get the data from Specification | 1252 // Get the data from Specification |
1220 var pagePool = []; | 1253 var pagePool = []; |
1221 specification.pages.forEach(function (page) { | 1254 specification.pages.forEach(function (page) { |
1222 if (page.position !== null || page.alwaysInclude) { | 1255 if (page.position !== null || page.alwaysInclude) { |
1223 page.alwaysInclude = true; | 1256 page.alwaysInclude = true; |
1251 // Now process the pages | 1284 // Now process the pages |
1252 pagePool.forEach(function (page, i) { | 1285 pagePool.forEach(function (page, i) { |
1253 page.presentedId = i; | 1286 page.presentedId = i; |
1254 this.stateMap.push(page); | 1287 this.stateMap.push(page); |
1255 var elements = page.audioElements; | 1288 var elements = page.audioElements; |
1256 if (page.poolSize > 0 || page.randomiseOrder) { | 1289 randomiseElements(page); |
1257 page.randomiseOrder = true; | |
1258 if (page.poolSize === 0) { | |
1259 page.poolSize = elements.length; | |
1260 } | |
1261 elements = pickSubPool(elements, page.poolSize); | |
1262 } | |
1263 if (page.randomiseOrder) { | |
1264 elements = randomiseOrder(elements); | |
1265 } | |
1266 page.audioElements = elements; | |
1267 storage.createTestPageStore(page); | 1290 storage.createTestPageStore(page); |
1268 audioEngineContext.loadPageData(page); | 1291 audioEngineContext.loadPageData(page); |
1269 }, this); | 1292 }, this); |
1270 | 1293 |
1271 if (specification.preTest !== null) { | 1294 if (specification.preTest !== null) { |
1323 createProjectSave(specification.projectReturn); | 1346 createProjectSave(specification.projectReturn); |
1324 } else { | 1347 } else { |
1325 popup.hidePopup(); | 1348 popup.hidePopup(); |
1326 if (this.currentStateMap === null) { | 1349 if (this.currentStateMap === null) { |
1327 this.currentStateMap = this.stateMap[this.stateIndex]; | 1350 this.currentStateMap = this.stateMap[this.stateIndex]; |
1328 // Find and extract the outside reference | |
1329 var elements = [], | |
1330 ref = []; | |
1331 var elem = this.currentStateMap.audioElements.pop(); | |
1332 while (elem) { | |
1333 if (elem.type == "outside-reference") { | |
1334 ref.push(elem); | |
1335 } else { | |
1336 elements.push(elem); | |
1337 } | |
1338 elem = this.currentStateMap.audioElements.pop(); | |
1339 } | |
1340 elements = elements.reverse(); | |
1341 if (this.currentStateMap.randomiseOrder) { | |
1342 elements = randomiseOrder(elements); | |
1343 } | |
1344 this.currentStateMap.audioElements = elements.concat(ref); | |
1345 | 1351 |
1346 this.currentStore = storage.testPages[this.stateIndex]; | 1352 this.currentStore = storage.testPages[this.stateIndex]; |
1347 if (this.currentStateMap.preTest !== undefined) { | 1353 if (this.currentStateMap.preTest !== undefined) { |
1348 this.currentStatePosition = 'pre'; | 1354 this.currentStatePosition = 'pre'; |
1349 popup.initState(this.currentStateMap.preTest, storage.testPages[this.stateIndex].preTest); | 1355 popup.initState(this.currentStateMap.preTest, storage.testPages[this.stateIndex].preTest); |