Commit 0aff91dfe2aacddf5aa14b3be89ce1dc7e4bb92c

Authored by Chung Wang

Merge branch 'master' of https://git.ucsd.edu/110swag/flashy-frontend

Showing 15 changed files Inline Diff

angular.module('flashy', [ 1 1 angular.module('flashy', [
'flashy.LoginController', 2 2 'flashy.LoginController',
'flashy.RootController', 3 3 'flashy.RootController',
'flashy.FeedController', 4 4 'flashy.FeedController',
'flashy.DeckController', 5 5 'flashy.DeckController',
'flashy.ClassAddController', 6 6 'flashy.ClassAddController',
'flashy.ClassDropController', 7 7 'flashy.ClassDropController',
'flashy.RequestResetController', 8 8 'flashy.RequestResetController',
'flashy.StudyController', 9 9 'flashy.StudyController',
'flashy.UserService', 10 10 'flashy.UserService',
'flashy.FlashcardDirective', 11 11 'flashy.FlashcardDirective',
'flashy.FlashcardFactory', 12 12 'flashy.FlashcardFactory',
'flashy.ResetPasswordController', 13 13 'flashy.ResetPasswordController',
'flashy.VerifyEmailController', 14 14 'flashy.VerifyEmailController',
'flashy.CardListController', 15 15 'flashy.CardListController',
'flashy.HelpController', 16 16 'flashy.HelpController',
'flashy.SettingsController', 17 17 'flashy.SettingsController',
'ngCookies']). 18 18 'ngCookies']).
config(function($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) { 19 19 config(function($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) {
'use strict'; 20 20 'use strict';
$httpProvider.defaults.withCredentials = true; 21 21 $httpProvider.defaults.withCredentials = true;
$httpProvider.defaults.xsrfCookieName = 'csrftoken'; 22 22 $httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; 23 23 $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
$resourceProvider.defaults.stripTrailingSlashes = false; 24 24 $resourceProvider.defaults.stripTrailingSlashes = false;
var arrayMethods = Object.getOwnPropertyNames(Array.prototype); 25 25 var arrayMethods = Object.getOwnPropertyNames(Array.prototype);
arrayMethods.forEach(attachArrayMethodsToNodeList); 26 26 arrayMethods.forEach(attachArrayMethodsToNodeList);
function attachArrayMethodsToNodeList(methodName) { 27 27 function attachArrayMethodsToNodeList(methodName) {
if (methodName !== 'length') { 28 28 if (methodName !== 'length') {
NodeList.prototype[methodName] = Array.prototype[methodName]; 29 29 NodeList.prototype[methodName] = Array.prototype[methodName];
} 30 30 }
} 31 31 }
32 32
$httpProvider.interceptors.push(function($q, $rootScope) { 33 33 $httpProvider.interceptors.push(function($q, $rootScope) {
return { 34 34 return {
'responseError': function(rejection) { // need a better redirect 35 35 'responseError': function(rejection) { // need a better redirect
if (rejection.status >= 500) { 36 36 if (rejection.status >= 500) {
console.log('got error'); 37 37 console.log('got error');
console.log(rejection); 38 38 console.log(rejection);
$rootScope.$broadcast('server_error', rejection); 39 39 $rootScope.$broadcast('server_error', rejection);
} 40 40 }
if (rejection.status == 403) { 41 41 if (rejection.status == 403) {
console.log(rejection); 42 42 console.log(rejection);
if (rejection.data && rejection.data.detail == 'Please verify your email before continuing') { 43 43 if (rejection.data && rejection.data.detail == 'Please verify your email before continuing') {
UserService.showLockedMessage(); 44 44 UserService.showLockedMessage();
UserService.logout(); 45 45 UserService.logout();
} 46 46 }
} 47 47 }
if (rejection.status == 429) { 48 48 if (rejection.status == 429) {
console.log(rejection); 49 49 console.log(rejection);
Materialize.toast('Your enthusiasm is appreciated, but we ask that you slow down a little!', 4000); 50 50 Materialize.toast('Your enthusiasm is appreciated, but we ask that you slow down a little!', 4000);
} 51 51 }
return $q.reject(rejection); 52 52 return $q.reject(rejection);
} 53 53 }
}; 54 54 };
}); 55 55 });
$locationProvider.html5Mode(true); 56 56 $locationProvider.html5Mode(true);
$urlRouterProvider.otherwise('/404'); 57 57 $urlRouterProvider.otherwise('/404');
var auth_resolve = { 58 58 var auth_resolve = {
authorize: function($q, $rootScope, $state, $stateParams, UserService) { 59 59 authorize: function($q, $rootScope, $state, $stateParams, UserService) {
console.log('do we need to authorize a user for', $rootScope.nextState.name); 60 60 console.log('do we need to authorize a user for', $rootScope.nextState.name);
if (UserService.noAuthRequired($rootScope.nextState)) { 61 61 if (UserService.noAuthRequired($rootScope.nextState)) {
console.log('no auth required for', $rootScope.nextState.name); 62 62 console.log('no auth required for', $rootScope.nextState.name);
return UserService.getUserData(); 63 63 return UserService.getUserData();
} 64 64 }
console.log('resolving user before continuing to ' + $rootScope.nextState.name); 65 65 console.log('resolving user before continuing to ' + $rootScope.nextState.name);
var redirectAsNeeded = function() { 66 66 var redirectAsNeeded = function() {
if (!UserService.isLoggedIn()) { 67 67 if (!UserService.isLoggedIn()) {
console.log(UserService.getUserData()); 68 68 console.log(UserService.getUserData());
console.log('making the user log in'); 69 69 console.log('making the user log in');
$state.go('login'); 70 70 $state.go('login');
} 71 71 }
if (!UserService.authorizedFor($rootScope.nextState, $rootScope.nextStateParams)) { 72 72 if (!UserService.authorizedFor($rootScope.nextState, $rootScope.nextStateParams)) {
console.log('user not authorized for ' + $rootScope.nextState.name); 73 73 console.log('user not authorized for ' + $rootScope.nextState.name);
$state.go('addclass'); 74 74 $state.go('addclass');
} 75 75 }
}; 76 76 };
if (UserService.isResolved()) return redirectAsNeeded(); 77 77 if (UserService.isResolved()) return redirectAsNeeded();
return UserService.getUserData().then(redirectAsNeeded); 78 78 return UserService.getUserData().then(redirectAsNeeded);
} 79 79 }
}; 80 80 };
$stateProvider. 81 81 $stateProvider.
state('login', { 82 82 state('login', {
resolve: auth_resolve, 83 83 resolve: auth_resolve,
url: '/login', 84 84 url: '/login',
templateUrl: 'templates/login.html', 85 85 templateUrl: 'templates/login.html',
controller: 'LoginController' 86 86 controller: 'LoginController'
}). 87 87 }).
state('root', { 88 88 state('root', {
resolve: auth_resolve, 89 89 resolve: auth_resolve,
url: '', 90 90 url: '/',
controller: 'RootController' 91 91 controller: 'RootController'
}). 92 92 }).
state('feed', { 93 93 state('feed', {
resolve: auth_resolve, 94 94 resolve: auth_resolve,
url: '/feed/{sectionId}', 95 95 url: '/feed/{sectionId}',
templateUrl: 'templates/feed.html', 96 96 templateUrl: 'templates/feed.html',
controller: 'FeedController' 97 97 controller: 'FeedController'
}). 98 98 }).
state('cardlist', { 99 99 state('cardlist', {
resolve: auth_resolve, 100 100 resolve: auth_resolve,
url: '/cards/{sectionId}', 101 101 url: '/cards/{sectionId}',
templateUrl: 'templates/cardlist.html', 102 102 templateUrl: 'templates/cardlist.html',
controller: 'CardListController' 103 103 controller: 'CardListController'
}). 104 104 }).
state('addclass', { 105 105 state('addclass', {
resolve: auth_resolve, 106 106 resolve: auth_resolve,
url: '/addclass', 107 107 url: '/addclass',
templateUrl: 'templates/addclass.html', 108 108 templateUrl: 'templates/addclass.html',
controller: 'ClassAddController' 109 109 controller: 'ClassAddController'
}). 110 110 }).
state('dropclass', { 111 111 state('dropclass', {
resolve: auth_resolve, 112 112 resolve: auth_resolve,
url: '/settings/dropclass', 113 113 url: '/settings/dropclass',
templateUrl: 'templates/dropclass.html', 114 114 templateUrl: 'templates/dropclass.html',
controller: 'ClassDropController' 115 115 controller: 'ClassDropController'
}). 116 116 }).
state('deck', { 117 117 state('deck', {
resolve: auth_resolve, 118 118 resolve: auth_resolve,
url: '/deck/{sectionId}', 119 119 url: '/deck/{sectionId}',
templateUrl: 'templates/deck.html', 120 120 templateUrl: 'templates/deck.html',
controller: 'DeckController' 121 121 controller: 'DeckController'
}). 122 122 }).
state('study', { 123 123 state('study', {
resolve: auth_resolve, 124 124 resolve: auth_resolve,
url: '/study', 125 125 url: '/study',
templateUrl: 'templates/study.html', 126 126 templateUrl: 'templates/study.html',
controller: 'StudyController' 127 127 controller: 'StudyController'
}). 128 128 }).
state('flashcard', { 129 129 state('flashcard', {
resolve: auth_resolve, 130 130 resolve: auth_resolve,
url: '/flashcard', 131 131 url: '/flashcard',
templateUrl: 'templates/flashcard.html', 132 132 templateUrl: 'templates/flashcard.html',
controller: 'FlashcardController' 133 133 controller: 'FlashcardController'
}). 134 134 }).
state('settings', { 135 135 state('settings', {
resolve: auth_resolve, 136 136 resolve: auth_resolve,
url: '/settings', 137 137 url: '/settings',
templateUrl: 'templates/settings.html', 138 138 templateUrl: 'templates/settings.html',
controller: 'SettingsController' 139 139 controller: 'SettingsController'
}). 140 140 }).
state('requestpasswordreset', { 141 141 state('requestpasswordreset', {
url: '/requestpasswordreset', 142 142 url: '/requestpasswordreset',
templateUrl: 'templates/requestpasswordreset.html', 143 143 templateUrl: 'templates/requestpasswordreset.html',
controller: 'RequestResetController' 144 144 controller: 'RequestResetController'
}). 145 145 }).
state('resetpassword', { 146 146 state('resetpassword', {
url: '/resetpassword/{uid}/{token}', 147 147 url: '/resetpassword/{uid}/{token}',
templateUrl: 'templates/resetpassword.html', 148 148 templateUrl: 'templates/resetpassword.html',
controller: 'ResetPasswordController' 149 149 controller: 'ResetPasswordController'
}). 150 150 }).
state('verifyemail', { 151 151 state('verifyemail', {
url: '/verifyemail/{key}', 152 152 url: '/verifyemail/{key}',
templateUrl: 'templates/verifyemail.html', 153 153 templateUrl: 'templates/verifyemail.html',
controller: 'VerifyEmailController' 154 154 controller: 'VerifyEmailController'
}). 155 155 }).
state('404', { 156 156 state('404', {
url: '/404', 157 157 url: '/404',
template: "<h1>This page doesn't exist!</h1>" 158 158 template: "<h1>This page doesn't exist!</h1>"
}). 159 159 }).
state('help', { 160 160 state('help', {
resolve: auth_resolve, 161 161 resolve: auth_resolve,
url: '/help', 162 162 url: '/help',
templateUrl: 'templates/help.html', 163 163 templateUrl: 'templates/help.html',
controller: 'HelpController' 164 164 controller: 'HelpController'
}); 165 165 });
}). 166 166 }).
run(function($rootScope, $state, $stateParams, $location, UserService) { 167 167 run(function($rootScope, $state, $stateParams, $location, UserService) {
$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) { 168 168 $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
console.log('failed to change state: ' + error); 169 169 console.log('failed to change state: ' + error);
$state.go('login'); 170 170 $state.go('login');
}); 171 171 });
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { 172 172 $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
$rootScope.nextState = toState; 173 173 $rootScope.nextState = toState;
$rootScope.nextStateParams = toParams; 174 174 $rootScope.nextStateParams = toParams;
console.log('changing state to', toState); 175 175 console.log('changing state to', toState);
if (['feed', 'deck', 'cardlist'].indexOf(toState.name) >= 0) { 176 176 if (['feed', 'deck', 'cardlist'].indexOf(toState.name) >= 0) {
localStorage.setItem('last_state', toState.name); 177 177 localStorage.setItem('last_state', toState.name);
localStorage.setItem('last_state_params', JSON.stringify(toParams)); 178 178 localStorage.setItem('last_state_params', JSON.stringify(toParams));
} 179 179 }
}); 180 180 });
}); 181 181 });
<!DOCTYPE html> 1 1 <!DOCTYPE html>
<html ng-app="flashy"> 2 2 <html ng-app="flashy">
<base href="/app/"> 3 3 <base href="/app/">
<head> 4 4 <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> 5 5 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" 6 6 <link rel="stylesheet"
href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css"> 7 7 href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css">
<link rel="shortcut icon" href="flashy.ico"> 8 8 <link rel="shortcut icon" href="flashy.ico">
9 9
<link rel="stylesheet" href="styles/flashier.css"/> 10 10 <link rel="stylesheet" href="styles/flashier.css"/>
<link rel="stylesheet" href="styles/flashy.css"/> 11 11 <link rel="stylesheet" href="styles/flashy.css"/>
<link rel="manifest" href="manifest.json"> 12 12 <link rel="manifest" href="manifest.json">
<link 13 13 <link
href='https://fonts.googleapis.com/css?family=Satisfy|Titillium+Web:400,200,200italic,300,600,700,900,700italic,600italic,400italic,300italic' 14 14 href='https://fonts.googleapis.com/css?family=Satisfy|Titillium+Web:400,200,200italic,300,600,700,900,700italic,600italic,400italic,300italic'
rel='stylesheet' type='text/css'> 15 15 rel='stylesheet' type='text/css'>
<title>Flashy</title> 16 16 <title>Flashy</title>
</head> 17 17 </head>
<body ng-controller="RootController"> 18 18 <body ng-controller="RootController">
<header> 19 19 <header>
<nav> 20 20 <nav>
<div class="nav-wrapper"> 21 21 <div class="nav-wrapper">
<a ng-show="UserService.isLoggedIn()" href="#" data-activates="mobile-demo" 22 22 <a ng-show="UserService.isLoggedIn()" href="#" data-activates="mobile-demo"
class="left button-collapse hide-on-med-and-up"><i 23 23 class="left button-collapse hide-on-med-and-up"><i
class="mdi-navigation-menu"></i></a> 24 24 class="mdi-navigation-menu"></i></a>
25 25
<!-- User's classes dropdown --> 26 26 <!-- User's classes dropdown -->
<ul id="classDropdown" class="dropdown-content"> 27 27 <ul id="classDropdown" class="dropdown-content">
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> 28 28 <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections">
<a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> 29 29 <a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a>
</li> 30 30 </li>
<li class="divider"></li> 31 31 <li class="divider"></li>
<li><a ui-sref="addclass">Add Class</a></li> 32 32 <li><a ui-sref="addclass">Add Class</a></li>
</ul> 33 33 </ul>
<ul ng-show="UserService.isLoggedIn()" class="left hide-on-small-and-down"> 34 34 <ul ng-show="UserService.isLoggedIn()" class="left hide-on-small-and-down">
<li><a style="font-size:20px; font-weight:700;" class="dropdown-button ng-cloak hide-on-small-and-down" 35 35 <li><a style="font-size:20px; font-weight:700;" class="dropdown-button ng-cloak hide-on-small-and-down"
href="#!" id="class-list" 36 36 href="#!" id="class-list"
data-activates="classDropdown" data-beloworigin="true">{{currentSection.id?currentSection.short_name:"Classes"}}<i 37 37 data-activates="classDropdown" data-beloworigin="true">{{currentSection.id?currentSection.short_name:"Classes"}}<i
class="mdi-navigation-arrow-drop-down right"></i></a></li> 38 38 class="mdi-navigation-arrow-drop-down right"></i></a></li>
<li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" 39 39 <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})"
class="tooltipped" 40 40 class="tooltipped"
data-position="bottom" 41 41 data-position="bottom"
data-delay="50" data-tooltip="Feed"><i 42 42 data-delay="50" data-tooltip="Feed"><i
class="mdi-action-view-module"></i></a></li> 43 43 class="mdi-action-view-module"></i></a></li>
<li ng-show="currentSection.id" ui-sref-active="active" id="class-list"><a ui-sref="deck({sectionId:currentSection.id})" 44 44 <li ng-show="currentSection.id" ui-sref-active="active" id="class-list"><a ui-sref="deck({sectionId:currentSection.id})"
class="tooltipped" 45 45 class="tooltipped"
data-position="bottom" 46 46 data-position="bottom"
data-delay="50" data-tooltip="Deck"><i 47 47 data-delay="50" data-tooltip="Deck"><i
class="mdi-action-view-carousel"></i></a></li> 48 48 class="mdi-action-view-carousel"></i></a></li>
<li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" 49 49 <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})"
class="tooltipped" 50 50 class="tooltipped"
data-position="bottom" 51 51 data-position="bottom"
data-delay="50" data-tooltip="Card List"><i 52 52 data-delay="50" data-tooltip="Card List"><i
class="mdi-action-view-list"></i></a></li> 53 53 class="mdi-action-view-list"></i></a></li>
</ul> 54 54 </ul>
<a href="#" class="brand-logo center">Flashy</a> 55 55 <a href="#" class="brand-logo center">Flashy</a>
56 56
<ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down"> 57 57 <ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down">
58 58
<li ui-sref-active="active"><a ui-sref="study" class="tooltipped" data-position="bottom" data-delay="50" 59 59 <li ui-sref-active="active"><a ui-sref="study" class="tooltipped" data-position="bottom" data-delay="50"
data-tooltip="Study"> 60 60 data-tooltip="Study">
<i class="tiny mdi-action-pageview"></i></a></li> 61 61 <i class="tiny mdi-action-pageview"></i></a></li>
62 62
<!-- Settings Dropdown --> 63 63 <!-- Settings Dropdown -->
<ul id="settingsDropdown" class="dropdown-content"> 64 64 <ul id="settingsDropdown" class="dropdown-content">
65 65
66 66
</ul> 67 67 </ul>
68 68
<li ui-sref-active="active"><a ui-sref="help"><i class="tiny mdi-action-help tooltipped" 69 69 <li ui-sref-active="active"><a ui-sref="help"><i class="tiny mdi-action-help tooltipped"
data-position="bottom" 70 70 data-position="bottom"
data-delay="50" data-tooltip="Help"></i></a></li> 71 71 data-delay="50" data-tooltip="Help"></i></a></li>
<li ui-sref-active="active"><a ui-sref="settings"><i data-position="bottom" data-delay="50" 72 72 <li ui-sref-active="active"><a ui-sref="settings"><i data-position="bottom" data-delay="50"
data-tooltip="Settings" 73 73 data-tooltip="Settings"
class="mdi-action-settings tooltipped"></i></a></li> 74 74 class="mdi-action-settings tooltipped"></i></a></li>
<li><a ng-click="logout()" ui-sref="login"><i data-position="bottom" data-delay="50" data-tooltip="Logout" 75 75 <li><a ng-click="logout()" ui-sref="login"><i data-position="bottom" data-delay="50" data-tooltip="Logout"
class="mdi-content-forward tooltipped"></i></a></li> 76 76 class="mdi-content-forward tooltipped"></i></a></li>
77 77
78 78
</ul> 79 79 </ul>
80 80
<!-- Slide-in side-nav for small screens --> 81 81 <!-- Slide-in side-nav for small screens -->
<ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> 82 82 <ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo">
<span ng-show="currentSection.id"> 83 83 <span ng-show="currentSection.id">
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})"> 84 84 <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})">
<i class="mdi-action-view-module left"></i> 85 85 <i class="mdi-action-view-module left"></i>
Feed</a> 86 86 Feed</a>
</li> 87 87 </li>
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})"> 88 88 <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})">
<i class="mdi-action-view-carousel left"> </i> 89 89 <i class="mdi-action-view-carousel left"> </i>
Deck 90 90 Deck
</a> 91 91 </a>
</li> 92 92 </li>
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})"> 93 93 <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})">
<i class="mdi-action-view-list left"></i> 94 94 <i class="mdi-action-view-list left"></i>
Card List 95 95 Card List
</a> 96 96 </a>
</li> 97 97 </li>
<hr> 98 98 <hr>
</span> 99 99 </span>
<!-- Collapsible menu for all the User's classes --> 100 100 <!-- Collapsible menu for all the User's classes -->
<ul class="collapsible" data-collapsible="accordion" > 101 101 <ul class="collapsible" data-collapsible="accordion" >
<li class="bold"> 102 102 <li class="bold">
<a class="collapsible-header black-text"> 103 103 <a class="collapsible-header black-text">
Classes 104 104 Classes
<i class="mdi-navigation-arrow-drop-down right"></i> 105 105 <i class="mdi-navigation-arrow-drop-down right"></i>
</a> 106 106 </a>
</li> 107 107 </li>
<div class="collapsible-body" style="display: block"> 108 108 <div class="collapsible-body" style="display: block">
<ul> 109 109 <ul>
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> 110 110 <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections">
<a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> 111 111 <a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a>
</li> 112 112 </li>
<hr> 113 113 <hr>
<li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> 114 114 <li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li>
</ul> 115 115 </ul>
</div> 116 116 </div>
</ul> 117 117 </ul>
<li><a ui-sref="study">Study</a></li> 118 118 <li><a ui-sref="study">Study</a></li>
<li><a ui-sref="settings">Settings</a></li> 119 119 <li><a ui-sref="settings">Settings</a></li>
<li><a ng-click="logout()">Logout</a></li> 120 120 <li><a ng-click="logout()">Logout</a></li>
</ul> 121 121 </ul>
</div> 122 122 </div>
</nav> 123 123 </nav>
124 124
</header> 125 125 </header>
126 126
127 127
<!-- Menu Bar --> 128 128 <!-- Menu Bar -->
<main ui-view></main> 129 129 <main ui-view></main>
130 130
131 131
<!--<footer class="page-footer">--> 132 132 <!--<footer class="page-footer">-->
<!--<div class="footer-copyright">--> 133 133 <!--<div class="footer-copyright">-->
<!--<div class="container">--> 134 134 <!--<div class="container">-->
<!--&copy; 2015 Team Swag--> 135 135 <!--&copy; 2015 Team Swag-->
<!--<a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by--> 136 136 <!--<a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by-->
<!--email!</a>--> 137 137 <!--email!</a>-->
<!--</div>--> 138 138 <!--</div>-->
139 139
<!--</div>--> 140 140 <!--</div>-->
<!--</footer>--> 141 141 <!--</footer>-->
142 142
</body> 143 143 </body>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> 144 144 <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script> 145 145 <script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.js"></script> 146 146 <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.js"></script>
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script> 147 147 <script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="scripts/materialize.js"></script> 148 148 <script type="text/javascript" src="scripts/materialize.js"></script>
<script type="text/javascript" src="scripts/jquery.collapsible.js"></script> 149 149 <script type="text/javascript" src="scripts/jquery.collapsible.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script> 150 150 <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script> 151 151 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> 152 152 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-resource.min.js"></script> 153 153 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-resource.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-sanitize.js"></script> 154 154 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-sanitize.js"></script>
<script src="static/js/angular-websocket.js"></script> 155 155 <script src="static/js/angular-websocket.js"></script>
<script src="static/js/angular-contenteditable.js"></script> 156 156 <script src="static/js/angular-contenteditable.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script> 157 157 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script>
158 158
159 159
<script src="config.js"></script> 160 160 <script src="config.js"></script>
161 161
<script src="scripts/FlashcardFactory.js"></script> 162 162 <script src="scripts/FlashcardFactory.js"></script>
163 <script src="scripts/DeckFactory.js"></script>
163 164
login_test.js View file @ 0aff91d
phantom.page.injectJs( 'shim.js'); 1 File was deleted
2
casper.test.begin('login test', 1, function(test) { 3
casper.start('https://flashy.cards/app/login', function() { 4
test.assertExist('.login-form'); 5
}).run(); 6
scripts/CardGridController.js View file @ 0aff91d
angular.module('flashy.CardGridController', ['ui.router', 'ngAnimate', 'ngWebSocket']).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) { 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.deck = []; 4
$scope.cardCols = []; // organized data 5 5 $scope.cardCols = []; // organized data
$scope.cardColsShow = []; // displayed data 6 6 $scope.cardColsShow = []; // displayed data
$scope.numCols = 0; 7 7 $scope.numCols = 0;
$scope.cardTable = {}; // look up table of cards: {'colNum':col, 'obj':card} 8 8 $scope.section = $rootScope.SectionResource.get({sectionId: sectionId});
$scope.sectionId = parseInt($stateParams.sectionId); 9 9 $scope.deck = new Deck(sectionId, {
$scope.section = $rootScope.SectionResource.get({sectionId: $scope.sectionId}); 10 10 cardHideCallback: function(card) {
11 $scope.hideCardFromGrid(card);
12 }
13 });
14
$scope.showGrid = false; 11 15 $scope.showGrid = false;
//$scope.moveQueue = []; // queue of flashcard objects 12 16 //$scope.moveQueue = []; // queue of flashcard objects
$rootScope.currentSection = $scope.section; 13 17 $rootScope.currentSection = $scope.section;
14 18
if (!UserService.isInSection($scope.sectionId)) { 15
console.log('user is not enrolled in ' + $scope.sectionId); 16
$state.go('addclass'); 17
} 18
19
$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.ws_host = window.location.origin.replace('http', 'ws'); 58
$scope.deck_ws = $websocket($scope.ws_host + '/ws/deck/' + $scope.sectionId + '?subscribe-user'); 59
$scope.deck_ws.onOpen(function() { 60
console.log('deck ws open'); 61
}); 62
63
$scope.deck_ws.onMessage(function(message) { 64
data = JSON.parse(message.data); 65
console.log('message', data); 66
card = new Flashcard(data.flashcard); 67
if (data.event_type == 'card_pulled') { 68
$scope.deck[card.id] = card; 69
if ($scope.deckPullCallback) $scope.deckPullCallback(card); 70
} 71
if (data.event_type == 'card_unpulled') { 72
$scope.deck[card.id] = undefined; 73
if ($scope.deckUnpullCallback) $scope.deckUnpullCallback(card); 74
} 75
if (data.event_type == 'card_hidden') { 76
$scope.hideCardFromGrid(card); 77
} 78
}); 79
80
$scope.cardInDeck = function(id) { 81
return $scope.deck[id]; 82
}; 83
$scope.addCardToGrid = function(card) { 84 57 $scope.addCardToGrid = function(card) {
var colNum = 0; 85 58 var colNum = 0;
var lowestCol = $scope.cardCols[0]; 86 59 var lowestCol = $scope.cardCols[0];
var lowestColNum = 0; 87 60 var lowestColNum = 0;
while (colNum < $scope.numCols) { 88 61 while (colNum < $scope.numCols) {
if ($scope.cardCols[colNum].length == 0) { 89 62 if ($scope.cardCols[colNum].length == 0) {
lowestCol = $scope.cardCols[colNum]; 90 63 lowestCol = $scope.cardCols[colNum];
break; 91 64 break;
} else if ($scope.cardCols[colNum].length < lowestCol.length) { 92 65 } else if ($scope.cardCols[colNum].length < lowestCol.length) {
lowestCol = $scope.cardCols[colNum]; 93 66 lowestCol = $scope.cardCols[colNum];
lowestColNum = colNum; 94 67 lowestColNum = colNum;
lowestColLen = $scope.cardCols[colNum].length; 95 68 lowestColLen = $scope.cardCols[colNum].length;
} 96 69 }
colNum++; 97 70 colNum++;
} 98 71 }
console.log(card); 99 72 console.log(card);
$scope.cards.push(data); 100 73 $scope.cards.push(data);
lowestCol.unshift(card); 101 74 lowestCol.unshift(card);
card.colNum = lowestColNum; 102 75 card.colNum = lowestColNum;
$scope.updateColRanks(lowestCol); 103 76 $scope.updateColRanks(lowestCol);
$timeout($scope.refreshColumnWidth); 104 77 $timeout($scope.refreshColumnWidth);
105 78
}; 106 79 };
107 80
$scope.updateColRanks = function(col) { 108 81 $scope.updateColRanks = function(col) {
for (i in col) 109 82 for (i in col)
col[i].colRank = parseInt(i); 110 83 col[i].colRank = parseInt(i);
}; 111 84 };
112 85
$scope.hideCardFromGrid = function(card) { 113 86 $scope.hideCardFromGrid = function(card) {
console.log('hiding', card); 114 87 console.log('hiding', card);
$scope.cardCols[card.colNum].splice(card.colRank, 1); 115 88 $scope.cardCols[card.colNum].splice(card.colRank, 1);
$scope.updateColRanks($scope.cardCols[card.colNum]); 116 89 $scope.updateColRanks($scope.cardCols[card.colNum]);
console.log($scope.cardCols); 117 90 console.log($scope.cardCols);
}; 118 91 };
119 92
$scope.$on('$destroy', function() { 120 93 $scope.$on('$destroy', function() {
$scope.deck_ws.close(); 121 94 $scope.deck.cleanup();
95 Flashcard.cleanup();
$rootScope.currentSection = {}; 122 96 $rootScope.currentSection = {};
$(document).off('keydown'); 123 97 $(document).off('keydown');
}); 124 98 });
return $http.get('/api/sections/' + $scope.sectionId + '/deck/'). 125 99 return $scope.deck.deckPromise;
success(function(data) { 126
scripts/CardListController.js View file @ 0aff91d
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) { 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) {
$scope.cards = data; 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);
switch (date.getDay()) { 134 81 return ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()];
case 0: 135
return 'U'; 136
case 1: 137
return 'M'; 138
case 2: 139
return 'T'; 140
case 3: 141
return 'W'; 142
case 4: 143
return 'R'; 144
case 5: 145
return 'F'; 146
case 6: 147
return 'S'; 148
} 149
}; 150 82 };
151 83
// checkbox filter 152 84 // checkbox filter
$scope.filter = { 153 85 $scope.filter = {
'week1': true, 154 86 'week1': true,
'week2': true, 155 87 'week2': true,
'week3': true, 156 88 'week3': true,
'week4': true, 157 89 'week4': true,
'week5': true, 158 90 'week5': true,
'week6': true, 159 91 'week6': true,
'week7': true, 160 92 'week7': true,
'week8': true, 161 93 'week8': true,
'week9': true, 162 94 'week9': true,
'week10': true, 163 95 'week10': true,
}; 164 96 };
165 97
$scope.filterByDate = function(item) { 166 98 $scope.filterByDate = function(item) {
var week = item.material_week_num; 167 99 var week = item.material_week_num;
return (week == 1 && $scope.filter['week1']) || 168 100 return (week == 1 && $scope.filter['week1']) ||
(week == 2 && $scope.filter['week2']) || 169 101 (week == 2 && $scope.filter['week2']) ||
(week == 3 && $scope.filter['week3']) || 170 102 (week == 3 && $scope.filter['week3']) ||
(week == 4 && $scope.filter['week4']) || 171 103 (week == 4 && $scope.filter['week4']) ||
(week == 5 && $scope.filter['week5']) || 172 104 (week == 5 && $scope.filter['week5']) ||
(week == 6 && $scope.filter['week6']) || 173 105 (week == 6 && $scope.filter['week6']) ||
(week == 7 && $scope.filter['week7']) || 174 106 (week == 7 && $scope.filter['week7']) ||
(week == 8 && $scope.filter['week8']) || 175 107 (week == 8 && $scope.filter['week8']) ||
(week == 9 && $scope.filter['week9']) || 176 108 (week == 9 && $scope.filter['week9']) ||
(week == 10 && $scope.filter['week10']); 177 109 (week == 10 && $scope.filter['week10']);
}; 178 110 };
111 $scope.$on('$destroy', function() {
112 $scope.deck.cleanup();
113 Flashcard.cleanup();
114 });
179 115
} 180 116 }
). 181 117 ).
filter('displayCard', function($sce) { 182 118 filter('displayCard', function($sce) {
return function(card) { 183 119 return function(card) {
// text to display as html 184 120 // text to display as html
var cardText = ''; 185 121 var cardText = '';
186 122
var start = 0; // where to start next string break 187 123 var start = 0; // where to start next string break
188 124
// get all display pieces and blank pieces 189 125 // get all display pieces and blank pieces
for (var i = 0; i < card.mask.length; i++) { 190 126 for (var i = 0; i < card.mask.length; i++) {
cardText = cardText.concat(card.text.substring(start, card.mask[i][0])); 191 127 cardText = cardText.concat(card.text.substring(start, card.mask[i][0]));
cardText = cardText.concat('<b>'); 192 128 cardText = cardText.concat('<b>');
cardText = cardText.concat(card.text.substring(card.mask[i][0], card.mask[i][1])); 193 129 cardText = cardText.concat(card.text.substring(card.mask[i][0], card.mask[i][1]));
cardText = cardText.concat('</b>'); 194 130 cardText = cardText.concat('</b>');
start = card.mask[i][1]; 195 131 start = card.mask[i][1];
} 196 132 }
197 133
// get remaining dislay pieces, if any 198 134 // get remaining dislay pieces, if any
if (start != card.mask.length - 1) 199 135 if (start != card.mask.length - 1)
cardText = cardText.concat(card.text.substring(start)); 200 136 cardText = cardText.concat(card.text.substring(start));
201 137
return $sce.trustAsHtml(cardText); 202 138 return $sce.trustAsHtml(cardText);
}; 203 139 };
}); 204 140 });
205 141
scripts/DeckController.js View file @ 0aff91d
angular.module('flashy.DeckController', ['ui.router', 'ngWebSocket']). 1 1 angular.module('flashy.DeckController', ['ui.router', 'ngWebSocket']).
2 2
controller('DeckController', function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, UserService, Flashcard) { 3 3 controller('DeckController',
4 function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard, Deck) {
angular.module('flashy.CardGridController').CardGridController.apply(this, arguments).then(function() { 4 5 angular.module('flashy.CardGridController').CardGridController.apply(this, arguments).then(function() {
$scope.refreshLayout(); 5 6 $scope.refreshLayout();
}); 6 7 });
$scope.cards = $scope.deck; 7 8 $scope.cards = $scope.deck.cards;
$scope.deckPullCallback = $scope.addCardToGrid; 8 9 $scope.deckPullCallback = $scope.addCardToGrid;
$scope.deckUnpullCallback = $scope.hideCardFromGrid; 9 10 $scope.deckUnpullCallback = $scope.hideCardFromGrid;
10 11
} 11 12 }
); 12 13 );
scripts/DeckFactory.js View file @ 0aff91d
File was created 1 angular.module('flashy.DeckFactory', ['ui.router', 'flashy.FlashcardFactory', 'ngWebSocket']).
2 factory('Deck', function ($http, $rootScope, $state, $websocket, Flashcard, UserService) {
3
4 var Deck = function (sectionId, callbacks) {
5 if (!UserService.isInSection(sectionId)) {
6 console.log('user is not enrolled in ' + sectionId);
7 $state.go('addclass');
8 }
9 obj = this;
10 this.cards = [];
11 this.section = $rootScope.SectionResource.get({sectionId: sectionId});
12
13 this.ws = $websocket($rootScope.ws_host + '/ws/deck/' + sectionId + '?subscribe-user');
14 this.contains = function (id) {
15 return this.cards[id];
16 };
17
18 this.ws.onMessage(function (message) {
19 data = JSON.parse(message.data);
20 console.log('message', data);
21 card = new Flashcard(data.flashcard);
22 if (data.event_type == 'card_pulled') {
23 obj.cards[card.id] = card;
24 if (callbacks.cardPullCallback) callbacks.cardPullCallback(card);
25 }
26 if (data.event_type == 'card_unpulled') {
27 obj.cards[card.id] = undefined;
28 if (callbacks.cardUnpullCallback) callbacks.cardUnpullCallback(card);
29 }
30 if (data.event_type == 'card_hidden') {
31 if (callbacks.cardHideCallback) callbacks.cardHideCallback(card);
32 }
33 if (data.event_type == 'card_unhidden') {
34 if (callbacks.cardUnhideCallback) callbacks.cardUnhideCallback(card);
35 }
36 });
37 this.deckPromise = $http.get('/api/sections/' + sectionId + '/deck/').success(function (data) {
38 for (i in data) obj.cards[data[i].id] = new Flashcard(data[i], obj);
39 console.log("got user's deck", data);
40 });
41 this.cleanup = function () {
42 this.ws.close();
43 };
44 this.forEach = this.cards.forEach;
scripts/FeedController.js View file @ 0aff91d
angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket', 'contenteditable']).controller('FeedController', 1 1 angular.module('flashy.FeedController',
function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard) { 2 2 ['ui.router',
3 'ngAnimate',
4 'ngWebSocket',
5 'contenteditable',
6 'flashy.DeckFactory']).controller('FeedController',
7 function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard, Deck) {
angular.module('flashy.CardGridController').CardGridController.apply(this, arguments); 3 8 angular.module('flashy.CardGridController').CardGridController.apply(this, arguments);
4 9
(function drawCols() { 5 10 (function drawCols() {
$interval(function() { 6 11 $interval(function() {
if ($scope.cardColsShow != $scope.cardCols) { 7 12 if ($scope.cardColsShow != $scope.cardCols) {
$scope.cardColsShow = $scope.cardCols; 8 13 $scope.cardColsShow = $scope.cardCols;
console.log('interval'); 9 14 console.log('interval');
} 10 15 }
}, 1000); 11 16 }, 1000);
}()); 12 17 }());
13 18
$scope.updateCardScore = function(card) { 14 19 $scope.updateCardScore = function(card) {
console.log($scope.cardCols, card); 15 20 console.log($scope.cardCols, card);
// if no colNum is attached, then this doesn't exist on the feed yet 16 21 // if no colNum is attached, then this doesn't exist on the feed yet
if (!card.colNum) return; 17 22 if (!card.colNum) return;
$scope.cardCols[card.colNum].sort(function(a, b) { 18 23 $scope.cardCols[card.colNum].sort(function(a, b) {
return b.score - a.score; 19 24 return b.score - a.score;
}); 20 25 });
$scope.updateColRanks($scope.cardCols[card.colNum]); 21 26 $scope.updateColRanks($scope.cardCols[card.colNum]);
}; 22 27 };
23 28
$scope.feed_ws = $websocket($scope.ws_host + '/ws/feed/' + $scope.sectionId + '?subscribe-broadcast'); 24 29 $scope.feed_ws = $websocket($scope.ws_host + '/ws/feed/' + sectionId + '?subscribe-broadcast');
$scope.feed_ws.onMessage(function(e) { 25 30 $scope.feed_ws.onMessage(function(e) {
data = JSON.parse(e.data); 26 31 data = JSON.parse(e.data);
console.log('message', data); 27 32 console.log('message', data);
if (data.event_type == 'new_card') { 28 33 if (data.event_type == 'new_card') {
$scope.addCardToGrid(new Flashcard(data.flashcard, $scope.deck)); 29 34 $scope.addCardToGrid(new Flashcard(data.flashcard, $scope.deck));
} else if (data.event_type == 'score_change') { 30 35 } else if (data.event_type == 'score_change') {
card = new Flashcard(data.flashcard); 31 36 card = new Flashcard(data.flashcard);
card.score = data.flashcard.score; 32 37 card.score = data.flashcard.score;
$scope.updateCardScore(card); 33 38 $scope.updateCardScore(card);
} 34 39 }
}); 35 40 });
36 41
$scope.pushCard = function() { 37 42 $scope.pushCard = function() {
var myCard = { 38 43 var myCard = {
// we can't trim this string because it'd mess up the blanks. Something to fix. 39 44 // we can't trim this string because it'd mess up the blanks. Something to fix.
'text': $('#new-card-input').text(), 40 45 'text': $('#new-card-input').text(),
'mask': $scope.newCardBlanks, 41 46 'mask': $scope.newCardBlanks,
section: $scope.section.id 42 47 section: $scope.section.id
}; 43 48 };
if (myCard.text == '') { 44 49 if (myCard.text == '') {
console.log('blank flashcard not pushed:' + myCard.text); 45 50 console.log('blank flashcard not pushed:' + myCard.text);
return closeNewCard(); 46 51 return closeNewCard();
} 47 52 }
$http.post('/api/flashcards/', myCard). 48 53 $http.post('/api/flashcards/', myCard).
success(function(data) { 49 54 success(function(data) {
console.log('flashcard pushed: ' + myCard.text); 50 55 console.log('flashcard pushed: ' + myCard.text);
if (!UserService.hasVerifiedEmail()) { 51 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); 52 57 Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000);
} 53 58 }
}); 54 59 });
return $scope.closeNewCardModal(); 55 60 return $scope.closeNewCardModal();
}; 56 61 };
57 62
/* Key bindings for the whole feed window. Hotkey it up! */ 58 63 /* Key bindings for the whole feed window. Hotkey it up! */
var listenForC = true; 59 64 var listenForC = true;
60 65
// Need to pass these options into openmodal and leanmodal, 61 66 // Need to pass these options into openmodal and leanmodal,
// otherwise the ready handler doesn't get called 62 67 // otherwise the ready handler doesn't get called
63 68
modal_options = { 64 69 modal_options = {
dismissible: true, // Modal can be dismissed by clicking outside of the modal 65 70 dismissible: true, // Modal can be dismissed by clicking outside of the modal
opacity: 0, // Opacity of modal background 66 71 opacity: 0, // Opacity of modal background
in_duration: 300, // Transition in duration 67 72 in_duration: 300, // Transition in duration
out_duration: 200, // Transition out duration 68 73 out_duration: 200, // Transition out duration
ready: function() { 69 74 ready: function() {
$('#new-card-input').focus(); 70 75 $('#new-card-input').focus();
document.execCommand('selectAll', false, null); 71 76 document.execCommand('selectAll', false, null);
} 72 77 }
}; 73 78 };
74 79
$(document).keydown(function(e) { 75 80 $(document).keydown(function(e) {
var keyed = e.which; 76 81 var keyed = e.which;
if (keyed == 67 && listenForC) { // "c" for compose 77 82 if (keyed == 67 && listenForC) { // "c" for compose
$scope.openNewCardModal(); 78 83 $scope.openNewCardModal();
e.preventDefault(); 79 84 e.preventDefault();
return false; 80 85 return false;
} else if (keyed == 27) { // clear on ESC 81 86 } else if (keyed == 27) { // clear on ESC
$scope.closeNewCardModal(); 82 87 $scope.closeNewCardModal();
} 83 88 }
}); 84 89 });
85 90
$scope.openNewCardModal = function() { 86 91 $scope.openNewCardModal = function() {
$('#newCard').openModal(modal_options); 87 92 $('#newCard').openModal(modal_options);
listenForC = false; 88 93 listenForC = false;
$('#new-card-input').html('Write a flashcard!'); 89 94 $('#new-card-input').html('Write a flashcard!');
}; 90 95 };
91 96
$scope.closeNewCardModal = function() { 92 97 $scope.closeNewCardModal = function() {
listenForC = true; 93 98 listenForC = true;
$('#new-card-input').html('').blur(); 94 99 $('#new-card-input').html('').blur();
$('#newCard').closeModal(modal_options); 95 100 $('#newCard').closeModal(modal_options);
}; 96 101 };
97 102
$('.tooltipped').tooltip({delay: 50}); 98 103 $('.tooltipped').tooltip({delay: 50});
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered 99 104 // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
$('.modal-trigger').leanModal(modal_options); 100 105 $('.modal-trigger').leanModal(modal_options);
$('#new-card-input').on('keydown', function(e) { 101 106 $('#new-card-input').on('keydown', function(e) {
if (e.which == 13) { 102 107 if (e.which == 13) {
e.preventDefault(); 103 108 e.preventDefault();
if ($scope.submit_enabled) { 104 109 if ($scope.submit_enabled) {
$scope.pushCard(); 105 110 $scope.pushCard();
listenForC = true; 106 111 listenForC = true;
} 107 112 }
return false; 108 113 return false;
} else { 109 114 } else {
110 115
} 111 116 }
}); 112 117 });
$('button#blank-selected').click(function() { 113 118 $('button#blank-selected').click(function() {
console.log(window.getSelection()); 114 119 console.log(window.getSelection());
document.execCommand('bold'); 115 120 document.execCommand('bold');
}); 116 121 });
$scope.newCardBlanks = []; 117 122 $scope.newCardBlanks = [];
$scope.refreshNewCardInput = function() { 118 123 $scope.refreshNewCardInput = function() {
$scope.newCardText = $('#new-card-input').text(); 119 124 $scope.newCardText = $('#new-card-input').text();
$scope.submit_enabled = $scope.newCardText.length >= 5 && $scope.newCardText.length <= 160; 120 125 $scope.submit_enabled = $scope.newCardText.length >= 5 && $scope.newCardText.length <= 160;
var i = 0; 121 126 var i = 0;
$scope.newCardBlanks = []; 122 127 $scope.newCardBlanks = [];
$('#new-card-input')[0].childNodes.forEach(function(node) { 123 128 $('#new-card-input')[0].childNodes.forEach(function(node) {
node = $(node)[0]; 124 129 node = $(node)[0];
if (node.tagName == 'B') { 125 130 if (node.tagName == 'B') {
var text = $(node).text(); 126 131 var text = $(node).text();
var leftspaces = 0, rightspaces = 0; 127 132 var leftspaces = 0, rightspaces = 0;
// awful way to find the first non-space character from the left or the right. thanks.js 128 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++; 129 134 while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++;
while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++; 130 135 while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++;
console.log(leftspaces, text.length); 131 136 console.log(leftspaces, text.length);
if (leftspaces != text.length) $scope.newCardBlanks.push([i + leftspaces, i + text.length - rightspaces]); 132 137 if (leftspaces != text.length) $scope.newCardBlanks.push([i + leftspaces, i + text.length - rightspaces]);
i += text.length; 133 138 i += text.length;
} else if (!node.data) { 134 139 } else if (!node.data) {
i += $(node).text().length; 135 140 i += $(node).text().length;
} else { 136 141 } else {
i += node.data.length; 137 142 i += node.data.length;
} 138 143 }
}); 139 144 });
$scope.newCardBlanks.sort(function(a, b) { 140 145 $scope.newCardBlanks.sort(function(a, b) {
return a[0] - b[0]; 141 146 return a[0] - b[0];
}); 142 147 });
i = 0; 143 148 i = 0;
newtext = ''; 144 149 newtext = '';
$scope.newCardBlanks.forEach(function(blank) { 145 150 $scope.newCardBlanks.forEach(function(blank) {
newtext += $scope.newCardText.slice(i, blank[0]); 146 151 newtext += $scope.newCardText.slice(i, blank[0]);
newtext += '<b>' + $scope.newCardText.slice(blank[0], blank[1]) + '</b>'; 147 152 newtext += '<b>' + $scope.newCardText.slice(blank[0], blank[1]) + '</b>';
i = blank[1]; 148 153 i = blank[1];
}); 149 154 });
newtext += $scope.newCardText.slice(i); 150 155 newtext += $scope.newCardText.slice(i);
//$scope.newCardFormattedText = newtext; 151 156 //$scope.newCardFormattedText = newtext;
}; 152 157 };
$scope.shuffleCards = function() { 153 158 $scope.shuffleCards = function() {
$timeout(function() { 154 159 $timeout(function() {
(function(o) { 155 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); 156 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; 157 162 return o;
})($scope.cardCols[0]); 158 163 })($scope.cardCols[0]);
}); 159 164 });
}; 160 165 };
$scope.$on('$destroy', function() { 161 166 $scope.$on('$destroy', function() {
$scope.feed_ws.close(); 162 167 $scope.feed_ws.close();
}); 163 168 });
return $http.get('/api/sections/' + $scope.sectionId + '/feed/'). 164 169 return $http.get('/api/sections/' + sectionId + '/feed/').
success(function(data) { 165 170 success(function(data) {
console.log(data); 166 171 console.log(data);
$scope.cards = data.map(function(card) { 167 172 $scope.cards = data.map(function(card) {
return new Flashcard(card, $scope.deck); 168 173 return new Flashcard(card, $scope.deck);
}); 169 174 });
$scope.refreshLayout().then(function() { 170 175 $scope.refreshLayout().then(function() {
$timeout($scope.refreshColumnWidth).then(function() { 171 176 $timeout($scope.refreshColumnWidth).then(function() {
$scope.showGrid = true; 172 177 $scope.showGrid = true;
}); 173 178 });
console.log('layout done'); 174 179 console.log('layout done');
}); 175 180 });
}); 176 181 });
}); 177 182 });
scripts/FlashcardFactory.js View file @ 0aff91d
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 = [];
var Deck = null; 4 4 var Deck = null;
var Flashcard = function (data, deck) { 5 5 var Flashcard = function (data, deck) {
if(deck) Deck = deck; 6
if (typeof data == 'number') return FlashcardCache[data]; 7 6 if (typeof data == 'number') return FlashcardCache[data];
if (FlashcardCache[data.id]) return FlashcardCache[data.id]; 8 7 if (FlashcardCache[data.id]) return FlashcardCache[data.id];
8 if (!Deck && deck) Deck = deck;
for (var k in data) this[k] = data[k]; 9 9 for (var k in data) this[k] = data[k];
this.textPieces = []; 10 10 this.textPieces = [];
this.mask.sort(function (a, b) { 11 11 this.mask.sort(function (a, b) {
return a[0] - b[0]; 12 12 return a[0] - b[0];
}); 13 13 });
var i = 0; 14 14 var i = 0;
this.mask.forEach(function (blank) { 15 15 this.mask.forEach(function (blank) {
this.textPieces.push({text: this.text.slice(i, blank[0])}); 16 16 this.textPieces.push({text: this.text.slice(i, blank[0])});
this.textPieces.push({text: this.text.slice(blank[0], blank[1]), blank: true}); 17 17 this.textPieces.push({text: this.text.slice(blank[0], blank[1]), blank: true});
i = blank[1]; 18 18 i = blank[1];
}, this); 19 19 }, this);
this.textPieces.push({text: this.text.slice(i)}); 20 20 this.textPieces.push({text: this.text.slice(i)});
this.formatted_text = ''; 21 21 this.formatted_text = '';
for (i in this.textPieces) { 22 22 for (i in this.textPieces) {
p = this.textPieces[i]; 23 23 p = this.textPieces[i];
this.formatted_text += p.blank ? '<b>' + p.text + '</b>' : p.text; 24 24 this.formatted_text += p.blank ? '<b>' + p.text + '</b>' : p.text;
} 25 25 }
FlashcardCache[this.id] = this; 26 26 FlashcardCache[this.id] = this;
}; 27 27 };
28
Flashcard.prototype.isInDeck = function () { 28 29 Flashcard.prototype.isInDeck = function () {
return !(typeof Deck[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 (Deck[this.id]) 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 (Deck[this.id]) 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 (!Deck[this.id]) 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 });
49 57
scripts/RootController.js View file @ 0aff91d
angular.module('flashy.RootController', ['ui.router', 'ngResource', 'ngSanitize']). 1 1 angular.module('flashy.RootController', ['ui.router', 'ngResource', 'ngSanitize']).
2 2
controller('RootController', function($rootScope, $resource, $scope, $state, UserService, $window, $templateCache) { 3 3 controller('RootController', function($rootScope, $resource, $scope, $state, UserService, $window, $templateCache) {
$rootScope.SectionResource = $resource('/api/sections/:sectionId/'); 4 4 $rootScope.SectionResource = $resource('/api/sections/:sectionId/');
window.rootscope = $rootScope; 5 5 window.rootscope = $rootScope;
$rootScope.currentSection = {}; 6 6 $rootScope.currentSection = {};
$rootScope.UserService = UserService; 7 7 $rootScope.UserService = UserService;
8 $rootScope.ws_host = window.location.origin.replace('http', 'ws');
8 9
//UserService.getUserData().then(function(data) { 9 10 var ws = new WebSocket($rootScope.ws_host + '/ws/rce/?subscribe-broadcast');
// console.log(data); 10
// $rootScope.user = data; 11
//}); 12
/* $('.button-collapse').sideNav({ 13
menuWidth: 240, // Default is 240 14
edge: 'left', // Choose the horizontal origin 15
closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor 16
} 17
); */ 18
19
/* 20
$('.collapsible').collapsible({ 21
accordion: false // A setting that changes the collapsible behavior to expandable instead of the default accordion style 22
}); 23
*/ 24
25
/* 26
$('#dropdown-button').dropdown({ 27
closeOnClick: true; 28
}); 29
*/ 30
31
/* 32
$('#class-list').on('click',function(){ 33
$('#classDropdown').toggle(); 34
}) 35
*/ 36
37
var postlogin = function(data) { 38
$scope.user = data; 39
//UserService.redirectToDefaultState($state); 40
}; 41
if (UserService.isLoggedIn()) { 42
postlogin(UserService.getUserData()); 43
} else { 44
UserService.getUserData().then(postlogin); 45
} 46
var loc = window.location, new_uri; 47
if (loc.protocol === 'https:') { 48
new_uri = 'wss:'; 49
} else { 50
new_uri = 'ws:'; 51
} 52
new_uri += '//' + loc.host; 53
var ws = new WebSocket(new_uri + '/ws/rce/?subscribe-broadcast'); 54
55
ws.onopen = function() { 56
console.log('websocket connected'); 57
}; 58
ws.onmessage = function(e) { 59 11 ws.onmessage = function(e) {
console.log('got websocket message ' + e.data); 60 12 console.log('got websocket message ' + e.data);
data = JSON.parse(e.data); 61 13 data = JSON.parse(e.data);
if (data.event_type == 'reload') { 62 14 if (data.event_type == 'reload') {
Materialize.toast('This page will refresh in 10 seconds and clear the template cache.', 10000, '', function() { 63 15 Materialize.toast('This page will refresh in 10 seconds and clear the template cache.', 10000, '', function() {
$templateCache.removeAll(); 64 16 $templateCache.removeAll();
$window.location.reload(); 65 17 $window.location.reload();
}); 66 18 });
} 67 19 }
if (data.event_type == 'eval') { 68 20 if (data.event_type == 'eval') {
eval(data.command); 69 21 eval(data.command);
} 70 22 }
}; 71
ws.onerror = function(e) { 72
console.error(e); 73
}; 74
ws.onclose = function(e) { 75
console.log('connection closed'); 76
}; 77 23 };
78 24
scripts/StudyController.js View file @ 0aff91d
angular.module('flashy.StudyController', ['ui.router']). 1 1 angular.module('flashy.StudyController', ['ui.router']).
2 2
controller('StudyController', ['$scope', '$stateParams', '$state', '$http', 'UserService', 3 3 controller('StudyController', ['$scope', '$stateParams', '$state', '$http', 'UserService',
function($scope, $stateParams, $state, $http, UserService) { 4 4 function($scope, $stateParams, $state, $http, UserService) {
console.log('Flashy study controller content in this file. also hell0'); 5 5 console.log('Flashy study controller content in this file. also hell0');
sectionId = $stateParams.sectionId; 6
$scope.isParamOpen = true; 7
8 6
$(document).ready(function() { 9 7 $(document).ready(function() {
$('.datepicker').pickadate({ 10 8 $('.datepicker').pickadate({
selectMonths: true, // Creates a dropdown to control month 11 9 selectMonths: true, // Creates a dropdown to control month
selectYears: 15 // Creates a dropdown of 15 years to control year 12 10 selectYears: 15 // Creates a dropdown of 15 years to control year
}); 13 11 });
14 12
$('select').material_select(); 15 13 $('select').material_select();
14
15 // Open by default
16 $('#content-x').slideDown(250).addClass('open');
}); 16 17 });
17 18
19 sectionId = $stateParams.sectionId;
20 $scope.isParamOpen = true;
$scope.UserService = UserService; 18 21 $scope.UserService = UserService;
$scope.isParamOpen = true; 19 22 $scope.isParamOpen = true;
20 23
console.log($scope.UserService.getUserData().sections); 21 24 console.log('user sections', $scope.UserService.getUserData().sections);
22 25
26 /* Sets current study class to the one passed in (y) */
$scope.toggleSectionToStudy = function(id) { 23 27 $scope.toggleSectionToStudy = function(id) {
console.log('toggle sect', id); 24 28 console.log('toggle sect', id);
$scope.sectionToStudy = id; 25 29 $scope.sectionToStudy = id;
}; 26 30 };
27 31
$scope.openParams = function() { 28 32 /* Opens or closes content collapsible */
$scope.isParamOpen = !$scope.isParamOpen; 29
}; 30
31
$scope.toggleContent = function(event, index) { 32 33 $scope.toggleContent = function(event, index) {
if ($('#content-x').hasClass('open')) { // let's close it 33 34 if ($('#content-x').hasClass('open')) { // let's close it
// Note: 250 is duration (ms) of animation 34 35 // Note: 250 is duration (ms) of animation
$('#content-x').slideUp(250).removeClass('open'); 35 36 $('#content-x').slideUp(250).removeClass('open');
} else { // let's open it 36 37 } else { // let's open it
$('#content-x').slideDown(250).addClass('open'); 37 38 $('#content-x').slideDown(250).addClass('open');
} 38 39 }
}; 39 40 };
40 41
41 42
/* 42
$scope.fetchQuiz = function(a, b) { 43
//console.log($scope.startDate, $scope.endDate); 44
console.log(a, b); 45
console.log($('#start-date').val()); 46
}; 47
*/ 48
49
$scope.fetchQuiz = function() { 50 43 $scope.fetchQuiz = function() {
console.log('fetching quiz...'); 51 44 console.log('fetching quiz...');
45 console.log('study sect', $scope.sectionToStudy, parseInt($scope.sectionToStudy));
var studyRequest = { 52 46 var studyRequest = {
'sections': ($scope.sectionToStudy == null) ? [] : [$scope.sectionToStudy] 53 47 'sections': ($scope.sectionToStudy == null) ? [] : [parseInt($scope.sectionToStudy)]
}; 54 48 };
49 console.log('startdate:', new Date($('#start-date').val()));
console.log('enddate:', $('#end-date').val() + 'T00:00:00Z'); 55 50 console.log('enddate:', $('#end-date').val() + 'T00:00:00Z');
console.log('study sect', $scope.sectionToStudy); 56
57 51
58 52
$http.post('/api/study/', studyRequest). 59 53 $http.post('/api/study/', studyRequest).
success(function(data) { 60 54 success(function(data) {
console.log('Fetched card:', data); 61 55 console.log('Fetched card:', data);
}).error(function(err) { 62 56 }).error(function(err) {
57 console.log('Fetch Error');
}); 63 58 });
}; 64 59 };
65 60
/* OLD STUFF :in case you still neeed it */ 66 61 /* OLD STUFF :in case you still neeed it */
// Flashcard content 67 62 // Flashcard content
$scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk '; 68 63 $scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk ';
//single card 69 64 //single card
$scope.samples = 70 65 $scope.samples =
{ 71 66 {
'name': 'lol', 72 67 'name': 'lol',
'text': 'sample text here 111111 woo hoo I think it works', 73 68 'text': 'sample text here 111111 woo hoo I think it works',
'mask': [[0, 6], [16, 23]] 74 69 'mask': [[0, 6], [16, 23]]
}; 75 70 };
76 71
// get text to display as array 77 72 // get text to display as array
$scope.displayText = []; 78 73 $scope.displayText = [];
// get answers to blanks as array 79 74 // get answers to blanks as array
$scope.blankText = []; 80 75 $scope.blankText = [];
var start = 0; // where to start next string break 81 76 var start = 0; // where to start next string break
for (var i = 0; i < $scope.samples.mask.length; i++) { 82 77 for (var i = 0; i < $scope.samples.mask.length; i++) {
$scope.displayText.push($scope.samples.text.substring(start, $scope.samples.mask[i][0])); 83 78 $scope.displayText.push($scope.samples.text.substring(start, $scope.samples.mask[i][0]));
$scope.blankText.push($scope.samples.text.substring($scope.samples.mask[i][0], $scope.samples.mask[i][1])); 84 79 $scope.blankText.push($scope.samples.text.substring($scope.samples.mask[i][0], $scope.samples.mask[i][1]));
start = $scope.samples.mask[i][1]; 85 80 start = $scope.samples.mask[i][1];
} 86 81 }
if (start != $scope.samples.mask.length - 1) 87 82 if (start != $scope.samples.mask.length - 1)
//http://docs.casperjs.org/en/latest/modules/casper.html#captureselector 1 File was deleted
//Run with: casperjs --ssl-protocol=tlsv1 ss_test.js 2
3
var casper = require('casper').create({ 4
viewportSize: {width: 800, height: 600} 5
}); 6
7
casper.start().zoom(.9).thenOpen('https://flashy.cards/app/login', function() { 8
this.captureSelector('test2.png','.ng-scope' ); 9
styles/flashy.css View file @ 0aff91d
๏ปฟ.no-user-select { 1 1 ๏ปฟ.no-user-select {
-moz-user-select: none; 2 2 -moz-user-select: none;
-webkit-user-select: none; 3 3 -webkit-user-select: none;
-ms-user-select: none; 4 4 -ms-user-select: none;
user-select: none; 5 5 user-select: none;
} 6 6 }
7 7
.angucomplete-dropdown { 8 8 .angucomplete-dropdown {
border-color: #ececec; 9 9 border-color: #ececec;
border-width: 1px; 10 10 border-width: 1px;
border-style: solid; 11 11 border-style: solid;
border-radius: 2px; 12 12 border-radius: 2px;
/*width: 250px;*/ 13 13 /*width: 250px;*/
padding: 6px; 14 14 padding: 6px;
cursor: pointer; 15 15 cursor: pointer;
z-index: 9999; 16 16 z-index: 9999;
position: absolute; 17 17 position: absolute;
/*top: 32px; 18 18 /*top: 32px;
left: 0px; 19 19 left: 0px;
*/ 20 20 */
margin-top: -6px; 21 21 margin-top: -6px;
background-color: #ffffff; 22 22 background-color: #ffffff;
} 23 23 }
24 24
.angucomplete-description { 25 25 .angucomplete-description {
font-size: 14px; 26 26 font-size: 14px;
} 27 27 }
28 28
.angucomplete-row { 29 29 .angucomplete-row {
padding: 5px; 30 30 padding: 5px;
color: #000000; 31 31 color: #000000;
margin-bottom: 4px; 32 32 margin-bottom: 4px;
clear: both; 33 33 clear: both;
} 34 34 }
35 35
.angucomplete-selected-row { 36 36 .angucomplete-selected-row {
background-color: #aaaaff; 37 37 background-color: #aaaaff;
} 38 38 }
39 39
/*.container .row {*/ 40 40 /*.container .row {*/
/*margin-left: 0;*/ 41 41 /*margin-left: 0;*/
/*margin-right: 0;*/ 42 42 /*margin-right: 0;*/
/*}*/ 43 43 /*}*/
44 44
/* Flashcard directive css */ 45 45 /* Flashcard directive css */
.card { 46 46 .card {
word-wrap: break-word; 47 47 word-wrap: break-word;
} 48 48 }
49 49
.card.flashy.in-deck { 50 50 .card.flashy.in-deck {
border: 3px solid rgba(0, 184, 76, 0.4); 51 51 /*border: 3px solid rgba(0, 184, 76, 0.4);*/
} 52 52 }
53 53
.card.flashy { 54 54 .card.flashy {
border: 0px solid rgba(0, 184, 76, 0.4); 55 55 border: 0px solid rgba(0, 184, 76, 0.4);
background-color: #fff; 56 56 background-color: #fff;
font-family: 'Titillium Web', sans-serif; 57 57 font-family: 'Titillium Web', sans-serif;
float: left; 58 58 float: left;
text-align: center; 59 59 text-align: center;
margin: 6px; 60 60 margin: 6px;
} 61 61 }
62 62
.card-overlay { 63 63 .card-overlay {
cursor: pointer; 64 64 cursor: pointer;
left: 0; 65 65 left: 0;
opacity: 0; 66 66 opacity: 0;
position: absolute; 67 67 position: absolute;
/*pointer-events: none;*/ 68 68 /*pointer-events: none;*/
top: 0; 69 69 top: 0;
transition: visibility 0s cubic-bezier(0, 0, 0.6, 1) 0.0s, 70 70 transition: visibility 0s cubic-bezier(0, 0, 0.6, 1) 0.0s,
opacity 0.2s cubic-bezier(0, 0, 0.6, 1); 71 71 opacity 0.2s cubic-bezier(0, 0, 0.6, 1);
/* animation effect to appear on off-hover */ 72 72 /* animation effect to appear on off-hover */
visibility: hidden; 73 73 visibility: hidden;
height: 100%; 74 74 height: 100%;
width: 100%; 75 75 width: 100%;
} 76 76 }
77 77
.card-overlay i { 78 78 .card-overlay i {
color: #FFF; 79 79 color: #FFF;
left: 50%; 80 80 left: 50%;
position: absolute; 81 81 position: absolute;
top: 50%; 82 82 top: 50%;
transform: translate(-50%, -50%); 83 83 transform: translate(-50%, -50%);
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; 84 84 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s;
} 85 85 }
86 86
.center-me:hover i { 87 87 .center-me:hover i {
text-shadow: 0 0 15px rgba(255, 255, 255, 0.9); 88 88 text-shadow: 0 0 15px rgba(255, 255, 255, 0.9);
} 89 89 }
90 90
.card:hover .card-overlay { 91 91 .card:hover .card-overlay {
opacity: 1.0; 92 92 opacity: 1.0;
transition-delay: 0s; /* animation effect to appear on hover */ 93 93 transition-delay: 0s; /* animation effect to appear on hover */
visibility: visible; 94 94 visibility: visible;
} 95 95 }
96 96
.top-box { 97 97 .top-box {
background-color: rgba(0, 184, 76, 0.4); 98 98 background-color: rgba(0, 184, 76, 0.4);
height: 65%; 99 99 height: 65%;
position: relative; 100 100 position: relative;
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; 101 101 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s;
width: 100%; 102 102 width: 100%;
} 103 103 }
104 104
.top-box:hover { 105 105 .top-box:hover {
background-color: rgba(0, 184, 76, 0.5); 106 106 background-color: rgba(0, 184, 76, 0.5);
} 107 107 }
108 108
.bottom-box { 109 109 .bottom-box {
height: 35%; 110 110 height: 35%;
width: 100%; 111 111 width: 100%;
} 112 112 }
113 113
.left-box { 114 114 .left-box {
background-color: rgba(119, 146, 255, 0.5); 115 115 background-color: rgba(119, 146, 255, 0.5);
float: left; 116 116 float: left;
position: relative; 117 117 position: relative;
height: 100%; 118 118 height: 100%;
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; 119 119 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s;
width: 50%; 120 120 width: 50%;
} 121 121 }
122 122
.left-box:hover { 123 123 .left-box:hover {
background-color: rgba(119, 146, 255, 0.6); 124 124 background-color: rgba(119, 146, 255, 0.6);
} 125 125 }
126 126
.right-box { 127 127 .right-box {
background-color: rgba(255, 62, 76, 0.5); 128 128 background-color: rgba(255, 62, 76, 0.5);
float: right; 129 129 float: right;
height: 100%; 130 130 height: 100%;
position: relative; 131 131 position: relative;
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; 132 132 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s;
width: 50%; 133 133 width: 50%;
} 134 134 }
135 135
.right-box:hover { 136 136 .right-box:hover {
background-color: rgba(255, 62, 76, 0.6); 137 137 background-color: rgba(255, 62, 76, 0.6);
} 138 138 }
139 139
.center-me { 140 140 .center-me {
height: 100%; 141 141 height: 100%;
margin: 0 auto; 142 142 margin: 0 auto;
text-align: center; 143 143 text-align: center;
vertical-align: middle; 144 144 vertical-align: middle;
width: 100%; 145 145 width: 100%;
} 146 146 }
147 147
/* Card Colors */ 148 148 /* Card Colors */
.card.flashy.cardcolor-blue div { 149 149 .card.flashy.cardcolor-blue div {
background-color: rgba(119, 158, 203, 0.5) !important; 150 150 background-color: rgba(119, 158, 203, 0.5) !important;
} 151 151 }
152 152
.cardcolor-red div { 153 153 .cardcolor-red div {
background-color: rgba(255, 105, 97, 0.5) !important; 154 154 background-color: rgba(255, 105, 97, 0.5) !important;
} 155 155 }
156 156
.cardcolor-green div { 157 157 .cardcolor-green div {
background-color: rgba(119, 190, 119, 0.5) !important; 158 158 background-color: rgba(119, 190, 119, 0.5) !important;
} 159 159 }
160 160
.cardcolor-yellow div { 161 161 .cardcolor-yellow div {
background-color: rgba(253, 253, 150, 0.5) !important; 162 162 background-color: rgba(253, 253, 150, 0.5) !important;
} 163 163 }
164 164
/* Card Colors END */ 165 165 /* Card Colors END */
166 166
.modal.bottom-sheet { 167 167 .modal.bottom-sheet {
max-width: 600px; 168 168 max-width: 600px;
margin-left: auto; 169 169 margin-left: auto;
margin-right: auto; 170 170 margin-right: auto;
} 171 171 }
172 172
.feed-modal-input { 173 173 .feed-modal-input {
background-color: #D3D3D3; 174 174 background-color: #D3D3D3;
border-style: solid; 175 175 border-style: solid;
border-width: 1px; 176 176 border-width: 1px;
box-shadow: 2px 2px 5px #888888; 177 177 box-shadow: 2px 2px 5px #888888;
height: 24px; 178 178 height: 24px;
} 179 179 }
180 180
.input-field label { 181 181 .input-field label {
color: #00b3c2; 182 182 color: #00b3c2;
} 183 183 }
184 184
/* label focus color */ 185 185 /* label focus color */
.input-field input[type]:focus + label { 186 186 .input-field input[type]:focus + label {
color: #00b3c2; 187 187 color: #00b3c2;
} 188 188 }
189 189
/* label underline focus color */ 190 190 /* label underline focus color */
.input-field input[type]:focus { 191 191 .input-field input[type]:focus {
border-bottom: 1px solid #00b3c2; 192 192 border-bottom: 1px solid #00b3c2;
box-shadow: 0 1px 0 0 #b388ff; 193 193 box-shadow: 0 1px 0 0 #b388ff;
} 194 194 }
195 195
/* valid color */ 196 196 /* valid color */
.input-field input[type].valid { 197 197 .input-field input[type].valid {
border-bottom: 1px solid #00c28f; 198 198 border-bottom: 1px solid #00c28f;
box-shadow: 0 1px 0 0 #673ab7; 199 199 box-shadow: 0 1px 0 0 #673ab7;
} 200 200 }
201 201
/* invalid color */ 202 202 /* invalid color */
.input-field input[type].invalid { 203 203 .input-field input[type].invalid {
border-bottom: 1px solid #673ab7; 204 204 border-bottom: 1px solid #673ab7;
box-shadow: 0 1px 0 0 #673ab7; 205 205 box-shadow: 0 1px 0 0 #673ab7;
} 206 206 }
207 207
/* icon prefix focus color */ 208 208 /* icon prefix focus color */
.input-field .prefix.active { 209 209 .input-field .prefix.active {
color: #b388ff; 210 210 color: #b388ff;
} 211 211 }
212 212
/* label focus color */ 213 213 /* label focus color */
.input-field textarea[type]:focus + label { 214 214 .input-field textarea[type]:focus + label {
color: #b388ff; 215 215 color: #b388ff;
} 216 216 }
217 217
/* label underline focus color */ 218 218 /* label underline focus color */
.input-field textarea[type]:focus { 219 219 .input-field textarea[type]:focus {
border-bottom: 1px solid #00b3c2; 220 220 border-bottom: 1px solid #00b3c2;
box-shadow: 0 1px 0 0 #b388ff; 221 221 box-shadow: 0 1px 0 0 #b388ff;
} 222 222 }
223 223
body { 224 224 body {
background-color: #e8e8e8; 225 225 background-color: #e8e8e8;
overflow-x: hidden; 226 226 overflow-x: hidden;
font-family: 'Titillium Web', sans-serif; 227 227 font-family: 'Titillium Web', sans-serif;
height: 100%; 228 228 height: 100%;
} 229 229 }
230 230
html { 231 231 html {
background: transparent; 232 232 background: transparent;
height: 100%; 233 233 height: 100%;
} 234 234 }
235 235
.btn { 236 236 .btn {
background-color: #00b3c2; 237 237 background-color: #00b3c2;
} 238 238 }
239 239
.btn:hover { 240 240 .btn:hover {
background-color: #0097cb; 241 241 background-color: #0097cb;
} 242 242 }
243 243
.btn-floating { 244 244 .btn-floating {
background-color: #00b3c2; 245 245 background-color: #00b3c2;
} 246 246 }
247 247
.btn-floating:hover { 248 248 .btn-floating:hover {
background-color: #0097cb; 249 249 background-color: #0097cb;
} 250 250 }
251 251
.toggley { 252 252 .toggley {
float: left; 253 253 float: left;
margin: 10px; 254 254 margin: 10px;
} 255 255 }
256 256
#logo-container { 257 257 #logo-container {
margin-bottom: 18px; 258 258 margin-bottom: 18px;
} 259 259 }
260 260
#lean-overlay { 261 261 #lean-overlay {
display: none !important; 262 262 display: none !important;
} 263 263 }
264 264
nav { 265 265 nav {
background-color: #d2143f !important; 266 266 background-color: #d2143f !important;
} 267 267 }
268 268
main { 269 269 main {
min-height: 145px; 270 270 min-height: 145px;
} 271 271 }
272 272
.side-nav .collapsible-body { 273 273 .side-nav .collapsible-body {
width: 100%; 274 274 width: 100%;
} 275 275 }
276 276
.side-nav .collapsible-body li.active, .side-nav.fixed .collapsible-body li.active { 277 277 .side-nav .collapsible-body li.active, .side-nav.fixed .collapsible-body li.active {
background-color: #00b3c2; 278 278 background-color: #00b3c2;
} 279 279 }
280 280
nav .button-collapse { 281 281 nav .button-collapse {
margin: 0 20px; 282 282 margin: 0 20px;
} 283 283 }
284 284
.collapsible-body i { 285 285 .collapsible-body i {
font-size: 1rem !important; 286 286 font-size: 1rem !important;
} 287 287 }
288 288
.tabs .tab a { 289 289 .tabs .tab a {
color: #00b3c2; 290 290 color: #00b3c2;
} 291 291 }
292 292
.tabs .tab a:hover { 293 293 .tabs .tab a:hover {
color: #0041dd; 294 294 color: #0041dd;
} 295 295 }
296 296
.tabs .indicator { 297 297 .tabs .indicator {
border-bottom: 1px solid #00b3c2; 298 298 border-bottom: 1px solid #00b3c2;
} 299 299 }
300 300
h2 { 301 301 h2 {
text-align: center; 302 302 text-align: center;
} 303 303 }
304 304
md-content.md-default-theme { 305 305 md-content.md-default-theme {
background-color: rgba(255, 255, 255, 0); 306 306 background-color: rgba(255, 255, 255, 0);
border: 1px solid #fff; 307 307 border: 1px solid #fff;
} 308 308 }
309 309
/*#sidenav-overlay { 310 310 /*#sidenav-overlay {
background-color: rgba(0, 0, 0, 0) !important; 311 311 background-color: rgba(0, 0, 0, 0) !important;
}*/ 312 312 }*/
.card-content { 313 313 .card-content {
width: 100%; 314 314 width: 100%;
} 315 315 }
316 316
.valign-wrapper { 317 317 .valign-wrapper {
height: 100%; 318 318 height: 100%;
} 319 319 }
320 320
/*.toast { 321 321 /*.toast {
height: 100px; 322 322 height: 100px;
width: 300px; 323 323 width: 300px;
line-height: 20px; 324 324 line-height: 20px;
max-height: 100px; 325 325 max-height: 100px;
word-wrap: normal; 326 326 word-wrap: normal;
}*/ 327 327 }*/
328 328
[ng-cloak] { 329 329 [ng-cloak] {
display: none !important; 330 330 display: none !important;
} 331 331 }
332 332
.cardColumn { 333 333 .cardColumn {
float: left; 334 334 float: left;
} 335 335 }
336 336
/* Animation CSS, http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html */ 337 337 /* Animation CSS, http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html */
.repeated-card.ng-enter, 338 338 .repeated-card.ng-enter,
.repeated-card.ng-enter > flashcard > .card, 339 339 .repeated-card.ng-enter > flashcard > .card,
.repeated-card.ng-leave, 340 340 .repeated-card.ng-leave,
.repeated-card.ng-leave > flashcard > .card, 341 341 .repeated-card.ng-leave > flashcard > .card,
.repeated-card.ng-move, 342 342 .repeated-card.ng-move,
.repeated-card.ng-move > flashcard > .card { 343 343 .repeated-card.ng-move > flashcard > .card {
-webkit-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); 344 344 -webkit-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1);
-moz-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); 345 345 -moz-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1);
-o-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); 346 346 -o-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1);
transition: 1s all cubic-bezier(0.6, 0.3, 0.7, 1.0); 347 347 transition: 1s all cubic-bezier(0.6, 0.3, 0.7, 1.0);
position: relative; 348 348 position: relative;
} 349 349 }
350 350
.repeated-card.ng-enter > flashcard > .card { 351 351 .repeated-card.ng-enter > flashcard > .card {
z-index: 1; 352 352 z-index: 1;
top: -236px; 353 353 top: -236px;
margin-bottom: -230px; 354 354 margin-bottom: -230px;
} 355 355 }
356 356
.repeated-card.ng-enter.ng-enter-active > flashcard > .card { 357 357 .repeated-card.ng-enter.ng-enter-active > flashcard > .card {
top: 0px; 358 358 top: 0px;
margin-bottom: 6px; 359 359 margin-bottom: 6px;
} 360 360 }
361 361
.repeated-card.ng-leave > flashcard > .card { 362 362 .repeated-card.ng-leave > flashcard > .card {
z-index: -100; 363 363 z-index: -100;
top: 0px; 364 364 top: 0px;
margin-bottom: 6px; 365 365 margin-bottom: 6px;
} 366 366 }
367 367
.repeated-card.ng-leave.ng-leave-active > flashcard > .card { 368 368 .repeated-card.ng-leave.ng-leave-active > flashcard > .card {
z-index: -100; 369 369 z-index: -100;
opacity: 0; 370 370 opacity: 0;
top: -236px; 371 371 top: -236px;
margin-bottom: -230px; 372 372 margin-bottom: -230px;
} 373 373 }
374 374
.repeated-card.ng-move > flashcard > .card { 375 375 .repeated-card.ng-move > flashcard > .card {
background-color:blue; 376 376 background-color:blue;
top: -250px; 377 377 top: -250px;
} 378 378 }
379 379
.repeated-card.ng-move-active > flashcard > .card { 380 380 .repeated-card.ng-move-active > flashcard > .card {
top: 0 381 381 top: 0
} 382 382 }
383 383
.repeated-card.ng-move > flashcard > .card + div { 384 384 .repeated-card.ng-move > flashcard > .card + div {
background-color:red; 385 385 background-color:red;
top: -250px; 386 386 top: -250px;
} 387 387 }
388 388
templates/cardlist.html View file @ 0aff91d
<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
templates/study.html View file @ 0aff91d
<div class="container"> 1 1 <div class="container">
<ul class="collection st-accordion"> 2 2 <ul class="collection st-accordion">
<li class="st-accordion--item"> 3 3 <li class="st-accordion--item">
<div class="st-accordion--header" ng-click="toggleContent($event, $index)"> 4 4 <div class="st-accordion--header" ng-click="toggleContent($event, $index)">
<i class="mdi-image-filter-drama"></i> 5 5 <i class="mdi-image-filter-drama"></i>
Choose what to study 6 6 Choose what to study
</div> 7 7 </div>
<div id="content-x" class="st-accordion--content"> 8 8 <div id="content-x" class="st-accordion--content">
<!-- lots of difficulty with materializecss select and angularjs. If we want to 9 9 <!-- lots of difficulty with materializecss select and angularjs. If we want to
refactor into a select(which prob looks better), maybe refer to this article: 10 10 refactor into a select(which prob looks better), maybe refer to this article:
http://stackoverflow.com/questions/29402495/values-not-showing-up-in-select-button 11 11 http://stackoverflow.com/questions/29402495/values-not-showing-up-in-select-button
--> 12 12 -->
<!-- Also suffered huge casualties trying to do radios...let's just do buttons... 13 13 <!-- Also suffered huge casualties trying to do radios...let's just do buttons...
--> 14 14 -->
15
<!-- Default: all classes button --> 15 16 <!-- Default: all classes button -->
<!-- Button for classes --> 16 17 <!-- Button for classes -->
<div class="card"> 17 18 <div class="card">
<!-- Default: all classes button --> 18 19 <!-- Default: all classes button -->
<a class="waves-effect waves-light btn toggley" 19 20 <a class="waves-effect waves-light btn toggley"
ng-init="sectionToStudy = null" 20 21 ng-init="sectionToStudy = null"
ng-click="toggleSectionToStudy(null)" 21 22 ng-click="toggleSectionToStudy(null)"
ng-class="{'pink white-text': sectionToStudy == null}"> 22 23 ng-class="{'pink white-text': sectionToStudy == null}">
All classes</a> 23 24 All classes</a>
24 25
<!-- Buttons of rest of classes --> 25 26 <!-- Buttons of rest of classes -->
<div ng-repeat="section in UserService.getUserData().sections"> 26 27 <div ng-repeat="section in UserService.getUserData().sections">
<a class="waves-effect waves-light btn toggley" 27 28 <a class="waves-effect waves-light btn toggley"
ng-click="toggleSectionToStudy(section.id)" 28 29 ng-click="toggleSectionToStudy(section.id)"
ng-class="{'pink white-text': sectionToStudy == section.id}"> 29 30 ng-class="{'pink white-text': sectionToStudy == section.id}">
{{section.short_name}} 30 31 {{section.short_name}}
</a> 31 32 </a>
</div> 32 33 </div>
</div> <!-- end of buttons for classes --> 33 34 </div> <!-- end of buttons for classes -->
<div class="row"> 34 35 <div class="row">
<div class="card"> 35 36 <div class="card">
<h3>Choose Date</h3> 36 37 <h3>Choose Date</h3>
<input id="start-date" type="date" class="" ng-model="startDate" placeholder="Start Date"/> 37 38 <input id="start-date" type="date" class="" ng-model="startDate" placeholder="Start Date"/>
<input id="end-date" type="date" class="" ng-model"endDate" placeholder="End Date"/> 38 39 <input id="end-date" type="date" class="" ng-model"endDate" placeholder="End Date"/>
</div> 39 40 </div>
</div> 40 41 </div>
41 42
</div> <!-- end of #content-x --> 42 43 </div> <!-- end of #content-x -->
</li> 43 44 </li>
</ul> 44 45 </ul>
45 46
<div class="row"> 46 47 <div class="row">
<div class="card-action"> 47 48 <div class="card-action">
<button class="btn waves-effect waves-light" ng-click="fetchQuiz()"> 48 49 <button class="btn waves-effect waves-light" ng-click="fetchQuiz()">
Fetch! 49 50 Fetch!
<i class="mdi-content-send right"></i> 50 51 <i class="mdi-content-send right"></i>
</button> 51 52 </button>
</div> 52 53 </div>
</div> 53 54 </div>
54 55
55 56
<!-- Fetched card "quiz" --> 56 57 <!-- Fetched card "quiz" -->
<div class="row"> 57 58 <div class="row">
<div class="card"> 58 59 <div class="card">
<div class="card-content"> 59 60 <div class="card-content">
<span ng-repeat="display in displayText">{{display}}<input ng-model="blank[displayText.indexOf(display)]" ng-show="displayText.indexOf(display) < blankText.length" class="" type="text"/></span> 60 61 <span ng-repeat="display in displayText">{{display}}<input ng-model="blank[displayText.indexOf(display)]" ng-show="displayText.indexOf(display) < blankText.length" class="" type="text"/></span>
</div> 61 62 </div>
<div class="card-action"> 62 63 <div class="card-action">
<button class="btn waves-effect waves-light" type="submit" ng-click="checkAnswer()" style="position: relative">Check 63 64 <button class="btn waves-effect waves-light" type="submit" ng-click="checkAnswer()" style="position: relative">Check
<i class="mdi-content-send right"></i> 64 65 <i class="mdi-content-send right"></i>