Blame view

scripts/FeedController.js 2.62 KB
4da3dd303   Andrew Buss   Tried unbreaking ...
1
  angular.module('flashy.FeedController', ['ui.router']).
9c420b35c   Rachel Lee   Separating all cu...
2

8fa323ef6   Andrew Buss   more on userservi...
3
      controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) {
bbba33088   Andrew Buss   Added addclass st...
4
          console.log('Hello from feed');
8fa323ef6   Andrew Buss   more on userservi...
5
          sectionId = $stateParams.sectionId;
bac1b3d8d   Melody   Purple
6
          $scope.cards = [];
8fa323ef6   Andrew Buss   more on userservi...
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   Melody   Purple
10

8fa323ef6   Andrew Buss   more on userservi...
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   Melody   Purple
20

80d1e57aa   Andrew Buss   materialized thin...
21
          $scope.viewDeck = function() {
bbba33088   Andrew Buss   Added addclass st...
22
              $state.go('deck');
80d1e57aa   Andrew Buss   materialized thin...
23
24
              console.log('go to deck');
          };
a9bf4467e   Kevin Mach   update deck, feed...
25

bac1b3d8d   Melody   Purple
26
27
          $scope.pullCard = function(card) {
              var index = $scope.cards.indexOf(card);
32b3331d8   Melody   Fixed fancy butto...
28

bac1b3d8d   Melody   Purple
29
30
              console.log($scope.cards[index]);
          };
c3f215014   Melody   Purple! And submi...
31

32b3331d8   Melody   Fixed fancy butto...
32
          $scope.pushCard = function() {
c3f215014   Melody   Purple! And submi...
33
              console.log('make! card content:' + $scope.text);
a2c4eb4fd   Melody   Added Angular Mat...
34
35
36
37
              var pushed = new Date(Date.now());
              console.log(pushed.toString());
  
              // attempt to make card :(
6fd36f978   Andrew Buss   autocomplete is w...
38
              $http.post('/api/flashcards/', {'text': $scope.text, 'pushed': pushed, 'mask': []}).
8fa323ef6   Andrew Buss   more on userservi...
39
40
41
42
43
44
                  success(function(data) {
                      console.log('No way, really?');
                  }).
                  error(function(error) {
                      console.log('haha, n00b');
                  });
a2c4eb4fd   Melody   Added Angular Mat...
45

6fd36f978   Andrew Buss   autocomplete is w...
46
              $scope.text = '';
32b3331d8   Melody   Fixed fancy butto...
47
          };
8fa323ef6   Andrew Buss   more on userservi...
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   Andrew Buss   autocomplete is w...
50
          $scope.text = '';
e384f6cef   Andrew Buss   add trailing slas...
51
52
  
          $(document).ready(function() {
8fa323ef6   Andrew Buss   more on userservi...
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   Melody   Nicer new flashca...
63
          });
46c7d69b0   Melody   Fancy buttons for...
64

bbba33088   Andrew Buss   Added addclass st...
65
      }]);