diff options
author | Jakob Odersky <jodersky@gmail.com> | 2014-05-11 10:00:23 +0200 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2014-05-11 10:00:23 +0200 |
commit | b687f35b9b760b70cb3c9fe16b092bd33888a3b9 (patch) | |
tree | 879fad430466133da9763e5cc5469470797e034c | |
parent | c5a3c232eb89bf14748a105809184d02c949e762 (diff) | |
parent | d4d6500ff3dd707c5bce7b162813efc273b1c3f4 (diff) | |
download | playGraph-b687f35b9b760b70cb3c9fe16b092bd33888a3b9.tar.gz playGraph-b687f35b9b760b70cb3c9fe16b092bd33888a3b9.tar.bz2 playGraph-b687f35b9b760b70cb3c9fe16b092bd33888a3b9.zip |
Merge branch 'master' of github.com:jodersky/playGraph into html
-rw-r--r-- | app/js/services.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/js/services.js b/app/js/services.js index a7f4eda..622717a 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -31,11 +31,14 @@ app.service('pathService', function() { //select the songs var selection = []; var tuning = .5; - songListCopy.sort(function(song){ - return (tuning + tuning*Math.random())*song.minDist;} - ); + angular.forEach(songListCopy, function(song){ + song.rand = (tuning + tuning*Math.random())*song.minDist; + }); + songListCopy.sort(function(a,b){return a.rand-b.rand;}); + //take from the sorted list util we reach the desired duration while(duration > 0 && songListCopy.length > 0){ var removed = songListCopy.splice(0, 1); + console.log(removed[0].minDist); selection.push(removed[0]); duration -= 10; } |