From 9e579f32a7818f78f568089638fdcf8a06f579e6 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Sun, 11 May 2014 10:36:07 +0200 Subject: working canvas --- app/css/app.css | 4 ++++ app/index.html | 4 ++-- app/js/controllers.js | 2 +- app/js/services.js | 14 ++++++++++++-- 4 files changed, 19 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/css/app.css b/app/css/app.css index 960eac4..5f3e698 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -27,4 +27,8 @@ margin-top: -15px; width: 30px; height: 30px; +} + +.selected > div { + background-color: red; } \ No newline at end of file diff --git a/app/index.html b/app/index.html index 537996f..843df21 100644 --- a/app/index.html +++ b/app/index.html @@ -17,11 +17,11 @@
-
+
diff --git a/app/js/controllers.js b/app/js/controllers.js index 29e7c0d..97e6366 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -16,7 +16,7 @@ app.controller('pointCtrl', function($scope, $http, pathService){ } } - $scope.$watch('points', function(newVal) { + $scope.$watch('points', function(newVal, oldVal) { console.log("r") update(newVal, $scope.line); }, true); diff --git a/app/js/services.js b/app/js/services.js index 622717a..37cb523 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -11,9 +11,11 @@ app.service('pathService', function() { }, computePlaylist: function(songList, constrainList, duration) { //compute distances from the constrain path + var songListCopy = songList.slice(0); var maxDistOverall = Number.MIN_VALUE; angular.forEach(songListCopy, function(song){ + song.selected = false; song.minDist = Number.MAX_VALUE; for(var i=0; i 0 && songListCopy.length > 0){ var removed = songListCopy.splice(0, 1); - console.log(removed[0].minDist); selection.push(removed[0]); duration -= 10; + removed[0].selected = true; } selection.sort(function(item){ return item.closestIndex;}); + + //clean points + angular.forEach(songList, function(song) { + delete song.minDist; + delete song.closest; + delete song.closestIndex; + delete song.rand; + }); return selection; } }; -- cgit v1.2.3