From a13c1491e674bbefd565d603865b4af81804e77a Mon Sep 17 00:00:00 2001 From: Philippe Vienne Date: Sun, 17 Apr 2016 19:37:16 +0200 Subject: [PATCH 01/15] Add Angular.js --- public/index.html | 3 ++- public/script.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 7b02799..8dbebb7 100644 --- a/public/index.html +++ b/public/index.html @@ -1,5 +1,5 @@ - + Spotify Duplicate Finder @@ -71,6 +71,7 @@ + + ') } else { - res.redirect('/#' + - querystring.stringify({ - error: 'invalid_token' - })); + res.send('') } }); } diff --git a/public/script.js b/public/script.js index c8e3f9a..b4662bc 100644 --- a/public/script.js +++ b/public/script.js @@ -58,11 +58,24 @@ }]); - app.controller('AuthCtrl',['$scope', '$rootScope', function($scope, $rootScope){ + app.controller('AuthCtrl',['$scope', '$rootScope', '$interval', function($scope, $rootScope, $interval){ $scope.login = function(){ var openUrl = '/login'; window.$windowScope = $scope; - window.open(openUrl, "Authenticate Account", "width=500, height=500"); + $scope.popup = window.open(openUrl, "Authenticate Account", "width=500, height=500"); + var checker = $interval(function(){ + if($scope.popup.closed){ + $interval.cancel(checker); + } else if ($scope.popup.token != undefined && $scope.popup.token != null) { + $rootScope.access_token = $scope.popup.token.access_token; + $rootScope.refresh_token = $scope.popup.token.refresh_token; + $scope.popup.close(); + $interval.cancel(checker); + } else if ($scope.popup.token == null){ + $scope.popup.close(); + $interval.cancel(checker); + } + }, 500); }; $scope.refresh = function(){ var openUrl = '/refresh_token'; From 156f06bc200aa2b98813db2efd02962a187e8af6 Mon Sep 17 00:00:00 2001 From: Philippe Vienne Date: Sun, 17 Apr 2016 21:19:01 +0200 Subject: [PATCH 06/15] Refresh the token --- public/index.html | 4 ++-- public/script.js | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/public/index.html b/public/index.html index 34cf236..309bd75 100644 --- a/public/index.html +++ b/public/index.html @@ -28,10 +28,10 @@ diff --git a/public/script.js b/public/script.js index b4662bc..8b195b7 100644 --- a/public/script.js +++ b/public/script.js @@ -58,7 +58,7 @@ }]); - app.controller('AuthCtrl',['$scope', '$rootScope', '$interval', function($scope, $rootScope, $interval){ + app.controller('AuthCtrl',['$scope', '$rootScope', '$interval', '$http', function($scope, $rootScope, $interval, $http){ $scope.login = function(){ var openUrl = '/login'; window.$windowScope = $scope; @@ -71,16 +71,20 @@ $rootScope.refresh_token = $scope.popup.token.refresh_token; $scope.popup.close(); $interval.cancel(checker); - } else if ($scope.popup.token == null){ - $scope.popup.close(); - $interval.cancel(checker); } }, 500); + return false; }; $scope.refresh = function(){ - var openUrl = '/refresh_token'; - window.$windowScope = $scope; - window.open(openUrl, "Authenticate Account", "width=500, height=500"); + if($rootScope.refresh_token) + $http.get('/refresh_token',{params: {refresh_token: $rootScope.refresh_token}}) + .then(function(result){ + $rootScope.access_token = result.data.access_token || ""; + }, function(failResult){ + $rootScope.access_token = ""; + $rootScope.refresh_token = ""; + }); + return false; } }]) From 0bc8f06c3eaf0db74c75b77e0fb5fbb058e978b6 Mon Sep 17 00:00:00 2001 From: Philippe Vienne Date: Sun, 17 Apr 2016 21:47:17 +0200 Subject: [PATCH 07/15] Load playlists --- public/index.html | 30 +-------------------------- public/partials/dups.html | 2 ++ public/partials/home.html | 1 + public/partials/logged.html | 4 ++++ public/partials/playlist.html | 9 ++++++++ public/script.js | 39 +++++++++++++++++++++++++++++------ 6 files changed, 50 insertions(+), 35 deletions(-) create mode 100644 public/partials/dups.html create mode 100644 public/partials/home.html create mode 100644 public/partials/logged.html create mode 100644 public/partials/playlist.html diff --git a/public/index.html b/public/index.html index 309bd75..6d6da6a 100644 --- a/public/index.html +++ b/public/index.html @@ -38,35 +38,7 @@
-

Duplicates finder - - - Log in with Spotify - -

-
-
-
-
- -
-
-

Playlists - -

-
-
-
-
-
-
-
-
-
+
- - - - - - - - +