Mercurial > hg > webaudioevaluationtool
diff core.js @ 207:32e16bf9303a
Keep track of randomisation in console log; multipage example XML.
author | Brecht De Man <b.deman@qmul.ac.uk> |
---|---|
date | Mon, 15 Jun 2015 16:54:39 +0100 |
parents | 30b9d9538cb7 |
children | 538322113524 |
line wrap: on
line diff
--- a/core.js Mon Jun 15 13:09:46 2015 +0100 +++ b/core.js Mon Jun 15 16:54:39 2015 +0100 @@ -1069,8 +1069,14 @@ { // This takes an array of information and randomises the order var N = input.length; - var K = N; + + var inputSequence = []; // For safety purposes: keep track of randomisation + for (var counter = 0; counter < N; ++counter) + inputSequence.push(counter) // Fill array + var inputSequenceClone = inputSequence.slice(0); + var holdArr = []; + var outputSequence = []; for (var n=0; n<N; n++) { // First pick a random number @@ -1079,7 +1085,11 @@ r = Math.floor(r*input.length); // Pick out that element and delete from the array holdArr.push(input.splice(r,1)[0]); + // Do the same with sequence + outputSequence.push(inputSequence.splice(r,1)[0]); } + console.log(inputSequenceClone.toString()); // print original array to console + console.log(outputSequence.toString()); // print randomised array to console return holdArr; }