Commit b83f46393c7490924a580f01929817aed96a8e48
1 parent
61e46d4d43
Exists in
master
and in
1 other branch
only listen for c outside of the model
Showing 3 changed files with 12 additions and 11 deletions Inline Diff
scripts/FeedController.js
View file @
b83f463
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 | |||
$http.get('/api/sections/' + sectionId + '/feed/'). | 8 | 8 | $http.get('/api/sections/' + sectionId + '/feed/'). | |
success(function (data) { | 9 | 9 | success(function (data) { | |
console.log(data); | 10 | 10 | console.log(data); | |
$scope.cards = data; | 11 | 11 | $scope.cards = data; | |
}). | 12 | 12 | }). | |
error(function (err) { | 13 | 13 | error(function (err) { | |
console.log('pulling feed failed'); | 14 | 14 | console.log('pulling feed failed'); | |
}); | 15 | 15 | }); | |
16 | 16 | |||
$scope.viewDeck = function () { | 17 | 17 | $scope.viewDeck = function () { | |
$state.go('deck', {sectionId: sectionId}); | 18 | 18 | $state.go('deck', {sectionId: sectionId}); | |
console.log('go to deck'); | 19 | 19 | console.log('go to deck'); | |
}; | 20 | 20 | }; | |
21 | 21 | |||
$scope.pushCard = function () { | 22 | 22 | $scope.pushCard = function () { | |
console.log('make! card content:' + $scope.text); | 23 | 23 | console.log('make! card content:' + $scope.text); | |
var pushed = new Date(Date.now()); | 24 | 24 | var pushed = new Date(Date.now()); | |
console.log(pushed.toString()); | 25 | 25 | console.log(pushed.toString()); | |
text = $scope.text; | 26 | 26 | text = $scope.text; | |
// attempt to make card :( | 27 | 27 | // attempt to make card :( | |
var myCard = { | 28 | 28 | var myCard = { | |
'text': $scope.text, | 29 | 29 | 'text': $scope.text, | |
'material_date': pushed, | 30 | 30 | 'material_date': pushed, | |
'mask': '[]', | 31 | 31 | 'mask': '[]', | |
section: sectionId | 32 | 32 | section: sectionId | |
}; | 33 | 33 | }; | |
$http.post('/api/flashcards/', myCard). | 34 | 34 | $http.post('/api/flashcards/', myCard). | |
success(function (data) { | 35 | 35 | success(function (data) { | |
console.log('pushed a card!'); | 36 | 36 | console.log('pushed a card!'); | |
$scope.cards.push(myCard); // Add right away | 37 | 37 | $scope.cards.push(myCard); // Add right away | |
$scope.refreshCards(); // Refresh list | 38 | 38 | $scope.refreshCards(); // Refresh list | |
39 | listenForC = true; | |||
}). | 39 | 40 | }). | |
error(function (error) { | 40 | 41 | error(function (error) { | |
console.log('haha, n00b'); | 41 | 42 | console.log('haha, n00b'); | |
}); | 42 | 43 | }); | |
43 | 44 | |||
$scope.text = ''; | 44 | 45 | $scope.text = ''; | |
}; | 45 | 46 | }; | |
46 | 47 | |||
$scope.refreshCards = function () { | 47 | 48 | $scope.refreshCards = function () { | |
$http.get('/api/sections/' + sectionId + '/feed/'). | 48 | 49 | $http.get('/api/sections/' + sectionId + '/feed/'). | |
success(function (data) { | 49 | 50 | success(function (data) { | |
console.log(data); | 50 | 51 | console.log(data); | |
$scope.cards = data; | 51 | 52 | $scope.cards = data; | |
console.log('success in refresh cards...'); | 52 | 53 | console.log('success in refresh cards...'); | |
}). | 53 | 54 | }). | |
error(function (err) { | 54 | 55 | error(function (err) { | |
console.log('refresh fail'); | 55 | 56 | console.log('refresh fail'); | |
}); | 56 | 57 | }); | |
} | 57 | 58 | } | |
58 | 59 | var listenForC = true; | ||
$(document).keydown(function (e) { | 59 | 60 | $(document).keydown(function (e) { | |
var keyed = e.which; | 60 | 61 | var keyed = e.which; | |
if (keyed == 67) { // "c" or "C" for compose | 61 | 62 | if (keyed == 67 && listenForC) { // "c" or "C" for compose | |
$('#newCard').openModal(); | 62 | 63 | $('#newCard').openModal(); | |
64 | listenForC = false; | |||
65 | return false; | |||
} | 63 | 66 | } | |
}); | 64 | 67 | }); | |
65 | 68 | |||
66 | 69 | |||
$scope.flashcard = 'hi i am a flashcard. I need to be really long and awesome I ain\'t ' + | 67 | 70 | $scope.flashcard = ''; | |
'know how long I am right now. Is it good enough now?????????? Howz about now???'; | 68 | |||
$scope.text = ''; | 69 | 71 | $scope.text = ''; | |
70 | 72 | |||
$(document).ready(function () { | 71 | 73 | $(document).ready(function () { | |
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | 72 | 74 | // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | |
$('.modal-trigger').leanModal({ | 73 | 75 | $('.modal-trigger').leanModal({ | |
dismissible: true, // Modal can be dismissed by clicking outside of the modal | 74 | 76 | dismissible: true, // Modal can be dismissed by clicking outside of the modal | |
opacity: 0, // Opacity of modal background | 75 | 77 | opacity: 0, // Opacity of modal background | |
in_duration: 300, // Transition in duration | 76 | 78 | in_duration: 300, // Transition in duration | |
out_duration: 200, // Transition out duration | 77 | 79 | out_duration: 200, // Transition out duration | |
ready: function () { | 78 | |||
$('input:text:visible:first').focus(); | 79 |
templates/login.html
View file @
b83f463
<div class="row"> | 1 | 1 | <div class="row"> | |
2 | 2 | |||
</div> | 3 | 3 | </div> | |
<div class="row"> | 4 | 4 | <div class="row"> | |
<div class="offset-s3 col s4"> | 5 | 5 | <div class="offset-s3 col s4"> | |
6 | 6 | |||
</div> | 7 | 7 | </div> | |
<div class="offset-s3 col s4"> | 8 | 8 | <div class="offset-s3 col s4"> | |
<ul class="tabs"> | 9 | 9 | <ul class="tabs"> | |
<li class="tab col s6"><a href="#register-tab">Sign Up</a></li> | 10 | 10 | <li class="tab col s6"><a href="#register-tab">Sign Up</a></li> | |
<li class="tab col s6"><a class="active" href="#login-tab">Login</a></li> | 11 | 11 | <li class="tab col s6"><a class="active" href="#login-tab">Login</a></li> | |
</ul> | 12 | 12 | </ul> | |
<div class="card"> | 13 | 13 | <div class="card"> | |
<!--LOGIN TAB--> | 14 | 14 | <!--LOGIN TAB--> | |
<div id="login-tab" class="row col s12"> | 15 | 15 | <div id="login-tab" class="row col s12"> | |
<form> | 16 | 16 | <form> | |
<div class="card-content"> | 17 | 17 | <div class="card-content"> | |
<div class="check-element animate-show" role="alert" ng-show="loginError"> | 18 | 18 | <div class="check-element animate-show" role="alert" ng-show="loginError"> | |
<span style="color:#8E2323">Invalid username or password!!</span> | 19 | 19 | <span style="color:#8E2323">Invalid username or password!!</span> | |
</div> | 20 | 20 | </div> | |
21 | 21 | |||
<div class="input-field"> | 22 | 22 | <div class="input-field"> | |
<input id="email" type="email" name="login" class="validate" ng-model="loginEmail" required/> | 23 | 23 | <input id="email" type="email" name="login" class="validate" ng-model="loginEmail" required autofocus autocomplete/> | |
<label for="email">Email</label> | 24 | 24 | <label for="email">Email</label> | |
</div> | 25 | 25 | </div> | |
<div class="input-field"> | 26 | 26 | <div class="input-field"> | |
<input id="password" type="password" name="password" class="validate" ng-model="loginPassword" required/> | 27 | 27 | <input id="password" type="password" name="password" class="validate" ng-model="loginPassword" required/> | |
<label for="password">Password</label> | 28 | 28 | <label for="password">Password</label> | |
</div> | 29 | 29 | </div> | |
</div> | 30 | 30 | </div> | |
<div class="card-action"> | 31 | 31 | <div class="card-action"> | |
<button class="btn waves-effect waves-light col s12" type="submit" name="action" | 32 | 32 | <button class="btn waves-effect waves-light col s12" type="submit" name="action" | |
ng-click="login(loginEmail, loginPassword)">Login | 33 | 33 | ng-click="login(loginEmail, loginPassword)">Login | |
</button> | 34 | 34 | </button> | |
</div> | 35 | 35 | </div> | |
</form> | 36 | 36 | </form> | |
</div> | 37 | 37 | </div> | |
<!--REGISTER TAB--> | 38 | 38 | <!--REGISTER TAB--> | |
<div id="register-tab" class="row col s12"> | 39 | 39 | <div id="register-tab" class="row col s12"> | |
<form> | 40 | 40 | <form> | |
<div class="card-content"> | 41 | 41 | <div class="card-content"> | |
<div class="check-element animate-show" role="alert" ng-show="uniqueError"> | 42 | 42 | <div class="check-element animate-show" role="alert" ng-show="uniqueError"> | |
<span style="color:#8E2323">Invalid username or password!!</span> | 43 | 43 | <span style="color:#8E2323">Invalid username or password!!</span> | |
</div> | 44 | 44 | </div> | |
<div class="input-field"> | 45 | 45 | <div class="input-field"> | |
<input id="email" type="email" class="validate" ng-model="loginEmail" required/> | 46 | 46 | <input id="email" type="email" class="validate" ng-model="loginEmail" required/> | |
<label for="email">Email</label> | 47 | 47 | <label for="email">Email</label> | |
</div> | 48 | 48 | </div> | |
<div class="input-field"> | 49 | 49 | <div class="input-field"> | |
<input type="password" class="validate" ng-model="registerPassword" required/> | 50 | 50 | <input type="password" class="validate" ng-model="registerPassword" required/> | |
<label for="password">Password</label> | 51 | 51 | <label for="password">Password</label> | |
</div> | 52 | 52 | </div> | |
</div> | 53 | 53 | </div> | |
<div class="card-action"> | 54 | 54 | <div class="card-action"> | |
<button class="btn waves-effect waves-light col s12" type="" name="action" | 55 | 55 | <button class="btn waves-effect waves-light col s12" type="" name="action" | |
ng-click="signUp(loginEmail, registerPassword)">Register | 56 | 56 | ng-click="signUp(loginEmail, registerPassword)">Register | |
</button> | 57 | 57 | </button> | |
</div> | 58 | 58 | </div> | |
</form> | 59 | 59 | </form> | |
</div> | 60 | 60 | </div> | |
61 | 61 | |||
<div class="row offset-s1 col s12"> | 62 | 62 | <div class="row offset-s1 col s12"> | |
<a class="trigger-password-reset" ng-click="triggerPasswordReset()" href="#">Forgot Password?</a> | 63 | 63 | <a class="trigger-password-reset" ng-click="triggerPasswordReset()" href="#">Forgot Password?</a> | |
</div> | 64 | 64 | </div> |
templates/logout.html
View file @
b83f463
<div class="container"> | 1 | 1 | <div class="container"> | |
<h3 class="text-success heading">You have successfully logged out.</h3> | 2 | 2 | <div class="row"> | |
3 | <div class="offset-s3 col s4"> | |||
4 | <h3 class="text-success heading">You have successfully logged out.</h3> | |||
5 | </div> | |||
6 | </div> | |||
</div> | 3 | 7 | </div> | |