diff options
Diffstat (limited to 'app/js/controllers.js')
-rw-r--r-- | app/js/controllers.js | 70 |
1 files changed, 24 insertions, 46 deletions
diff --git a/app/js/controllers.js b/app/js/controllers.js index 97b52ad..f49f1b1 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1,66 +1,44 @@ 'use strict'; /* Controllers */ -var p = new Point(1,2); +var p = new Point(1, 2); -app.controller('pointCtrl', function($scope, $http, pathService){ +app.controller('pointCtrl', function($scope, $http, pathService, musicPlayer) { - $scope.points=dummyPoints; - $scope.line = []; + $scope.points = dummyPoints; + $scope.line = []; - var update = function(newPoints, newLine) { - if(newLine.length > 0) { - $scope.playseq=pathService.computePlaylist(newPoints, newLine, 60); - startSongWithDuration($scope.playseq[0].id, $scope.playseq[0].duration); - } - } + var update = function(newPoints, newLine) { + if (newLine.length > 0) { + $scope.playseq = pathService.computePlaylist(newPoints, newLine, 60); + musicPlayer.startSongWithDuration($scope.playseq[0].id, $scope.playseq[0].duration); + } + }; - $scope.$watch('points', function(newVal, oldVal) { - console.log("r") - update(newVal, $scope.line); + $scope.$watch('points', function(newVal) { + update(newVal, $scope.line); }, true); $scope.$watch('line', function(newVal) { - update($scope.points, newVal); + update($scope.points, newVal); }, true); - -// $scope.line=constList; - - $scope.addNewSongToGraph = function(id, titre, link, duration) - { - var newSong = { - x:100, - y:100, - label:titre, - id:id, - link:link, - duration:duration - }; - $scope.points.push(newSong); - console.log(newSong); - $scope.$apply(); - }; - - $scope.getColor = function(point) { - if (playlist.indexOf(point) == -1) { - return "white" - } else { - return "red" - } - } +// $scope.line=constList; - $scope.foo = function (event) { - console.log("foobar"); + $scope.addNewSongToGraph = function(newSong) + { + newSong.x = 100; + newSong.y = 100; + $scope.points.push(newSong); + }; +}); - $scope.points.push({ - x: 250, - y: 250 - }); - }; +app.controller('searchCtrl', function($scope) { + $scope.points = dummyPoints; + $scope.line = []; });
\ No newline at end of file |