Commit dc454dbeb42efdf415daf1a97090406a8485bc6b
1 parent
04d48b6f07
Exists in
master
and in
1 other branch
card list vaguely works now!
Showing 6 changed files with 130 additions and 163 deletions Inline Diff
scripts/CardGridController.js
View file @
dc454db
angular.module('flashy.CardGridController', ['ui.router', 'ngAnimate', 'ngWebSocket', 'flashy.DeckFactory']).CardGridController = | 1 | 1 | angular.module('flashy.CardGridController', ['ui.router', 'ngAnimate', 'ngWebSocket', 'flashy.DeckFactory']).CardGridController = | |
function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard, Deck) { | 2 | 2 | function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard, Deck) { | |
3 | sectionId = parseInt($stateParams.sectionId); | |||
$scope.cards = []; // all cards | 3 | 4 | $scope.cards = []; // all cards | |
$scope.cardCols = []; // organized data | 4 | 5 | $scope.cardCols = []; // organized data | |
$scope.cardColsShow = []; // displayed data | 5 | 6 | $scope.cardColsShow = []; // displayed data | |
$scope.numCols = 0; | 6 | 7 | $scope.numCols = 0; | |
$scope.cardTable = {}; // look up table of cards: {'colNum':col, 'obj':card} | 7 | 8 | $scope.section = $rootScope.SectionResource.get({sectionId: sectionId}); | |
$scope.sectionId = parseInt($stateParams.sectionId); | 8 | 9 | $scope.deck = new Deck(sectionId, { | |
$scope.section = $rootScope.SectionResource.get({sectionId: $scope.sectionId}); | 9 | |||
$scope.deck = new Deck($scope.sectionId, { | 10 | |||
cardHideCallback: function(card) { | 11 | 10 | cardHideCallback: function(card) { | |
$scope.hideCardFromGrid(card); | 12 | 11 | $scope.hideCardFromGrid(card); | |
} | 13 | 12 | } | |
}); | 14 | 13 | }); | |
15 | 14 | |||
$scope.showGrid = false; | 16 | 15 | $scope.showGrid = false; | |
//$scope.moveQueue = []; // queue of flashcard objects | 17 | 16 | //$scope.moveQueue = []; // queue of flashcard objects | |
$rootScope.currentSection = $scope.section; | 18 | 17 | $rootScope.currentSection = $scope.section; | |
19 | 18 | |||
$scope.refreshColumnWidth = function() { | 20 | 19 | $scope.refreshColumnWidth = function() { | |
avail = $window.innerWidth - 17; | 21 | 20 | avail = $window.innerWidth - 17; | |
width = Math.floor(avail / Math.floor(avail / 250)); | 22 | 21 | width = Math.floor(avail / Math.floor(avail / 250)); | |
$('.cardColumn').css({ | 23 | 22 | $('.cardColumn').css({ | |
width: width + 'px', | 24 | 23 | width: width + 'px', | |
'font-size': 100 * width / 250 + '%' | 25 | 24 | 'font-size': 100 * width / 250 + '%' | |
}); | 26 | 25 | }); | |
$('.cardColumn .card.flashy').css({ | 27 | 26 | $('.cardColumn .card.flashy').css({ | |
width: width - 12 + 'px', | 28 | 27 | width: width - 12 + 'px', | |
height: (width * 3 / 5) + 'px' | 29 | 28 | height: (width * 3 / 5) + 'px' | |
}); | 30 | 29 | }); | |
}; | 31 | 30 | }; | |
$scope.refreshLayout = function() { | 32 | 31 | $scope.refreshLayout = function() { | |
numCols = Math.max(1, Math.floor(($window.innerWidth - 17) / 250)); | 33 | 32 | numCols = Math.max(1, Math.floor(($window.innerWidth - 17) / 250)); | |
34 | 33 | |||
// check if we actually need to refresh the whole layout | 35 | 34 | // check if we actually need to refresh the whole layout | |
if (numCols == $scope.numCols) return $scope.refreshColumnWidth(); | 36 | 35 | if (numCols == $scope.numCols) return $scope.refreshColumnWidth(); | |
$scope.numCols = numCols; | 37 | 36 | $scope.numCols = numCols; | |
console.log('refreshing layout for ' + numCols + ' columns'); | 38 | 37 | console.log('refreshing layout for ' + numCols + ' columns'); | |
$scope.cardCols = []; | 39 | 38 | $scope.cardCols = []; | |
var cols = []; | 40 | 39 | var cols = []; | |
for (var i = 0; i < numCols; i++) cols.push([]); | 41 | 40 | for (var i = 0; i < numCols; i++) cols.push([]); | |
var n = 0; | 42 | 41 | var n = 0; | |
$scope.cards.forEach(function(card, j) { | 43 | 42 | $scope.cards.forEach(function(card, j) { | |
card.colNum = n++ % numCols; | 44 | 43 | card.colNum = n++ % numCols; | |
cols[card.colNum].push(card); | 45 | 44 | cols[card.colNum].push(card); | |
}); | 46 | 45 | }); | |
for (i in cols) $scope.updateColRanks(cols[i]); | 47 | 46 | for (i in cols) $scope.updateColRanks(cols[i]); | |
console.log(cols); | 48 | 47 | console.log(cols); | |
return $timeout(function() { | 49 | 48 | return $timeout(function() { | |
$scope.cardCols = cols; | 50 | 49 | $scope.cardCols = cols; | |
$timeout($scope.refreshColumnWidth); | 51 | 50 | $timeout($scope.refreshColumnWidth); | |
}); | 52 | 51 | }); | |
53 | 52 | |||
}; | 54 | 53 | }; | |
55 | 54 | |||
angular.element($window).bind('resize', $scope.refreshLayout); | 56 | 55 | angular.element($window).bind('resize', $scope.refreshLayout); | |
57 | 56 | |||
$scope.addCardToGrid = function(card) { | 58 | 57 | $scope.addCardToGrid = function(card) { | |
var colNum = 0; | 59 | 58 | var colNum = 0; | |
var lowestCol = $scope.cardCols[0]; | 60 | 59 | var lowestCol = $scope.cardCols[0]; | |
var lowestColNum = 0; | 61 | 60 | var lowestColNum = 0; | |
while (colNum < $scope.numCols) { | 62 | 61 | while (colNum < $scope.numCols) { | |
if ($scope.cardCols[colNum].length == 0) { | 63 | 62 | if ($scope.cardCols[colNum].length == 0) { | |
lowestCol = $scope.cardCols[colNum]; | 64 | 63 | lowestCol = $scope.cardCols[colNum]; | |
break; | 65 | 64 | break; | |
} else if ($scope.cardCols[colNum].length < lowestCol.length) { | 66 | 65 | } else if ($scope.cardCols[colNum].length < lowestCol.length) { | |
lowestCol = $scope.cardCols[colNum]; | 67 | 66 | lowestCol = $scope.cardCols[colNum]; | |
lowestColNum = colNum; | 68 | 67 | lowestColNum = colNum; | |
lowestColLen = $scope.cardCols[colNum].length; | 69 | 68 | lowestColLen = $scope.cardCols[colNum].length; | |
} | 70 | 69 | } | |
colNum++; | 71 | 70 | colNum++; | |
} | 72 | 71 | } | |
console.log(card); | 73 | 72 | console.log(card); | |
$scope.cards.push(data); | 74 | 73 | $scope.cards.push(data); | |
lowestCol.unshift(card); | 75 | 74 | lowestCol.unshift(card); | |
card.colNum = lowestColNum; | 76 | 75 | card.colNum = lowestColNum; | |
$scope.updateColRanks(lowestCol); | 77 | 76 | $scope.updateColRanks(lowestCol); | |
$timeout($scope.refreshColumnWidth); | 78 | 77 | $timeout($scope.refreshColumnWidth); | |
79 | 78 | |||
}; | 80 | 79 | }; | |
81 | 80 | |||
$scope.updateColRanks = function(col) { | 82 | 81 | $scope.updateColRanks = function(col) { | |
for (i in col) | 83 | 82 | for (i in col) | |
col[i].colRank = parseInt(i); | 84 | 83 | col[i].colRank = parseInt(i); | |
}; | 85 | 84 | }; | |
86 | 85 | |||
$scope.hideCardFromGrid = function(card) { | 87 | 86 | $scope.hideCardFromGrid = function(card) { | |
console.log('hiding', card); | 88 | 87 | console.log('hiding', card); | |
$scope.cardCols[card.colNum].splice(card.colRank, 1); | 89 | 88 | $scope.cardCols[card.colNum].splice(card.colRank, 1); | |
$scope.updateColRanks($scope.cardCols[card.colNum]); | 90 | 89 | $scope.updateColRanks($scope.cardCols[card.colNum]); | |
console.log($scope.cardCols); | 91 | 90 | console.log($scope.cardCols); | |
}; | 92 | 91 | }; | |
93 | 92 |
scripts/CardListController.js
View file @
dc454db
angular.module('flashy.CardListController', ['ui.router', 'angular.filter', 'ngSanitize']). | 1 | 1 | angular.module('flashy.CardListController', ['ui.router', 'angular.filter', 'ngSanitize', 'flashy.DeckFactory']). | |
controller('CardListController', function($scope, $rootScope, $state, $http, $stateParams, Flashcard) { | 2 | 2 | controller('CardListController', function($scope, $rootScope, $state, $http, $stateParams, Flashcard, Deck) { | |
// cards array | 3 | 3 | // cards array | |
sectionId = $stateParams.sectionId; | 4 | 4 | sectionId = parseInt($stateParams.sectionId); | |
5 | $scope.deck = new Deck(sectionId, { | |||
6 | cardPullCallback: function(card) { | |||
7 | Materialize.toast('Pulled!', 3000); | |||
8 | }, | |||
9 | cardUnpullCallback: function(card) { | |||
10 | Materialize.toast('Unpulled!', 3000); | |||
11 | }, | |||
12 | cardHideCallback: function(card) { | |||
13 | card.is_hidden = true; | |||
14 | Materialize.toast('Hidden!', 3000); | |||
15 | }, | |||
16 | cardUnhideCallback: function(card) { | |||
17 | card.is_hidden = false; | |||
18 | Materialize.toast('Unhidden!', 3000); | |||
19 | } | |||
20 | }); | |||
$rootScope.currentSection = $rootScope.SectionResource.get({sectionId: sectionId}); | 5 | 21 | $rootScope.currentSection = $rootScope.SectionResource.get({sectionId: sectionId}); | |
$scope.cards = []; | 6 | 22 | $scope.cards = []; | |
7 | 23 | |||
$http.get('/api/sections/' + sectionId + '/flashcards/?hidden=yes'). | 8 | 24 | $http.get('/api/sections/' + sectionId + '/flashcards/?hidden=yes'). | |
success(function(data) { | 9 | 25 | success(function(data) { | |
for (i in data) $scope.cards[data[i].id] = new Flashcard(data[i], $scope.cards); | 10 | 26 | for (i in data) $scope.cards[data[i].id] = new Flashcard(data[i], $scope.deck); | |
}). | 11 | 27 | }). | |
error(function(err) { | 12 | 28 | error(function(err) { | |
console.log('pulling feed failed'); | 13 | 29 | console.log('pulling feed failed'); | |
}); | 14 | 30 | }); | |
15 | 31 | |||
$scope.viewFeed = function() { | 16 | |||
$state.go('feed', {sectionId: sectionId}); | 17 | |||
console.log('go to feed'); | 18 | |||
}; | 19 | |||
20 | ||||
21 | ||||
// unhide card | 22 | |||
$scope.unhide = function(card) { | 23 | |||
$http.post('/api/flashcards/' + card.id + '/unhide/'). | 24 | |||
success(function(data) { | 25 | |||
console.log(card.text + ' unhidden'); | 26 | |||
27 | ||||
// locally change hidden | 28 | |||
card.is_hidden = false; | 29 | |||
Materialize.toast('Unhidden', 3000, 'rounded'); | 30 | |||
}). | 31 | |||
error(function(err) { | 32 | |||
console.log('no unhide for you'); | 33 | |||
}); | 34 | |||
}; | 35 | |||
36 | ||||
// hide card | 37 | |||
$scope.hide = function(card) { | 38 | |||
$http.post('/api/flashcards/' + card.id + '/hide/'). | 39 | |||
success(function(data) { | 40 | |||
console.log(card.text + ' hidden'); | 41 | |||
42 | ||||
// locally change hidden | 43 | |||
card.is_hidden = true; | 44 | |||
Materialize.toast('Hidden', 3000, 'rounded'); | 45 | |||
}). | 46 | |||
error(function(err) { | 47 | |||
console.log('no hide for you'); | 48 | |||
}); | 49 | |||
}; | 50 | |||
51 | ||||
// pull card | 52 | |||
$scope.pull = function(card) { | 53 | |||
$http.post('/api/flashcards/' + card.id + '/pull/'). | 54 | |||
success(function(data) { | 55 | |||
console.log(card.text + ' pulled'); | 56 | |||
57 | ||||
// locally change boolean for display purposes | 58 | |||
card.is_in_deck = true; | 59 | |||
Materialize.toast('Added to Your Deck', 3000, 'rounded'); | 60 | |||
}). | 61 | |||
error(function(err) { | 62 | |||
console.log('no pull for you'); | 63 | |||
}); | 64 | |||
}; | 65 | |||
66 | ||||
// unpull card | 67 | |||
$scope.unpull = function(card) { | 68 | |||
$http.post('/api/flashcards/' + card.id + '/unpull/'). | 69 | |||
success(function(data) { | 70 | |||
console.log(card.text + ' unpulled'); | 71 | |||
72 | ||||
// local change for display purposes | 73 | |||
card.is_in_deck = false; | 74 | |||
Materialize.toast('Removed from Your Deck', 3000, 'rounded'); | 75 | |||
}). | 76 | |||
error(function(err) { | 77 | |||
console.log('no unpull for you'); | 78 | |||
}); | 79 | |||
}; | 80 | |||
81 | ||||
// flag/report card | 82 | 32 | // flag/report card | |
$scope.flag = function(card) { | 83 | 33 | $scope.flag = function(card) { | |
$http.post('/api/flashcards/' + card.id + '/report/'). | 84 | 34 | $http.post('/api/flashcards/' + card.id + '/report/'). | |
success(function(data) { | 85 | 35 | success(function(data) { | |
console.log(card.text + ' reported'); | 86 | 36 | console.log(card.text + ' reported'); | |
87 | ||||
// local change for display purposes | 88 | |||
Materialize.toast('Card Flagged', 3000, 'rounded'); | 89 | |||
}). | 90 | 37 | }). | |
error(function(err) { | 91 | 38 | error(function(err) { | |
console.log('no flag for you'); | 92 | 39 | console.log('no flag for you'); | |
}); | 93 | 40 | }); | |
}; | 94 | 41 | }; | |
95 | 42 | |||
// toggle button text from show to hide | 96 | 43 | // toggle button text from show to hide | |
$(function() { | 97 | 44 | $(function() { | |
$('#showHidden').click(function() { | 98 | 45 | $('#showHidden').click(function() { | |
$(this).text(function(i, text) { | 99 | 46 | $(this).text(function(i, text) { | |
return text === 'Show Hidden' ? 'Hide Hidden' : 'Show Hidden'; | 100 | 47 | return text === 'Show Hidden' ? 'Hide Hidden' : 'Show Hidden'; | |
}); | 101 | 48 | }); | |
}); | 102 | 49 | }); | |
}); | 103 | 50 | }); | |
104 | 51 | |||
$scope.$on('$destroy', function() { | 105 | 52 | $scope.$on('$destroy', function() { | |
$rootScope.currentSection = {}; | 106 | 53 | $rootScope.currentSection = {}; | |
$(document).off('keydown'); | 107 | 54 | $(document).off('keydown'); | |
}); | 108 | 55 | }); | |
109 | 56 | |||
$(document).ready(function() { | 110 | 57 | $(document).ready(function() { | |
$('.tooltipped').tooltip({delay: 50}); | 111 | 58 | $('.tooltipped').tooltip({delay: 50}); | |
112 | 59 | |||
//back to top | 113 | 60 | //back to top | |
var offset = 300; | 114 | 61 | var offset = 300; | |
var duration = 300; | 115 | 62 | var duration = 300; | |
$(window).scroll(function() { | 116 | 63 | $(window).scroll(function() { | |
if ($(this).scrollTop() > offset) { | 117 | 64 | if ($(this).scrollTop() > offset) { | |
$('.back-to-top').fadeIn(duration); | 118 | 65 | $('.back-to-top').fadeIn(duration); | |
} else { | 119 | 66 | } else { | |
$('.back-to-top').fadeOut(duration); | 120 | 67 | $('.back-to-top').fadeOut(duration); | |
} | 121 | 68 | } | |
}); | 122 | 69 | }); | |
123 | 70 | |||
$('.back-to-top').click(function(event) { | 124 | 71 | $('.back-to-top').click(function(event) { | |
event.preventDefault(); | 125 | 72 | event.preventDefault(); | |
$('html, body').animate({scrollTop: 0}, duration); | 126 | 73 | $('html, body').animate({scrollTop: 0}, duration); | |
return false; | 127 | 74 | return false; | |
}); | 128 | 75 | }); | |
}); | 129 | 76 | }); | |
130 | 77 | |||
// to display day of the week badges | 131 | 78 | // to display day of the week badges | |
$scope.dayofweek = function(item) { | 132 | 79 | $scope.dayofweek = function(item) { | |
var date = new Date(item.material_date); | 133 | 80 | var date = new Date(item.material_date); | |
return ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()]; | 134 | 81 | return ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()]; | |
}; | 135 | 82 | }; | |
136 | 83 | |||
// checkbox filter | 137 | 84 | // checkbox filter | |
$scope.filter = { | 138 | 85 | $scope.filter = { | |
'week1': true, | 139 | 86 | 'week1': true, | |
'week2': true, | 140 | 87 | 'week2': true, | |
'week3': true, | 141 | 88 | 'week3': true, | |
'week4': true, | 142 | 89 | 'week4': true, | |
'week5': true, | 143 | 90 | 'week5': true, | |
'week6': true, | 144 | 91 | 'week6': true, | |
'week7': true, | 145 | 92 | 'week7': true, | |
'week8': true, | 146 | 93 | 'week8': true, | |
'week9': true, | 147 | 94 | 'week9': true, | |
'week10': true, | 148 | 95 | 'week10': true, | |
}; | 149 | 96 | }; | |
150 | 97 | |||
$scope.filterByDate = function(item) { | 151 | 98 | $scope.filterByDate = function(item) { | |
var week = item.material_week_num; | 152 | 99 | var week = item.material_week_num; | |
return (week == 1 && $scope.filter['week1']) || | 153 | 100 | return (week == 1 && $scope.filter['week1']) || | |
(week == 2 && $scope.filter['week2']) || | 154 | 101 | (week == 2 && $scope.filter['week2']) || | |
(week == 3 && $scope.filter['week3']) || | 155 | 102 | (week == 3 && $scope.filter['week3']) || | |
(week == 4 && $scope.filter['week4']) || | 156 | 103 | (week == 4 && $scope.filter['week4']) || | |
(week == 5 && $scope.filter['week5']) || | 157 | 104 | (week == 5 && $scope.filter['week5']) || | |
(week == 6 && $scope.filter['week6']) || | 158 | 105 | (week == 6 && $scope.filter['week6']) || | |
(week == 7 && $scope.filter['week7']) || | 159 | 106 | (week == 7 && $scope.filter['week7']) || | |
(week == 8 && $scope.filter['week8']) || | 160 | 107 | (week == 8 && $scope.filter['week8']) || | |
(week == 9 && $scope.filter['week9']) || | 161 | 108 | (week == 9 && $scope.filter['week9']) || | |
(week == 10 && $scope.filter['week10']); | 162 | 109 | (week == 10 && $scope.filter['week10']); | |
}; | 163 | 110 | }; | |
111 | $scope.$on('$destroy', function() { | |||
112 | $scope.deck.cleanup(); | |||
113 | Flashcard.cleanup(); | |||
114 | }); | |||
164 | 115 | |||
} | 165 | 116 | } | |
). | 166 | 117 | ). | |
filter('displayCard', function($sce) { | 167 | 118 | filter('displayCard', function($sce) { |
scripts/DeckFactory.js
View file @
dc454db
angular.module('flashy.DeckFactory', ['ui.router', 'flashy.FlashcardFactory', 'ngWebSocket']). | 1 | 1 | angular.module('flashy.DeckFactory', ['ui.router', 'flashy.FlashcardFactory', 'ngWebSocket']). | |
factory('Deck', function ($http, $rootScope, $state, $websocket, Flashcard, UserService) { | 2 | 2 | factory('Deck', function ($http, $rootScope, $state, $websocket, Flashcard, UserService) { | |
3 | 3 | |||
var Deck = function (sectionId, callbacks) { | 4 | 4 | var Deck = function (sectionId, callbacks) { | |
if (!UserService.isInSection(sectionId)) { | 5 | 5 | if (!UserService.isInSection(sectionId)) { | |
console.log('user is not enrolled in ' + sectionId); | 6 | 6 | console.log('user is not enrolled in ' + sectionId); | |
$state.go('addclass'); | 7 | 7 | $state.go('addclass'); | |
} | 8 | 8 | } | |
obj = this; | 9 | 9 | obj = this; | |
this.cards = []; | 10 | 10 | this.cards = []; | |
this.section = $rootScope.SectionResource.get({sectionId: sectionId}); | 11 | 11 | this.section = $rootScope.SectionResource.get({sectionId: sectionId}); | |
12 | 12 | |||
this.ws = $websocket($rootScope.ws_host + '/ws/deck/' + sectionId + '?subscribe-user'); | 13 | 13 | this.ws = $websocket($rootScope.ws_host + '/ws/deck/' + sectionId + '?subscribe-user'); | |
this.contains = function (id) { | 14 | 14 | this.contains = function (id) { | |
return this.cards[id]; | 15 | 15 | return this.cards[id]; | |
}; | 16 | 16 | }; | |
17 | 17 | |||
this.ws.onMessage(function (message) { | 18 | 18 | this.ws.onMessage(function (message) { | |
data = JSON.parse(message.data); | 19 | 19 | data = JSON.parse(message.data); | |
console.log('message', data); | 20 | 20 | console.log('message', data); | |
card = new Flashcard(data.flashcard); | 21 | 21 | card = new Flashcard(data.flashcard); | |
if (data.event_type == 'card_pulled') { | 22 | 22 | if (data.event_type == 'card_pulled') { | |
obj.cards[card.id] = card; | 23 | 23 | obj.cards[card.id] = card; | |
if (callbacks.cardPullCallback) callbacks.cardPullCallback(card); | 24 | 24 | if (callbacks.cardPullCallback) callbacks.cardPullCallback(card); | |
} | 25 | 25 | } | |
if (data.event_type == 'card_unpulled') { | 26 | 26 | if (data.event_type == 'card_unpulled') { | |
obj.cards[card.id] = undefined; | 27 | 27 | obj.cards[card.id] = undefined; | |
if (callbacks.cardUnpullCallback) callbacks.cardUnpullCallback(card); | 28 | 28 | if (callbacks.cardUnpullCallback) callbacks.cardUnpullCallback(card); | |
} | 29 | 29 | } | |
if (data.event_type == 'card_hidden') { | 30 | 30 | if (data.event_type == 'card_hidden') { | |
if (callbacks.cardHideCallback) callbacks.cardHideCallback(card); | 31 | 31 | if (callbacks.cardHideCallback) callbacks.cardHideCallback(card); | |
} | 32 | 32 | } | |
33 | if (data.event_type == 'card_unhidden') { | |||
34 | if (callbacks.cardUnhideCallback) callbacks.cardUnhideCallback(card); | |||
35 | } | |||
}); | 33 | 36 | }); | |
this.deckPromise = $http.get('/api/sections/' + sectionId + '/deck/').success(function (data) { | 34 | 37 | this.deckPromise = $http.get('/api/sections/' + sectionId + '/deck/').success(function (data) { | |
for (i in data) obj.cards[data[i].id] = new Flashcard(data[i], obj); | 35 | 38 | for (i in data) obj.cards[data[i].id] = new Flashcard(data[i], obj); | |
console.log("got user's deck", data); | 36 | 39 | console.log("got user's deck", data); | |
}); | 37 | 40 | }); | |
this.cleanup = function () { | 38 | 41 | this.cleanup = function () { | |
this.ws.close(); | 39 | 42 | this.ws.close(); | |
}; | 40 | 43 | }; | |
this.forEach = this.cards.forEach; | 41 | 44 | this.forEach = this.cards.forEach; |
scripts/FeedController.js
View file @
dc454db
angular.module('flashy.FeedController', | 1 | 1 | angular.module('flashy.FeedController', | |
['ui.router', | 2 | 2 | ['ui.router', | |
'ngAnimate', | 3 | 3 | 'ngAnimate', | |
'ngWebSocket', | 4 | 4 | 'ngWebSocket', | |
'contenteditable', | 5 | 5 | 'contenteditable', | |
'flashy.DeckFactory']).controller('FeedController', | 6 | 6 | 'flashy.DeckFactory']).controller('FeedController', | |
function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard, Deck) { | 7 | 7 | function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard, Deck) { | |
angular.module('flashy.CardGridController').CardGridController.apply(this, arguments); | 8 | 8 | angular.module('flashy.CardGridController').CardGridController.apply(this, arguments); | |
9 | 9 | |||
(function drawCols() { | 10 | 10 | (function drawCols() { | |
$interval(function() { | 11 | 11 | $interval(function() { | |
if ($scope.cardColsShow != $scope.cardCols) { | 12 | 12 | if ($scope.cardColsShow != $scope.cardCols) { | |
$scope.cardColsShow = $scope.cardCols; | 13 | 13 | $scope.cardColsShow = $scope.cardCols; | |
console.log('interval'); | 14 | 14 | console.log('interval'); | |
} | 15 | 15 | } | |
}, 1000); | 16 | 16 | }, 1000); | |
}()); | 17 | 17 | }()); | |
18 | 18 | |||
$scope.updateCardScore = function(card) { | 19 | 19 | $scope.updateCardScore = function(card) { | |
console.log($scope.cardCols, card); | 20 | 20 | console.log($scope.cardCols, card); | |
// if no colNum is attached, then this doesn't exist on the feed yet | 21 | 21 | // if no colNum is attached, then this doesn't exist on the feed yet | |
if (!card.colNum) return; | 22 | 22 | if (!card.colNum) return; | |
$scope.cardCols[card.colNum].sort(function(a, b) { | 23 | 23 | $scope.cardCols[card.colNum].sort(function(a, b) { | |
return b.score - a.score; | 24 | 24 | return b.score - a.score; | |
}); | 25 | 25 | }); | |
$scope.updateColRanks($scope.cardCols[card.colNum]); | 26 | 26 | $scope.updateColRanks($scope.cardCols[card.colNum]); | |
}; | 27 | 27 | }; | |
28 | 28 | |||
$scope.feed_ws = $websocket($scope.ws_host + '/ws/feed/' + $scope.sectionId + '?subscribe-broadcast'); | 29 | 29 | $scope.feed_ws = $websocket($scope.ws_host + '/ws/feed/' + sectionId + '?subscribe-broadcast'); | |
$scope.feed_ws.onMessage(function(e) { | 30 | 30 | $scope.feed_ws.onMessage(function(e) { | |
data = JSON.parse(e.data); | 31 | 31 | data = JSON.parse(e.data); | |
console.log('message', data); | 32 | 32 | console.log('message', data); | |
if (data.event_type == 'new_card') { | 33 | 33 | if (data.event_type == 'new_card') { | |
$scope.addCardToGrid(new Flashcard(data.flashcard, $scope.deck)); | 34 | 34 | $scope.addCardToGrid(new Flashcard(data.flashcard, $scope.deck)); | |
} else if (data.event_type == 'score_change') { | 35 | 35 | } else if (data.event_type == 'score_change') { | |
card = new Flashcard(data.flashcard); | 36 | 36 | card = new Flashcard(data.flashcard); | |
card.score = data.flashcard.score; | 37 | 37 | card.score = data.flashcard.score; | |
$scope.updateCardScore(card); | 38 | 38 | $scope.updateCardScore(card); | |
} | 39 | 39 | } | |
}); | 40 | 40 | }); | |
41 | 41 | |||
$scope.pushCard = function() { | 42 | 42 | $scope.pushCard = function() { | |
var myCard = { | 43 | 43 | var myCard = { | |
// we can't trim this string because it'd mess up the blanks. Something to fix. | 44 | 44 | // we can't trim this string because it'd mess up the blanks. Something to fix. | |
'text': $('#new-card-input').text(), | 45 | 45 | 'text': $('#new-card-input').text(), | |
'mask': $scope.newCardBlanks, | 46 | 46 | 'mask': $scope.newCardBlanks, | |
section: $scope.section.id | 47 | 47 | section: $scope.section.id | |
}; | 48 | 48 | }; | |
if (myCard.text == '') { | 49 | 49 | if (myCard.text == '') { | |
console.log('blank flashcard not pushed:' + myCard.text); | 50 | 50 | console.log('blank flashcard not pushed:' + myCard.text); | |
return closeNewCard(); | 51 | 51 | return closeNewCard(); | |
} | 52 | 52 | } | |
$http.post('/api/flashcards/', myCard). | 53 | 53 | $http.post('/api/flashcards/', myCard). | |
success(function(data) { | 54 | 54 | success(function(data) { | |
console.log('flashcard pushed: ' + myCard.text); | 55 | 55 | console.log('flashcard pushed: ' + myCard.text); | |
if (!UserService.hasVerifiedEmail()) { | 56 | 56 | if (!UserService.hasVerifiedEmail()) { | |
Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000); | 57 | 57 | Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000); | |
} | 58 | 58 | } | |
}); | 59 | 59 | }); | |
return $scope.closeNewCardModal(); | 60 | 60 | return $scope.closeNewCardModal(); | |
}; | 61 | 61 | }; | |
62 | 62 | |||
/* Key bindings for the whole feed window. Hotkey it up! */ | 63 | 63 | /* Key bindings for the whole feed window. Hotkey it up! */ | |
var listenForC = true; | 64 | 64 | var listenForC = true; | |
65 | 65 | |||
// Need to pass these options into openmodal and leanmodal, | 66 | 66 | // Need to pass these options into openmodal and leanmodal, | |
// otherwise the ready handler doesn't get called | 67 | 67 | // otherwise the ready handler doesn't get called | |
68 | 68 | |||
modal_options = { | 69 | 69 | modal_options = { | |
dismissible: true, // Modal can be dismissed by clicking outside of the modal | 70 | 70 | dismissible: true, // Modal can be dismissed by clicking outside of the modal | |
opacity: 0, // Opacity of modal background | 71 | 71 | opacity: 0, // Opacity of modal background | |
in_duration: 300, // Transition in duration | 72 | 72 | in_duration: 300, // Transition in duration | |
out_duration: 200, // Transition out duration | 73 | 73 | out_duration: 200, // Transition out duration | |
ready: function() { | 74 | 74 | ready: function() { | |
$('#new-card-input').focus(); | 75 | 75 | $('#new-card-input').focus(); | |
document.execCommand('selectAll', false, null); | 76 | 76 | document.execCommand('selectAll', false, null); | |
} | 77 | 77 | } | |
}; | 78 | 78 | }; | |
79 | 79 | |||
$(document).keydown(function(e) { | 80 | 80 | $(document).keydown(function(e) { | |
var keyed = e.which; | 81 | 81 | var keyed = e.which; | |
if (keyed == 67 && listenForC) { // "c" for compose | 82 | 82 | if (keyed == 67 && listenForC) { // "c" for compose | |
$scope.openNewCardModal(); | 83 | 83 | $scope.openNewCardModal(); | |
e.preventDefault(); | 84 | 84 | e.preventDefault(); | |
return false; | 85 | 85 | return false; | |
} else if (keyed == 27) { // clear on ESC | 86 | 86 | } else if (keyed == 27) { // clear on ESC | |
$scope.closeNewCardModal(); | 87 | 87 | $scope.closeNewCardModal(); | |
} | 88 | 88 | } | |
}); | 89 | 89 | }); | |
90 | 90 | |||
$scope.openNewCardModal = function() { | 91 | 91 | $scope.openNewCardModal = function() { | |
$('#newCard').openModal(modal_options); | 92 | 92 | $('#newCard').openModal(modal_options); | |
listenForC = false; | 93 | 93 | listenForC = false; | |
$('#new-card-input').html('Write a flashcard!'); | 94 | 94 | $('#new-card-input').html('Write a flashcard!'); | |
}; | 95 | 95 | }; | |
96 | 96 | |||
$scope.closeNewCardModal = function() { | 97 | 97 | $scope.closeNewCardModal = function() { | |
listenForC = true; | 98 | 98 | listenForC = true; | |
$('#new-card-input').html('').blur(); | 99 | 99 | $('#new-card-input').html('').blur(); | |
$('#newCard').closeModal(modal_options); | 100 | 100 | $('#newCard').closeModal(modal_options); | |
}; | 101 | 101 | }; | |
102 | 102 | |||
$('.tooltipped').tooltip({delay: 50}); | 103 | 103 | $('.tooltipped').tooltip({delay: 50}); | |
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | 104 | 104 | // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | |
$('.modal-trigger').leanModal(modal_options); | 105 | 105 | $('.modal-trigger').leanModal(modal_options); | |
$('#new-card-input').on('keydown', function(e) { | 106 | 106 | $('#new-card-input').on('keydown', function(e) { | |
if (e.which == 13) { | 107 | 107 | if (e.which == 13) { | |
e.preventDefault(); | 108 | 108 | e.preventDefault(); | |
if ($scope.submit_enabled) { | 109 | 109 | if ($scope.submit_enabled) { | |
$scope.pushCard(); | 110 | 110 | $scope.pushCard(); | |
listenForC = true; | 111 | 111 | listenForC = true; | |
} | 112 | 112 | } | |
return false; | 113 | 113 | return false; | |
} else { | 114 | 114 | } else { | |
115 | 115 | |||
} | 116 | 116 | } | |
}); | 117 | 117 | }); | |
$('button#blank-selected').click(function() { | 118 | 118 | $('button#blank-selected').click(function() { | |
console.log(window.getSelection()); | 119 | 119 | console.log(window.getSelection()); | |
document.execCommand('bold'); | 120 | 120 | document.execCommand('bold'); | |
}); | 121 | 121 | }); | |
$scope.newCardBlanks = []; | 122 | 122 | $scope.newCardBlanks = []; | |
$scope.refreshNewCardInput = function() { | 123 | 123 | $scope.refreshNewCardInput = function() { | |
$scope.newCardText = $('#new-card-input').text(); | 124 | 124 | $scope.newCardText = $('#new-card-input').text(); | |
$scope.submit_enabled = $scope.newCardText.length >= 5 && $scope.newCardText.length <= 160; | 125 | 125 | $scope.submit_enabled = $scope.newCardText.length >= 5 && $scope.newCardText.length <= 160; | |
var i = 0; | 126 | 126 | var i = 0; | |
$scope.newCardBlanks = []; | 127 | 127 | $scope.newCardBlanks = []; | |
$('#new-card-input')[0].childNodes.forEach(function(node) { | 128 | 128 | $('#new-card-input')[0].childNodes.forEach(function(node) { | |
node = $(node)[0]; | 129 | 129 | node = $(node)[0]; | |
if (node.tagName == 'B') { | 130 | 130 | if (node.tagName == 'B') { | |
var text = $(node).text(); | 131 | 131 | var text = $(node).text(); | |
var leftspaces = 0, rightspaces = 0; | 132 | 132 | var leftspaces = 0, rightspaces = 0; | |
// awful way to find the first non-space character from the left or the right. thanks.js | 133 | 133 | // awful way to find the first non-space character from the left or the right. thanks.js | |
while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++; | 134 | 134 | while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++; | |
while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++; | 135 | 135 | while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++; | |
console.log(leftspaces, text.length); | 136 | 136 | console.log(leftspaces, text.length); | |
if (leftspaces != text.length) $scope.newCardBlanks.push([i + leftspaces, i + text.length - rightspaces]); | 137 | 137 | if (leftspaces != text.length) $scope.newCardBlanks.push([i + leftspaces, i + text.length - rightspaces]); | |
i += text.length; | 138 | 138 | i += text.length; | |
} else if (!node.data) { | 139 | 139 | } else if (!node.data) { | |
i += $(node).text().length; | 140 | 140 | i += $(node).text().length; | |
} else { | 141 | 141 | } else { | |
i += node.data.length; | 142 | 142 | i += node.data.length; | |
} | 143 | 143 | } | |
}); | 144 | 144 | }); | |
$scope.newCardBlanks.sort(function(a, b) { | 145 | 145 | $scope.newCardBlanks.sort(function(a, b) { | |
return a[0] - b[0]; | 146 | 146 | return a[0] - b[0]; | |
}); | 147 | 147 | }); | |
i = 0; | 148 | 148 | i = 0; | |
newtext = ''; | 149 | 149 | newtext = ''; | |
$scope.newCardBlanks.forEach(function(blank) { | 150 | 150 | $scope.newCardBlanks.forEach(function(blank) { | |
newtext += $scope.newCardText.slice(i, blank[0]); | 151 | 151 | newtext += $scope.newCardText.slice(i, blank[0]); | |
newtext += '<b>' + $scope.newCardText.slice(blank[0], blank[1]) + '</b>'; | 152 | 152 | newtext += '<b>' + $scope.newCardText.slice(blank[0], blank[1]) + '</b>'; | |
i = blank[1]; | 153 | 153 | i = blank[1]; | |
}); | 154 | 154 | }); | |
newtext += $scope.newCardText.slice(i); | 155 | 155 | newtext += $scope.newCardText.slice(i); | |
//$scope.newCardFormattedText = newtext; | 156 | 156 | //$scope.newCardFormattedText = newtext; | |
}; | 157 | 157 | }; | |
$scope.shuffleCards = function() { | 158 | 158 | $scope.shuffleCards = function() { | |
$timeout(function() { | 159 | 159 | $timeout(function() { | |
(function(o) { | 160 | 160 | (function(o) { | |
for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); | 161 | 161 | for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); | |
return o; | 162 | 162 | return o; | |
})($scope.cardCols[0]); | 163 | 163 | })($scope.cardCols[0]); | |
}); | 164 | 164 | }); | |
}; | 165 | 165 | }; | |
$scope.$on('$destroy', function() { | 166 | 166 | $scope.$on('$destroy', function() { | |
$scope.feed_ws.close(); | 167 | 167 | $scope.feed_ws.close(); | |
}); | 168 | 168 | }); | |
return $http.get('/api/sections/' + $scope.sectionId + '/feed/'). | 169 | 169 | return $http.get('/api/sections/' + sectionId + '/feed/'). | |
success(function(data) { | 170 | 170 | success(function(data) { | |
console.log(data); | 171 | 171 | console.log(data); | |
$scope.cards = data.map(function(card) { | 172 | 172 | $scope.cards = data.map(function(card) { |
scripts/FlashcardFactory.js
View file @
dc454db
angular.module('flashy.FlashcardFactory', ['ui.router']). | 1 | 1 | angular.module('flashy.FlashcardFactory', ['ui.router']). | |
factory('Flashcard', function ($http) { | 2 | 2 | factory('Flashcard', function ($http) { | |
var FlashcardCache = []; | 3 | 3 | var FlashcardCache = []; | |
4 | var Deck = null; | |||
var Flashcard = function (data, deck) { | 4 | 5 | var Flashcard = function (data, deck) { | |
if (typeof data == 'number') return FlashcardCache[data]; | 5 | 6 | if (typeof data == 'number') return FlashcardCache[data]; | |
if (FlashcardCache[data.id]) return FlashcardCache[data.id]; | 6 | 7 | if (FlashcardCache[data.id]) return FlashcardCache[data.id]; | |
if (deck) this.deck = deck; | 7 | 8 | if (!Deck && deck) Deck = deck; | |
for (var k in data) this[k] = data[k]; | 8 | 9 | for (var k in data) this[k] = data[k]; | |
this.textPieces = []; | 9 | 10 | this.textPieces = []; | |
this.mask.sort(function (a, b) { | 10 | 11 | this.mask.sort(function (a, b) { | |
return a[0] - b[0]; | 11 | 12 | return a[0] - b[0]; | |
}); | 12 | 13 | }); | |
var i = 0; | 13 | 14 | var i = 0; | |
this.mask.forEach(function (blank) { | 14 | 15 | this.mask.forEach(function (blank) { | |
this.textPieces.push({text: this.text.slice(i, blank[0])}); | 15 | 16 | this.textPieces.push({text: this.text.slice(i, blank[0])}); | |
this.textPieces.push({text: this.text.slice(blank[0], blank[1]), blank: true}); | 16 | 17 | this.textPieces.push({text: this.text.slice(blank[0], blank[1]), blank: true}); | |
i = blank[1]; | 17 | 18 | i = blank[1]; | |
}, this); | 18 | 19 | }, this); | |
this.textPieces.push({text: this.text.slice(i)}); | 19 | 20 | this.textPieces.push({text: this.text.slice(i)}); | |
this.formatted_text = ''; | 20 | 21 | this.formatted_text = ''; | |
for (i in this.textPieces) { | 21 | 22 | for (i in this.textPieces) { | |
p = this.textPieces[i]; | 22 | 23 | p = this.textPieces[i]; | |
this.formatted_text += p.blank ? '<b>' + p.text + '</b>' : p.text; | 23 | 24 | this.formatted_text += p.blank ? '<b>' + p.text + '</b>' : p.text; | |
} | 24 | 25 | } | |
FlashcardCache[this.id] = this; | 25 | 26 | FlashcardCache[this.id] = this; | |
}; | 26 | 27 | }; | |
27 | 28 | |||
Flashcard.prototype.isInDeck = function () { | 28 | 29 | Flashcard.prototype.isInDeck = function () { | |
return !(typeof this.deck.contains(this.id) === 'undefined'); | 29 | 30 | return !(typeof Deck.contains(this.id) === 'undefined'); | |
}; | 30 | 31 | }; | |
Flashcard.prototype.pullUnpull = function () { | 31 | 32 | Flashcard.prototype.pullUnpull = function () { | |
if (this.isInDeck()) this.unpull(); | 32 | 33 | if (this.isInDeck()) this.unpull(); | |
else this.pull(); | 33 | 34 | else this.pull(); | |
}; | 34 | 35 | }; | |
Flashcard.prototype.pull = function () { | 35 | 36 | Flashcard.prototype.pull = function () { | |
if (this.isInDeck()) return console.log('Not pulling', this.id, "because it's already in deck"); | 36 | 37 | if (this.isInDeck()) return console.log('Not pulling', this.id, "because it's already in deck"); | |
return $http.post('/api/flashcards/' + this.id + '/pull/'); | 37 | 38 | return $http.post('/api/flashcards/' + this.id + '/pull/'); | |
}; | 38 | 39 | }; | |
Flashcard.prototype.unpull = function () { | 39 | 40 | Flashcard.prototype.unpull = function () { | |
if (!this.isInDeck()) return console.log('Not unpulling', this.id, "because it's not in deck"); | 40 | 41 | if (!this.isInDeck()) return console.log('Not unpulling', this.id, "because it's not in deck"); | |
return $http.post('/api/flashcards/' + this.id + '/unpull/'); | 41 | 42 | return $http.post('/api/flashcards/' + this.id + '/unpull/'); | |
}; | 42 | 43 | }; | |
Flashcard.prototype.hide = function () { | 43 | 44 | Flashcard.prototype.hide = function () { | |
return $http.post('/api/flashcards/' + this.id + '/hide/'); | 44 | 45 | return $http.post('/api/flashcards/' + this.id + '/hide/'); | |
46 | }; | |||
47 | Flashcard.prototype.unhide = function () { | |||
48 | return $http.post('/api/flashcards/' + this.id + '/unhide/'); | |||
49 | }; | |||
50 | Flashcard.cleanup = function () { | |||
51 | Deck = null; | |||
52 | FlashcardCache = []; | |||
}; | 45 | 53 | }; | |
46 | 54 | |||
return Flashcard; | 47 | 55 | return Flashcard; | |
}); | 48 | 56 | }); |
templates/cardlist.html
View file @
dc454db
<body> | 1 | 1 | <body> | |
<div class="row"> | 2 | 2 | <div class="row"> | |
<a class="btn" id="showHidden" ng-click="show = !show" style="margin-top: 15px">Show Hidden</a> | 3 | 3 | <a class="btn" id="showHidden" ng-click="show = !show" style="margin-top: 15px">Show Hidden</a> | |
4 | 4 | |||
<div class="input-field col s6 right"> | 5 | 5 | <div class="input-field col s6 right"> | |
<i class="mdi-action-search prefix"></i> | 6 | 6 | <i class="mdi-action-search prefix"></i> | |
<input id="search" type="text" class="validate" ng-model="searchText"/> | 7 | 7 | <input id="search" type="text" class="validate" ng-model="searchText"/> | |
<label for="search">Search</label> | 8 | 8 | <label for="search">Search</label> | |
</div> | 9 | |||
</div> | 10 | 9 | </div> | |
10 | </div> | |||
11 | 11 | |||
<div class="row"> | 12 | 12 | <div class="row"> | |
<form> | 13 | 13 | <form> | |
<div class="col s12"> | 14 | 14 | <div class="col s12"> | |
<div class="col s2"> | 15 | 15 | <div class="col s2"> | |
<input type="checkbox" class="filled-in" id="weekOneCheck" ng-model="filter['week1']"/> | 16 | 16 | <input type="checkbox" class="filled-in" id="weekOneCheck" ng-model="filter['week1']"/> | |
<label for="weekOneCheck">Week One</label> | 17 | 17 | <label for="weekOneCheck">Week One</label> | |
</div> | 18 | |||
<div class="col s2"> | 19 | |||
<input type="checkbox" class="filled-in" id="weekTwoCheck" ng-model="filter['week2']"/> | 20 | |||
<label for="weekTwoCheck">Week Two</label> | 21 | |||
</div> | 22 | |||
<div class="col s2"> | 23 | |||
<input type="checkbox" class="filled-in" id="weekThreeCheck" ng-model="filter['week3']"/> | 24 | |||
<label for="weekThreeCheck">Week Three</label> | 25 | |||
</div> | 26 | |||
<div class="col s2"> | 27 | |||
<input type="checkbox" class="filled-in" id="weekFourCheck" ng-model="filter['week4']"/> | 28 | |||
<label for="weekFourCheck">Week Four</label> | 29 | |||
</div> | 30 | |||
<div class="col s2"> | 31 | |||
<input type="checkbox" class="filled-in" id="weekFiveCheck" ng-model="filter['week5']"/> | 32 | |||
<label for="weekFiveCheck">Week Five</label> | 33 | |||
</div> | 34 | |||
</div> | 35 | 18 | </div> | |
<div class="col s12"> | 36 | 19 | <div class="col s2"> | |
<div class="col s2"> | 37 | 20 | <input type="checkbox" class="filled-in" id="weekTwoCheck" ng-model="filter['week2']"/> | |
<input type="checkbox" class="filled-in" id="weekSixCheck" ng-model="filter['week6']"/> | 38 | 21 | <label for="weekTwoCheck">Week Two</label> | |
<label for="weekSixCheck">Week Six</label> | 39 | |||
</div> | 40 | |||
<div class="col s2"> | 41 | |||
<input type="checkbox" class="filled-in" id="weekSevenCheck" ng-model="filter['week7']"/> | 42 | |||
<label for="weekSevenCheck">Week Seven</label> | 43 | |||
</div> | 44 | |||
<div class="col s2"> | 45 | |||
<input type="checkbox" class="filled-in" id="weekEightCheck" ng-model="filter['week8']"/> | 46 | |||
<label for="weekEightCheck">Week Eight</label> | 47 | |||
</div> | 48 | |||
<div class="col s2"> | 49 | |||
<input type="checkbox" class="filled-in" id="weekNineCheck" ng-model="filter['week9']"/> | 50 | |||
<label for="weekNineCheck">Week Nine</label> | 51 | |||
</div> | 52 | |||
<div class="col s2"> | 53 | |||
<input type="checkbox" class="filled-in" id="weekTenCheck" ng-model="filter['week10']"/> | 54 | |||
<label for="weekTenCheck">Week Ten</label> | 55 | |||
</div> | 56 | |||
</div> | 57 | 22 | </div> | |
</form> | 58 | 23 | <div class="col s2"> | |
</div> | 59 | 24 | <input type="checkbox" class="filled-in" id="weekThreeCheck" ng-model="filter['week3']"/> | |
25 | <label for="weekThreeCheck">Week Three</label> | |||
26 | </div> | |||
27 | <div class="col s2"> | |||
28 | <input type="checkbox" class="filled-in" id="weekFourCheck" ng-model="filter['week4']"/> | |||
29 | <label for="weekFourCheck">Week Four</label> | |||
30 | </div> | |||
31 | <div class="col s2"> | |||
32 | <input type="checkbox" class="filled-in" id="weekFiveCheck" ng-model="filter['week5']"/> | |||
33 | <label for="weekFiveCheck">Week Five</label> | |||
34 | </div> | |||
35 | </div> | |||
36 | <div class="col s12"> | |||
37 | <div class="col s2"> | |||
38 | <input type="checkbox" class="filled-in" id="weekSixCheck" ng-model="filter['week6']"/> | |||
39 | <label for="weekSixCheck">Week Six</label> | |||
40 | </div> | |||
41 | <div class="col s2"> | |||
42 | <input type="checkbox" class="filled-in" id="weekSevenCheck" ng-model="filter['week7']"/> | |||
43 | <label for="weekSevenCheck">Week Seven</label> | |||
44 | </div> | |||
45 | <div class="col s2"> | |||
46 | <input type="checkbox" class="filled-in" id="weekEightCheck" ng-model="filter['week8']"/> | |||
47 | <label for="weekEightCheck">Week Eight</label> | |||
48 | </div> | |||
49 | <div class="col s2"> | |||
50 | <input type="checkbox" class="filled-in" id="weekNineCheck" ng-model="filter['week9']"/> | |||
51 | <label for="weekNineCheck">Week Nine</label> | |||
52 | </div> | |||
53 | <div class="col s2"> | |||
54 | <input type="checkbox" class="filled-in" id="weekTenCheck" ng-model="filter['week10']"/> | |||
55 | <label for="weekTenCheck">Week Ten</label> | |||
56 | </div> | |||
57 | </div> | |||
58 | </form> | |||
59 | </div> | |||
60 | 60 | |||
<div class="list" style="padding: 0px 25px"> | 61 | 61 | <div class="list" style="padding: 0px 25px"> | |
<ul class="collection" | 62 | 62 | <ul class="collection" | |
ng-repeat="(weeknum, week_cards) in cards | filter:searchText | filter:filterByDate | groupBy: 'material_week_num'"> | 63 | 63 | ng-repeat="(weeknum, week_cards) in cards | filter:searchText | filter:filterByDate | groupBy: 'material_week_num'"> | |
<li class="collection-header"><h3>Week {{weeknum}}</h3></li> | 64 | 64 | <li class="collection-header"><h3>Week {{weeknum}}</h3></li> | |
<li class="collection-item" ng-click="expand = !expand" ng-repeat="card in week_cards" ng-show="show || !card.is_hidden"> | 65 | 65 | <li class="collection-item" ng-click="expand = !expand" ng-repeat="card in week_cards" | |
<div> | 66 | 66 | ng-show="show || !card.is_hidden"> | |
<span ng-bind-html="card | displayCard"></span> | 67 | 67 | <i ng-show="card.isInDeck()" class="mdi-action-done small green-text"></i> | |
<span class="badge">{{dayofweek(card)}}</span> | 68 | 68 | <span ng-bind-html="card | displayCard"></span> | |
<p class="right-align" ng-show="expand"> | 69 | 69 | <span class="badge">{{dayofweek(card)}}</span> | |
<a href="" class="tooltipped" ng-click="pull(card)" ng-show="!card.is_in_deck" data-position="bottom" data-delay="50" data-tooltip="Add to Deck"> | 70 | |||
<i class="mdi-content-add-circle-outline small"></i></a> | 71 | |||
<a href="" class="tooltipped" ng-click="unpull(card)" ng-show="card.is_in_deck" data-position="bottom" data-delay="50" data-tooltip="Add to Deck"> | 72 | |||
<i class="mdi-content-remove-circle-outline small"></i></a> | 73 | |||
<a href="" class="tooltipped" ng-click="hide(card)" ng-show="!card.is_hidden" data-position="bottom" data-delay="50" data-tooltip="Hide"> | 74 | |||
<i class="mdi-action-visibility-off small"></i></a> | 75 | |||
<a href="" class="tooltipped" ng-click="unhide(card)" ng-show="card.is_hidden" data-position="bottom" data-delay="50" data-tooltip="Unhide"> | 76 | |||
<i class="mdi-action-visibility small"></i></a> | 77 | |||
<a href="" ng-click="flag(card)" data-position="bottom" data-delay="50" data-tooltip="Flag"> | 78 | |||
<i class="mdi-content-flag small"></i></a> | 79 | |||
</p> | 80 | |||
</div> | 81 | |||
</li> | 82 | |||
</ul> | 83 | |||
</div> | 84 | |||
85 | 70 | |||
71 | <p class="right-align" ng-show="expand"> | |||
72 | <a href="" class="tooltipped" ng-click="card.pull()" ng-show="!card.isInDeck()" data-position="bottom" | |||
73 | data-delay="50" data-tooltip="Add to Deck"> | |||
74 | <i class="mdi-content-add-circle-outline small"></i></a> | |||
75 | <a href="" class="tooltipped" ng-click="card.unpull()" ng-show="card.isInDeck()" data-position="bottom" | |||
76 | data-delay="50" data-tooltip="Add to Deck"> | |||
77 | <i class="mdi-content-remove-circle-outline small"></i></a> | |||
78 | <a href="" class="tooltipped" ng-click="card.hide()" ng-show="!card.is_hidden" data-position="bottom" | |||
79 | data-delay="50" data-tooltip="Hide"> | |||
80 | <i class="mdi-action-visibility-off small"></i></a> | |||
81 | <a href="" class="tooltipped" ng-click="card.unhide()" ng-show="card.is_hidden" data-position="bottom" | |||
82 | data-delay="50" data-tooltip="Unhide"> | |||
83 | <i class="mdi-action-visibility small"></i></a> | |||
84 | <a href="" ng-click="flag(card)" data-position="bottom" data-delay="50" data-tooltip="Flag"> | |||
85 | <i class="mdi-content-flag small"></i></a> | |||
86 | </p> | |||
87 | </li> | |||
88 | </ul> | |||
89 | </div> | |||
86 | 90 | |||
<div class="fixed-action-btn back-to-top" style="bottom: 45px; right: 24px; display: none;"> | 87 | 91 | ||
<a class="btn-floating btn-large"> | 88 | 92 | <div class="fixed-action-btn back-to-top" style="bottom: 45px; right: 24px; display: none;"> | |
<i class="mdi-editor-publish medium"></i> | 89 | 93 | <a class="btn-floating btn-large"> | |
</a> | 90 | 94 | <i class="mdi-editor-publish medium"></i> | |
</div> | 91 | 95 | </a> | |
96 | </div> | |||
</body> | 92 | 97 | </body> | |
93 | 98 | |||