Blame view
scripts/FeedController.js
2.62 KB
4da3dd303
|
1 |
angular.module('flashy.FeedController', ['ui.router']). |
9c420b35c
|
2 |
|
8fa323ef6
|
3 |
controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) { |
bbba33088
|
4 |
console.log('Hello from feed'); |
8fa323ef6
|
5 |
sectionId = $stateParams.sectionId; |
bac1b3d8d
|
6 |
$scope.cards = []; |
8fa323ef6
|
7 8 9 |
$scope.cards[0] = {'id': 1, 'title': 'title1', 'content': 'abc'}; $scope.cards[1] = {'id': 2, 'title': 'title2', 'content': 'xyz'}; $scope.cards[2] = {'id': 2, 'title': 'title3', 'content': 'qwe'}; |
bac1b3d8d
|
10 |
|
8fa323ef6
|
11 12 13 14 15 16 17 18 19 |
$http.get('/api/sections/' + sectionId + '/flashcards/'). success(function(data) { for (var i = 0; i < data.length; i++) { cards.push({'title': data[i].title, 'content': data[i].content}); } }). error(function(err) { console.log('no'); }); |
bac1b3d8d
|
20 |
|
80d1e57aa
|
21 |
$scope.viewDeck = function() { |
bbba33088
|
22 |
$state.go('deck'); |
80d1e57aa
|
23 24 |
console.log('go to deck'); }; |
a9bf4467e
|
25 |
|
bac1b3d8d
|
26 27 |
$scope.pullCard = function(card) { var index = $scope.cards.indexOf(card); |
32b3331d8
|
28 |
|
bac1b3d8d
|
29 30 |
console.log($scope.cards[index]); }; |
c3f215014
|
31 |
|
32b3331d8
|
32 |
$scope.pushCard = function() { |
c3f215014
|
33 |
console.log('make! card content:' + $scope.text); |
a2c4eb4fd
|
34 35 36 37 |
var pushed = new Date(Date.now()); console.log(pushed.toString()); // attempt to make card :( |
6fd36f978
|
38 |
$http.post('/api/flashcards/', {'text': $scope.text, 'pushed': pushed, 'mask': []}). |
8fa323ef6
|
39 40 41 42 43 44 |
success(function(data) { console.log('No way, really?'); }). error(function(error) { console.log('haha, n00b'); }); |
a2c4eb4fd
|
45 |
|
6fd36f978
|
46 |
$scope.text = ''; |
32b3331d8
|
47 |
}; |
8fa323ef6
|
48 49 |
$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???'; |
6fd36f978
|
50 |
$scope.text = ''; |
e384f6cef
|
51 52 |
$(document).ready(function() { |
8fa323ef6
|
53 54 55 56 57 58 59 60 61 62 |
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered $('.modal-trigger').leanModal({ dismissible: true, // Modal can be dismissed by clicking outside of the modal opacity: 0, // Opacity of modal background in_duration: 300, // Transition in duration out_duration: 200, // Transition out duration /*ready: function() { alert('Ready'); }, // Callback for Modal open complete: function() { alert('Closed'); } // Callback for Modal close*/ } ); |
34a342819
|
63 |
}); |
46c7d69b0
|
64 |
|
bbba33088
|
65 |
}]); |