Commit 07a06ca9da59a6d3ca56f9c95037b5cd7edef12a
1 parent
e085121887
Exists in
master
and in
1 other branch
cleanup; more deck refactoring
Showing 3 changed files with 23 additions and 11 deletions Side-by-side Diff
scripts/CardGridController.js
View file @
07a06ca
... | ... | @@ -62,6 +62,10 @@ |
62 | 62 | console.log('deck ws open'); |
63 | 63 | }); |
64 | 64 | |
65 | + $scope.deck_ws.onMessage(function(message) { | |
66 | + console.log('message', message); | |
67 | + }); | |
68 | + | |
65 | 69 | $scope.add = function(card) { |
66 | 70 | var colNum = 0; |
67 | 71 | var lowestCol = $scope.cardCols[0]; |
... | ... | @@ -83,6 +87,16 @@ |
83 | 87 | $scope.cardTable[card.id] = {'colNum': lowestColNum, 'obj': card}; |
84 | 88 | $timeout($scope.refreshColumnWidth); |
85 | 89 | }; |
90 | + | |
91 | + $http.get('/api/sections/' + $scope.sectionId + '/deck/'). | |
92 | + success(function(data) { | |
93 | + $scope.deck_cards = data; | |
94 | + console.log("got user's deck"); | |
95 | + console.log(data); | |
96 | + }). | |
97 | + error(function(err) { | |
98 | + console.log('get deck failed'); | |
99 | + }); | |
86 | 100 | |
87 | 101 | $scope.$on('$destroy', function() { |
88 | 102 | $scope.deck_ws.close(); |
scripts/CardListController.js
View file @
07a06ca
... | ... | @@ -182,22 +182,22 @@ |
182 | 182 | filter('displayCard', function($sce) { |
183 | 183 | return function(card) { |
184 | 184 | // text to display as html |
185 | - var cardText = ""; | |
185 | + var cardText = ''; | |
186 | 186 | |
187 | 187 | var start = 0; // where to start next string break |
188 | 188 | |
189 | 189 | // get all display pieces and blank pieces |
190 | 190 | for (var i = 0; i < card.mask.length; i++) { |
191 | - cardText = cardText.concat( card.text.substring(start, card.mask[i][0]) ); | |
192 | - cardText = cardText.concat("<b>"); | |
193 | - cardText = cardText.concat( card.text.substring(card.mask[i][0], card.mask[i][1]) ); | |
194 | - cardText = cardText.concat("</b>"); | |
191 | + cardText = cardText.concat(card.text.substring(start, card.mask[i][0])); | |
192 | + cardText = cardText.concat('<b>'); | |
193 | + cardText = cardText.concat(card.text.substring(card.mask[i][0], card.mask[i][1])); | |
194 | + cardText = cardText.concat('</b>'); | |
195 | 195 | start = card.mask[i][1]; |
196 | 196 | } |
197 | 197 | |
198 | 198 | // get remaining dislay pieces, if any |
199 | 199 | if (start != card.mask.length - 1) |
200 | - cardText = cardText.concat( card.text.substring(start) ); | |
200 | + cardText = cardText.concat(card.text.substring(start)); | |
201 | 201 | |
202 | 202 | //cardText = cardText.concat("</span>"); |
203 | 203 | return $sce.trustAsHtml(cardText); |
scripts/FlashcardDirective.js
View file @
07a06ca
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | /* Pulls card from feed into deck */ |
26 | 26 | scope.pullCard = function(flashcard) { |
27 | 27 | flashcard.is_in_deck = true; |
28 | - $http.post('/api/flashcards/' + flashcard.id + '/pull/', flashcard). | |
28 | + $http.post('/api/flashcards/' + flashcard.id + '/pull/'). | |
29 | 29 | success(function(data) { |
30 | 30 | console.log('pulled flashcard #' + flashcard.id); |
31 | 31 | //scope.startShrink = true; |
... | ... | @@ -40,8 +40,7 @@ |
40 | 40 | scope.unpullCard = function(flashcard) { |
41 | 41 | console.log('unpulling card...'); |
42 | 42 | flashcard.is_in_deck = false; |
43 | - $http.post('/api/flashcards/' + flashcard.id + '/unpull/', | |
44 | - flashcard). | |
43 | + $http.post('/api/flashcards/' + flashcard.id + '/unpull/'). | |
45 | 44 | success(function(data) { |
46 | 45 | console.log('card unpull success'); |
47 | 46 | //scope.startShrink = true; |
... | ... | @@ -55,8 +54,7 @@ |
55 | 54 | /* Hides card from feed */ |
56 | 55 | scope.hideCard = function(flashcard) { |
57 | 56 | if ($state.current.name == 'feed') { |
58 | - $http.post('/api/flashcards/' + flashcard.id + '/hide/', | |
59 | - flashcard). | |
57 | + $http.post('/api/flashcards/' + flashcard.id + '/hide/'). | |
60 | 58 | success(function(data) { |
61 | 59 | console.log('card hide success'); |
62 | 60 | scope.startShrink = true; |