Commit 4bbb4161c10e6cae6021b6689e851915a7c63f03
1 parent
e303b86ecf
Exists in
master
and in
1 other branch
Fixing js styling for password reset, starting on feed pull
Showing 3 changed files with 83 additions and 81 deletions Inline Diff
scripts/FeedController.js
View file @
4bbb416
angular.module('flashy.FeedController', ['ui.router']). | 1 | 1 | angular.module('flashy.FeedController', ['ui.router']). | |
2 | 2 | |||
controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) { | 3 | 3 | controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) { | |
console.log('Hello from feed'); | 4 | 4 | console.log('Hello from feed'); | |
sectionId = $stateParams.sectionId; | 5 | 5 | sectionId = $stateParams.sectionId; | |
$scope.cards = []; | 6 | 6 | $scope.cards = []; | |
7 | 7 | |||
$scope.cards[0] = {'id': 1, 'title': 'title1', 'content': 'abchello'}; | 8 | 8 | $scope.cards[0] = {'id': 1, 'title': 'title1', 'content': 'abchello'}; | |
$scope.cards[1] = {'id': 2, 'title': 'title2', 'content': 'xyz2 2 2 2 2'}; | 9 | 9 | $scope.cards[1] = {'id': 2, 'title': 'title2', 'content': 'xyz2 2 2 2 2'}; | |
$scope.cards[2] = {'id': 2, 'title': 'title3', 'content': 'qwe 3 3 3'}; | 10 | 10 | $scope.cards[2] = {'id': 2, 'title': 'title3', 'content': 'qwe 3 3 3'}; | |
11 | 11 | |||
$http.get('/api/sections/' + sectionId + '/flashcards/'). | 12 | 12 | $http.get('/api/sections/' + sectionId + '/flashcards/'). | |
success(function(data) { | 13 | 13 | success(function(data) { | |
for (var i = 0; i < data.length; i++) { | 14 | 14 | for (var i = 0; i < data.length; i++) { | |
cards.push({'title': data[i].title, 'content': data[i].content}); | 15 | 15 | cards.push({'title': data[i].title, 'content': data[i].content}); | |
} | 16 | 16 | } | |
}). | 17 | 17 | }). | |
error(function(err) { | 18 | 18 | error(function(err) { | |
console.log('no'); | 19 | 19 | console.log('no'); | |
}); | 20 | 20 | }); | |
21 | 21 | |||
$scope.viewDeck = function() { | 22 | 22 | $scope.viewDeck = function() { | |
$state.go('deck', {sectionId: sectionId}); | 23 | 23 | $state.go('deck', {sectionId: sectionId}); | |
console.log('go to deck'); | 24 | 24 | console.log('go to deck'); | |
}; | 25 | 25 | }; | |
26 | 26 | |||
$scope.pullCard = function(card) { | 27 | 27 | $scope.pullCard = function(card) { | |
28 | /* | |||
29 | $http.post('/api/flashcards/pk/pull', | |||
30 | {} | |||
31 | */ | |||
var index = $scope.cards.indexOf(card); | 28 | 32 | var index = $scope.cards.indexOf(card); | |
29 | 33 | |||
console.log($scope.cards[index]); | 30 | 34 | console.log($scope.cards[index]); | |
}; | 31 | 35 | }; | |
32 | 36 | |||
$scope.pushCard = function() { | 33 | 37 | $scope.pushCard = function() { | |
console.log('make! card content:' + $scope.text); | 34 | 38 | console.log('make! card content:' + $scope.text); | |
var pushed = new Date(Date.now()); | 35 | 39 | var pushed = new Date(Date.now()); | |
console.log(pushed.toString()); | 36 | 40 | console.log(pushed.toString()); | |
37 | 41 | |||
// attempt to make card :( | 38 | 42 | // attempt to make card :( | |
$http.post('/api/flashcards/', {'text': $scope.text, 'pushed': pushed, 'mask': []}). | 39 | 43 | $http.post('/api/flashcards/', {'text': $scope.text, 'pushed': pushed, 'mask': []}). | |
success(function(data) { | 40 | 44 | success(function(data) { | |
console.log('No way, really?'); | 41 | 45 | console.log('No way, really?'); | |
}). | 42 | 46 | }). | |
error(function(error) { | 43 | 47 | error(function(error) { | |
console.log('haha, n00b'); | 44 | 48 | console.log('haha, n00b'); | |
}); | 45 | 49 | }); | |
46 | 50 | |||
$scope.text = ''; | 47 | 51 | $scope.text = ''; | |
}; | 48 | 52 | }; | |
49 | 53 | |||
$scope.flashcard = 'hi i am a flashcard. I need to be really long and awesome I ain\'t ' + | 50 | 54 | $scope.flashcard = 'hi i am a flashcard. I need to be really long and awesome I ain\'t ' + | |
'know how long I am right now. Is it good enough now?????????? Howz about now???'; | 51 | 55 | 'know how long I am right now. Is it good enough now?????????? Howz about now???'; | |
$scope.text = ''; | 52 | 56 | $scope.text = ''; | |
53 | 57 | |||
$(document).ready(function() { | 54 | 58 | $(document).ready(function() { | |
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | 55 | 59 | // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered |
scripts/RequestResetController.js
View file @
4bbb416
angular.module('flashy.RequestResetController', ['ui.router']) | 1 | 1 | angular.module('flashy.RequestResetController', ['ui.router']). | |
2 | 2 | |||
.controller('RequestResetController', ['$scope', '$state', '$http', | 3 | 3 | controller('RequestResetController', ['$scope', '$state', '$http', | |
function($scope, $state, $http) { | 4 | 4 | function($scope, $state, $http) { | |
'use strict'; | 5 | 5 | 'use strict'; | |
$scope.success = false; | 6 | 6 | $scope.success = false; | |
$scope.error = false; | 7 | 7 | $scope.error = false; | |
$scope.resetPass = function(email) { | 8 | 8 | $scope.resetPass = function(email) { | |
$http.post('/api/request_password_reset/', JSON.stringify({ | 9 | 9 | $http.post('/api/request_password_reset/', JSON.stringify({ | |
'email': email | 10 | 10 | 'email': email | |
})) | 11 | 11 | })). | |
.success(function(data) { | 12 | 12 | success(function(data) { | |
$scope.success = true; | 13 | 13 | $scope.success = true; | |
//$state.go('requestresetsuccess'); | 14 | 14 | //$state.go('requestresetsuccess'); | |
console.log('SUCCESS'); | 15 | 15 | console.log('SUCCESS'); | |
console.log(data); | 16 | 16 | console.log(data); | |
}) | 17 | 17 | }). | |
.error(function(data, status, header, config) { | 18 | 18 | error(function(data, status, header, config) { | |
if (data.email) { | 19 | 19 | if (data.email) { | |
$scope.error = true; | 20 | 20 | $scope.error = true; | |
} | 21 | 21 | } | |
console.log('ERROR'); | 22 | 22 | console.log('ERROR'); | |
console.log(data); | 23 | 23 | console.log(data); | |
}); | 24 | 24 | }); | |
}; | 25 | 25 | }; | |
$scope.cancelReset = function() { | 26 | 26 | ||
$state.go('login'); | 27 | 27 | $scope.cancelReset = function() { | |
}; | 28 | 28 | $state.go('login'); | |
} | 29 | 29 | }; | |
]); | 30 | 30 | }]); | |
31 | 31 | |||
scripts/ResetPasswordController.js
View file @
4bbb416
angular.module('flashy.ResetPasswordController', ['ui.router']). | 1 | 1 | angular.module('flashy.ResetPasswordController', ['ui.router']). | |
2 | 2 | |||
controller('ResetPasswordController', ['$scope', '$state', '$http', '$timeout', | 3 | 3 | controller('ResetPasswordController', ['$scope', '$state', '$http', '$timeout', | |
function($scope, $state, $http, $timeout) { | 4 | 4 | function($scope, $state, $http, $timeout) { | |
'use strict'; | 5 | 5 | 'use strict'; | |
var url = document.location.href.split('/'); | 6 | 6 | var url = document.location.href.split('/'); | |
var token = url[url.length - 1]; | 7 | 7 | var token = url[url.length - 1]; | |
var uid = url[url.length - 2]; | 8 | 8 | var uid = url[url.length - 2]; | |
$scope.error = false; | 9 | 9 | $scope.error = false; | |
$scope.success = false; | 10 | 10 | $scope.success = false; | |
$scope.mismatch = false; | 11 | 11 | $scope.mismatch = false; | |
$scope.unacceptable = false; | 12 | 12 | $scope.unacceptable = false; | |
/*if(token == 'resetpassword') { | 13 | 13 | /*if(token == 'resetpassword') { | |
$state.go('login'); | 14 | 14 | $state.go('login'); | |
}*/ | 15 | 15 | }*/ | |
console.log('RESETTING'); | 16 | 16 | console.log('RESETTING'); | |
$scope.confirmResetPass = function() { | 17 | 17 | $scope.confirmResetPass = function() { | |
if ($scope.newPassword.length < 8) { | 18 | 18 | if ($scope.newPassword.length < 8) { | |
$scope.unacceptable = true; | 19 | 19 | $scope.unacceptable = true; | |
return; | 20 | 20 | return; | |
} | 21 | 21 | } | |
if ($scope.newPassword != $scope.confirmPassword) { | 22 | 22 | if ($scope.newPassword != $scope.confirmPassword) { | |
$scope.mismatch = true; | 23 | 23 | $scope.mismatch = true; | |
$scope.confirmPassword.$setPristine(); | 24 | 24 | $scope.confirmPassword.$setPristine(); | |
console.log('mismatch'); | 25 | 25 | console.log('mismatch'); | |
return; | 26 | 26 | return; | |
} | 27 | 27 | } | |
$http.post('/api/reset_password/', JSON.stringify({ | 28 | 28 | $http.post('/api/reset_password/', JSON.stringify({ | |
'uid': uid, | 29 | 29 | 'uid': uid, | |
'token': token, | 30 | 30 | 'token': token, | |
'new_password': $scope.newPassword | 31 | 31 | 'new_password': $scope.newPassword | |
})) | 32 | 32 | })).success(function(data) { | |
.success(function(data) { | 33 | 33 | $scope.error = false; | |
$scope.error = false; | 34 | 34 | $scope.success = true; | |
$scope.success = true; | 35 | 35 | //$state.go('resetpasssuccess'); | |
//$state.go('resetpasssuccess'); | 36 | 36 | $timeout(function($state) { | |
$timeout(function($state) { | 37 | 37 | $state.go('login'); | |
$state.go('login'); | 38 | 38 | }, 1000); | |
}, 1000); | 39 | 39 | console.log(data); | |
console.log(data); | 40 | 40 | ||
}) | 41 | 41 | }).error(function(data, status, header, config) { | |
.error(function(data, status, header, config) { | 42 | 42 | $scope.error = true; | |
$scope.error = true; | 43 | 43 | $scope.success = false; | |
$scope.success = false; | 44 | 44 | $scope.mismatch = false; | |
$scope.mismatch = false; | 45 | 45 | $scope.unacceptable = false; | |
$scope.unacceptable = false; | 46 | 46 | console.log(data); | |
console.log(data); | 47 | 47 | }); | |
}); | 48 | 48 | }; | |
}; | 49 | 49 | $scope.cancelReset = function() { | |
$scope.cancelReset = function() { | 50 | 50 | $state.go('login'); | |
$state.go('login'); | 51 | 51 | }; | |
}; | 52 | 52 | }]); | |
} | 53 | |||
]); | 54 | |||
55 | 53 | |||