Commit df5215d6528a61305f0630bfc534d49cad12e01e

Authored by Rohan Rangray

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

Mergin conflicts after delayed pull

Showing 12 changed files Inline Diff

angular.module('flashy', [ 1 1 angular.module('flashy', [
'flashy.LogoutController', 2 2 'flashy.LogoutController',
'flashy.LoginController', 3 3 'flashy.LoginController',
'flashy.RootController', 4 4 'flashy.RootController',
'flashy.FeedController', 5 5 'flashy.FeedController',
'flashy.DeckController', 6 6 'flashy.DeckController',
'flashy.ClassAddController', 7 7 'flashy.ClassAddController',
'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.SelectDirective', 12 12 //'flashy.SelectDirective',
// DOESNT WORK RN 13 13 // DOESNT WORK RN
'flashy.ResetPasswordController', 14 14 'flashy.ResetPasswordController',
'flashy.VerifyEmailController', 15 15 'flashy.VerifyEmailController',
'flashy.CardListController', 16 16 'flashy.CardListController',
'flashy.HelpController', 17 17 'flashy.HelpController',
'flashy.SettingsController', 18 18 'flashy.SettingsController',
'ngCookies']). 19 19 'ngCookies']).
config(function($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) { 20 20 config(function($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) {
'use strict'; 21 21 'use strict';
$httpProvider.defaults.withCredentials = true; 22 22 $httpProvider.defaults.withCredentials = true;
$httpProvider.defaults.xsrfCookieName = 'csrftoken'; 23 23 $httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; 24 24 $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
$resourceProvider.defaults.stripTrailingSlashes = false; 25 25 $resourceProvider.defaults.stripTrailingSlashes = false;
var arrayMethods = Object.getOwnPropertyNames(Array.prototype); 26 26 var arrayMethods = Object.getOwnPropertyNames(Array.prototype);
arrayMethods.forEach(attachArrayMethodsToNodeList); 27 27 arrayMethods.forEach(attachArrayMethodsToNodeList);
function attachArrayMethodsToNodeList(methodName) { 28 28 function attachArrayMethodsToNodeList(methodName) {
if (methodName !== 'length') { 29 29 if (methodName !== 'length') {
NodeList.prototype[methodName] = Array.prototype[methodName]; 30 30 NodeList.prototype[methodName] = Array.prototype[methodName];
} 31 31 }
} 32 32 }
33 33
$httpProvider.interceptors.push(function($q, $rootScope) { 34 34 $httpProvider.interceptors.push(function($q, $rootScope) {
return { 35 35 return {
'responseError': function(rejection) { // need a better redirect 36 36 'responseError': function(rejection) { // need a better redirect
if (rejection.status >= 500) { 37 37 if (rejection.status >= 500) {
console.log('got error'); 38 38 console.log('got error');
console.log(rejection); 39 39 console.log(rejection);
$rootScope.$broadcast('server_error', rejection); 40 40 $rootScope.$broadcast('server_error', rejection);
} 41 41 }
if (rejection.status == 403) { 42 42 if (rejection.status == 403) {
console.log(rejection); 43 43 console.log(rejection);
if (rejection.data && rejection.data.detail == 'Please verify your email before continuing') { 44 44 if (rejection.data && rejection.data.detail == 'Please verify your email before continuing') {
$rootScope.$broadcast('account_locked'); 45 45 UserService.showLockedMessage();
46 UserService.logout();
} 46 47 }
} 47 48 }
return $q.reject(rejection); 48 49 return $q.reject(rejection);
} 49 50 }
}; 50 51 };
}); 51 52 });
$locationProvider.html5Mode(true); 52 53 $locationProvider.html5Mode(true);
$urlRouterProvider.otherwise('/404'); 53 54 $urlRouterProvider.otherwise('/404');
var auth_resolve = { 54 55 var auth_resolve = {
authorize: function($q, $state, $stateParams, UserService) { 55 56 authorize: function($q, $state, $stateParams, UserService) {
console.log('resolving user before continuing'); 56 57 if (UserService.noAuthRequired($state)) {
58 return console.log('no auth state ' + $state.name);
59 }
60 console.log('resolving user before continuing for ' + $state.name);
var redirectAsNeeded = function() { 57 61 var redirectAsNeeded = function() {
if (!UserService.isLoggedIn()) { 58 62 if (!UserService.isLoggedIn()) {
console.log(UserService.getUserData()); 59 63 console.log(UserService.getUserData());
console.log('making the user log in'); 60 64 console.log('making the user log in');
$state.go('login'); 61 65 $state.go('login');
} 62 66 }
if (!UserService.authorizedFor($state, $stateParams)) { 63 67 if (!UserService.authorizedFor($state, $stateParams)) {
68 console.log('user not authorized for ' + $state.name);
$state.go('addclass'); 64 69 $state.go('addclass');
} 65 70 }
}; 66 71 };
if (UserService.isResolved()) return redirectAsNeeded(); 67 72 if (UserService.isResolved()) return redirectAsNeeded();
return UserService.getUserData().then(redirectAsNeeded); 68 73 return UserService.getUserData().then(redirectAsNeeded);
} 69 74 }
}; 70 75 };
$stateProvider. 71 76 $stateProvider.
state('login', { 72 77 state('login', {
url: '/login', 73 78 url: '/login',
templateUrl: 'templates/login.html', 74 79 templateUrl: 'templates/login.html',
controller: 'LoginController' 75 80 controller: 'LoginController'
}). 76 81 }).
state('logout', { 77 82 state('logout', {
resolve: auth_resolve, 78 83 resolve: auth_resolve,
url: '/logout', 79 84 url: '/logout',
templateUrl: 'templates/logout.html', 80 85 templateUrl: 'templates/logout.html',
controller: 'LogoutController' 81 86 controller: 'LogoutController'
}). 82 87 }).
state('root', { 83 88 state('root', {
resolve: auth_resolve, 84 89 resolve: auth_resolve,
url: '', 85 90 url: '',
controller: 'RootController' 86 91 controller: 'RootController'
}). 87 92 }).
state('feed', { 88 93 state('feed', {
resolve: auth_resolve, 89 94 resolve: auth_resolve,
url: '/feed/{sectionId}', 90 95 url: '/feed/{sectionId}',
templateUrl: 'templates/feed.html', 91 96 templateUrl: 'templates/feed.html',
controller: 'FeedController' 92 97 controller: 'FeedController'
}). 93 98 }).
state('cardlist', { 94 99 state('cardlist', {
resolve: auth_resolve, 95 100 resolve: auth_resolve,
url: '/cards/{sectionId}', 96 101 url: '/cards/{sectionId}',
templateUrl: 'templates/cardlist.html', 97 102 templateUrl: 'templates/cardlist.html',
controller: 'CardListController' 98 103 controller: 'CardListController'
}). 99 104 }).
state('addclass', { 100 105 state('addclass', {
resolve: auth_resolve, 101 106 resolve: auth_resolve,
url: '/addclass', 102 107 url: '/addclass',
templateUrl: 'templates/addclass.html', 103 108 templateUrl: 'templates/addclass.html',
controller: 'ClassAddController' 104 109 controller: 'ClassAddController'
}). 105 110 }).
state('deck', { 106 111 state('deck', {
resolve: auth_resolve, 107 112 resolve: auth_resolve,
url: '/deck/{sectionId}', 108 113 url: '/deck/{sectionId}',
templateUrl: 'templates/deck.html', 109 114 templateUrl: 'templates/deck.html',
controller: 'DeckController' 110 115 controller: 'DeckController'
}). 111 116 }).
state('study', { 112 117 state('study', {
resolve: auth_resolve, 113 118 resolve: auth_resolve,
url: '/study', 114 119 url: '/study',
templateUrl: 'templates/study.html', 115 120 templateUrl: 'templates/study.html',
controller: 'StudyController' 116 121 controller: 'StudyController'
}). 117 122 }).
state('flashcard', { 118 123 state('flashcard', {
resolve: auth_resolve, 119 124 resolve: auth_resolve,
url: '/flashcard', 120 125 url: '/flashcard',
templateUrl: 'templates/flashcard.html', 121 126 templateUrl: 'templates/flashcard.html',
controller: 'FlashcardController' 122 127 controller: 'FlashcardController'
}). 123 128 }).
state('settings', { 124 129 state('settings', {
resolve: auth_resolve, 125 130 resolve: auth_resolve,
url: '/settings', 126 131 url: '/settings',
templateUrl: 'templates/settings.html', 127 132 templateUrl: 'templates/settings.html',
controller: 'SettingsController' 128 133 controller: 'SettingsController'
}). 129 134 }).
state('requestpasswordreset', { 130 135 state('requestpasswordreset', {
url: '/requestpasswordreset', 131 136 url: '/requestpasswordreset',
templateUrl: 'templates/requestpasswordreset.html', 132 137 templateUrl: 'templates/requestpasswordreset.html',
controller: 'RequestResetController' 133 138 controller: 'RequestResetController'
}). 134 139 }).
state('resetpassword', { 135 140 state('resetpassword', {
url: '/resetpassword/{uid}/{token}', 136 141 url: '/resetpassword/{uid}/{token}',
templateUrl: 'templates/resetpassword.html', 137 142 templateUrl: 'templates/resetpassword.html',
controller: 'ResetPasswordController' 138 143 controller: 'ResetPasswordController'
}). 139 144 }).
state('verifyemail', { 140 145 state('verifyemail', {
resolve: auth_resolve, 141
url: '/verifyemail/{key}', 142 146 url: '/verifyemail/{key}',
templateUrl: 'templates/verifyemail.html', 143 147 templateUrl: 'templates/verifyemail.html',
controller: 'VerifyEmailController' 144 148 controller: 'VerifyEmailController'
}). 145 149 }).
state('404', { 146 150 state('404', {
url: '/404', 147 151 url: '/404',
template: "<h1>This page doesn't exist!</h1>" 148 152 template: "<h1>This page doesn't exist!</h1>"
}). 149 153 }).
state('help', { 150 154 state('help', {
resolve: auth_resolve, 151 155 resolve: auth_resolve,
url: '/help', 152 156 url: '/help',
templateUrl: 'templates/help.html', 153 157 templateUrl: 'templates/help.html',
controller: 'HelpController' 154 158 controller: 'HelpController'
}); 155 159 });
}). 156 160 }).
run(function($rootScope, $state, $stateParams, $location, UserService) { 157 161 run(function($rootScope, $state, $stateParams, $location, UserService) {
$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) { 158 162 $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
console.log('failed to change state: ' + error); 159 163 console.log('failed to change state: ' + error);
$state.go('login'); 160 164 $state.go('login');
}); 161 165 });
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { 162 166 $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
if (['feed', 'deck', 'cardlist'].indexOf(toState.name) >= 0) { 163 167 if (['feed', 'deck', 'cardlist'].indexOf(toState.name) >= 0) {
localStorage.setItem('last_state', toState.name); 164 168 localStorage.setItem('last_state', toState.name);
localStorage.setItem('last_state_params', JSON.stringify(toParams)); 165 169 localStorage.setItem('last_state_params', JSON.stringify(toParams));
} 166 170 }
}); 167 171 });
}); 168 172 });
169 173
<!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">
8 8
<link 9 9 <link
href='http://fonts.googleapis.com/css?family=Lobster|Great+Vibes|Pacifico|Satisfy|Damion|Playball' 10 10 href='http://fonts.googleapis.com/css?family=Lobster|Great+Vibes|Pacifico|Satisfy|Damion|Playball'
rel='stylesheet' type='text/css'> 11 11 rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="styles/flashier.css"/> 12 12 <link rel="stylesheet" href="styles/flashier.css"/>
<link rel="stylesheet" href="styles/flashy.css"/> 13 13 <link rel="stylesheet" href="styles/flashy.css"/>
<link href='https://fonts.googleapis.com/css?family=Titillium+Web:200,200italic,300,600,400,900,700,400italic,700italic,300italic,600italic' 14 14 <link href='https://fonts.googleapis.com/css?family=Titillium+Web:200,200italic,300,600,400,900,700,400italic,700italic,300italic,600italic'
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>
<!-- User's classes dropdown --> 25 25 <!-- User's classes dropdown -->
<ul id="classDropdown" class="dropdown-content"> 26 26 <ul id="classDropdown" class="dropdown-content">
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> 27 27 <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections">
<a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> 28 28 <a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a>
</li> 29 29 </li>
<li class="divider"></li> 30 30 <li class="divider"></li>
<li><a ui-sref="addclass">Add Class</a></li> 31 31 <li><a ui-sref="addclass">Add Class</a></li>
</ul> 32 32 </ul>
<ul> 33 33 <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" 34 34 <li><a style="font-size:20px; font-weight:700" class="dropdown-button ng-cloak hide-on-small-and-down"
href="#!" 35 35 href="#!"
data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i 36 36 data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i
class="mdi-navigation-arrow-drop-down right"></i></a></li> 37 37 class="mdi-navigation-arrow-drop-down right"></i></a></li>
</ul> 38 38 <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})"
<ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> 39 39 class="tooltipped"
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" 40 40 data-position="bottom"
data-position="bottom" 41 41 data-delay="50" data-tooltip="Feed"><i
data-delay="50" data-tooltip="Feed"><i 42
class="mdi-action-view-module"></i></a></li> 43 42 class="mdi-action-view-module"></i></a></li>
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" 44 43 <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})"
data-position="bottom" 45 44 class="tooltipped"
data-delay="50" data-tooltip="Deck"><i 46 45 data-position="bottom"
46 data-delay="50" data-tooltip="Deck"><i
class="mdi-action-view-carousel"></i></a></li> 47 47 class="mdi-action-view-carousel"></i></a></li>
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" 48 48 <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})"
data-position="bottom" 49 49 class="tooltipped"
data-delay="50" data-tooltip="Card List"><i 50 50 data-position="bottom"
51 data-delay="50" data-tooltip="Card List"><i
class="mdi-action-view-list"></i></a></li> 51 52 class="mdi-action-view-list"></i></a></li>
</ul> 52 53 </ul>
<a href="#" class="brand-logo center">Flashy</a> 53 54 <a href="#" class="brand-logo center">Flashy</a>
54 55
<ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down"> 55 56 <ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down">
56 57
<li ui-sref-active="active"><a ui-sref="study" class="tooltipped" data-position="bottom" data-delay="50" 57 58 <li ui-sref-active="active"><a ui-sref="study" class="tooltipped" data-position="bottom" data-delay="50"
data-tooltip="Study"> 58 59 data-tooltip="Study">
<i class="tiny mdi-action-pageview"></i></a></li> 59 60 <i class="tiny mdi-action-pageview"></i></a></li>
60 61
<!-- Settings Dropdown --> 61 62 <!-- Settings Dropdown -->
<ul id="settingsDropdown" class="dropdown-content"> 62 63 <ul id="settingsDropdown" class="dropdown-content">
<li><a ui-sref="settings">Settings</a></li> 63 64
<li><a ui-sref="logout">Logout</a></li> 64 65
</ul> 65 66 </ul>
67
<li ui-sref-active="active"><a ui-sref="help"><i class="tiny mdi-action-help tooltipped" 66 68 <li ui-sref-active="active"><a ui-sref="help"><i class="tiny mdi-action-help tooltipped"
data-position="bottom" 67 69 data-position="bottom"
data-delay="50" data-tooltip="Help"></i></a></li> 68 70 data-delay="50" data-tooltip="Help"></i></a></li>
69 71 <li ui-sref-active="active"><a ui-sref="settings"><i data-position="bottom" data-delay="50"
<li><a class="dropdown-button ng-cloak" href="#!" data-activates="settingsDropdown"><i 70 72 data-tooltip="Settings"
class="tiny mdi-action-settings"></i></a></li> 71 73 class="mdi-action-settings tooltipped"></i></a></li>
74 <li><a ui-sref="logout"><i data-position="bottom" data-delay="50" data-tooltip="Logout"
75 class="mdi-content-forward tooltipped"></i></a></li>
72 76
73 77
</ul> 74 78 </ul>
75 79
<!-- Slide-in side-nav for small screens --> 76 80 <!-- Slide-in side-nav for small screens -->
<ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> 77 81 <ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo">
<span ng-show="currentSection.id"> 78 82 <span ng-show="currentSection.id">
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped"> 79 83 <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped">
<i class="mdi-action-view-module left"></i> 80 84 <i class="mdi-action-view-module left"></i>
Feed</a> 81 85 Feed</a>
</li> 82 86 </li>
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped"> 83 87 <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped">
<i class="mdi-action-view-carousel left"> </i> 84 88 <i class="mdi-action-view-carousel left"> </i>
Deck 85 89 Deck
</a> 86 90 </a>
</li> 87 91 </li>
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped"> 88 92 <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped">
<i class="mdi-action-view-list left"></i> 89 93 <i class="mdi-action-view-list left"></i>
Card List 90 94 Card List
</a> 91 95 </a>
</li> 92 96 </li>
<hr> 93 97 <hr>
</span> 94 98 </span>
<!-- Collapsible menu for all the User's classes --> 95 99 <!-- Collapsible menu for all the User's classes -->
<ul class="collapsible" data-collapsible="accordion"> 96 100 <ul class="collapsible" data-collapsible="accordion">
<li class="bold"> 97 101 <li class="bold">
<a class="collapsible-header black-text"> 98 102 <a class="collapsible-header black-text">
Classes 99 103 Classes
<i class="mdi-navigation-arrow-drop-down right"></i> 100 104 <i class="mdi-navigation-arrow-drop-down right"></i>
</a> 101 105 </a>
</li> 102 106 </li>
<div class="collapsible-body" style="display: block"> 103 107 <div class="collapsible-body" style="display: block">
<ul> 104 108 <ul>
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> 105 109 <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> 106 110 <a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a>
</li> 107 111 </li>
<hr> 108 112 <hr>
<li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> 109 113 <li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li>
</ul> 110 114 </ul>
</div> 111 115 </div>
</ul> 112 116 </ul>
<li><a ui-sref="study">Study</a></li> 113 117 <li><a ui-sref="study">Study</a></li>
<li><a ui-sref="settings">Settings</a></li> 114 118 <li><a ui-sref="settings">Settings</a></li>
<li><a ui-sref="logout">Logout</a></li> 115 119 <li><a ui-sref="logout">Logout</a></li>
</ul> 116 120 </ul>
</div> 117 121 </div>
</nav> 118 122 </nav>
119 123
</header> 120 124 </header>
121 125
122 126
<!-- Menu Bar --> 123 127 <!-- Menu Bar -->
124 128
<div class="wrapper"> 125 129 <div class="wrapper">
126 130
<main ui-view></main> 127 131 <main ui-view></main>
128 132
<div class="push"></div> 129 133 <div class="push"></div>
</div> 130 134 </div>
131 135
132 136
<footer class="page-footer"> 133 137 <footer class="page-footer">
<div class="footer-copyright"> 134 138 <div class="footer-copyright">
<div class="container"> 135 139 <div class="container">
&copy; 2015 Team Swag 136 140 &copy; 2015 Team Swag
<a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by 137 141 <a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by
email!</a> 138 142 email!</a>
</div> 139 143 </div>
140 144
</div> 141 145 </div>
</footer> 142 146 </footer>
143 147
</body> 144 148 </body>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> 145 149 <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> 146 150 <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> 147 151 <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> 148 152 <script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="scripts/materialize.js"></script> 149 153 <script type="text/javascript" src="scripts/materialize.js"></script>
<script type="text/javascript" src="scripts/jquery.collapsible.js"></script> 150 154 <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> 151 155 <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> 152 156 <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> 153 157 <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> 154 158 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-resource.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script> 155 159 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script>
156 160
157 161
<script src="config.js"></script> 158 162 <script src="config.js"></script>
159 163
<!-- Controllers --> 160 164 <!-- Controllers -->
<script src="scripts/FeedController.js"></script> 161 165 <script src="scripts/FeedController.js"></script>
<script src="scripts/RootController.js"></script> 162 166 <script src="scripts/RootController.js"></script>
<script src="scripts/SettingsController.js"></script> 163 167 <script src="scripts/SettingsController.js"></script>
<script src="scripts/LoginController.js"></script> 164 168 <script src="scripts/LoginController.js"></script>
<script src="scripts/LogoutController.js"></script> 165 169 <script src="scripts/LogoutController.js"></script>
<script src="scripts/DeckController.js"></script> 166 170 <script src="scripts/DeckController.js"></script>
<script src="scripts/RequestResetController.js"></script> 167 171 <script src="scripts/RequestResetController.js"></script>
<script src="scripts/ClassAddController.js"></script> 168 172 <script src="scripts/ClassAddController.js"></script>
<script src="scripts/StudyController.js"></script> 169 173 <script src="scripts/StudyController.js"></script>
<script src="scripts/ResetPasswordController.js"></script> 170 174 <script src="scripts/ResetPasswordController.js"></script>
<script src="scripts/CardListController.js"></script> 171 175 <script src="scripts/CardListController.js"></script>
<script src="scripts/VerifyEmailController.js"></script> 172 176 <script src="scripts/VerifyEmailController.js"></script>
<script src="scripts/HelpController.js"></script> 173 177 <script src="scripts/HelpController.js"></script>
174 178
<!-- Services --> 175 179 <!-- Services -->
<script src="scripts/UserService.js"></script> 176 180 <script src="scripts/UserService.js"></script>
scripts/FeedController.js View file @ df5215d
angular.module('flashy.FeedController', ['ui.router', 'ngAnimate']). 1 1 angular.module('flashy.FeedController', ['ui.router', 'ngAnimate']).
2 2
controller('FeedController', function($scope, $rootScope, $stateParams, $state, $http, $window, $timeout, UserService) { 3 3 controller('FeedController', function($scope, $rootScope, $stateParams, $state, $http, $window, $timeout, UserService) {
console.log('Hello from feed'); 4 4 console.log('Hello from feed');
sectionId = parseInt($stateParams.sectionId); 5 5 sectionId = parseInt($stateParams.sectionId);
if (!UserService.isInSection(sectionId)) { 6 6 if (!UserService.isInSection(sectionId)) {
console.log('user is not enrolled in ' + sectionId); 7 7 console.log('user is not enrolled in ' + sectionId);
return $state.go('addclass'); 8 8 return $state.go('addclass');
} 9 9 }
$rootScope.currentSection = $rootScope.SectionResource.get({sectionId: sectionId}); 10 10 $rootScope.currentSection = $rootScope.SectionResource.get({sectionId: sectionId});
11 $rootScope.debug_flashcard = false;
$scope.cards = false; 11 12 $scope.cards = false;
$scope.cardCols = []; // organized data 12 13 $scope.cardCols = []; // organized data
$scope.numCols = 0; 13 14 $scope.numCols = 0;
15 $scope.cardTable = {}; // look up table of cards, {'colNum':col, 'obj':card}
14 16
15
function calculate_cols() { 16 17 function calculate_cols() {
var avail = $window.innerWidth - 17; 17 18 var avail = $window.innerWidth - 17;
return Math.max(1, Math.floor(avail / 250)); 18 19 return Math.max(1, Math.floor(avail / 250));
} 19 20 }
20 21
$scope.refreshColumnWidth = function() { 21 22 $scope.refreshColumnWidth = function() {
console.log('refreshing column width'); 22 23 console.log('refreshing column width');
avail = $window.innerWidth - 17; 23 24 avail = $window.innerWidth - 17;
width = Math.floor(avail / Math.floor(avail / 250)); 24 25 width = Math.floor(avail / Math.floor(avail / 250));
$('.cardColumn').css({ 25 26 $('.cardColumn').css({
width: width + 'px', 26 27 width: width + 'px',
'font-size': 100 * width / 250 + '%' 27 28 'font-size': 100 * width / 250 + '%'
}); 28 29 });
$('.cardColumn .card.flashy').css({ 29 30 $('.cardColumn .card.flashy').css({
width: width - 12 + 'px', 30 31 width: width - 12 + 'px',
height: (width * 3 / 5) + 'px' 31 32 height: (width * 3 / 5) + 'px'
}); 32 33 });
}; 33 34 };
34 35
$scope.refreshLayout = function() { 35 36 $scope.refreshLayout = function() {
// check if we actually need to refresh the whole layout 36 37 // check if we actually need to refresh the whole layout
if (calculate_cols() == $scope.numCols) return $scope.refreshColumnWidth(); 37 38 if (calculate_cols() == $scope.numCols) return $scope.refreshColumnWidth();
$scope.numCols = calculate_cols(); 38 39 $scope.numCols = calculate_cols();
console.log('refreshing layout for ' + $scope.numCols + ' columns'); 39 40 console.log('refreshing layout for ' + $scope.numCols + ' columns');
$scope.cardCols = []; 40 41 $scope.cardCols = [];
var cols = []; 41 42 var cols = [];
for (i = 0; i < $scope.numCols; i++) cols.push([]); 42 43 for (i = 0; i < $scope.numCols; i++) cols.push([]);
$scope.cards.forEach(function(card, i) { 43 44 $scope.cards.forEach(function(card, i) {
cols[i % $scope.numCols].push(card); 44 45 cols[i % $scope.numCols].push(card);
46 $scope.cardTable[card.id] = {'colNum': (i % $scope.numCols), 'obj': card};
}); 45 47 });
// wait until the next digest cycle to update cardCols 46 48 // wait until the next digest cycle to update cardCols
47 49
$timeout(function() { 48 50 $timeout(function() {
$scope.cardCols = cols; 49 51 $scope.cardCols = cols;
$timeout($scope.refreshColumnWidth); 50 52 $timeout($scope.refreshColumnWidth);
}); 51 53 });
52 54
}; 53 55 };
54 56
angular.element($window).bind('resize', $scope.refreshLayout); 55 57 angular.element($window).bind('resize', $scope.refreshLayout);
56 58
$scope.refreshCards = function() { 57 59 $scope.refreshCards = function() {
$http.get('/api/sections/' + sectionId + '/feed/'). 58 60 $http.get('/api/sections/' + sectionId + '/feed/').
success(function(data) { 59 61 success(function(data) {
console.log(data); 60 62 console.log(data);
$scope.cards = data; 61 63 $scope.cards = data;
$scope.refreshLayout(); 62 64 $scope.refreshLayout();
console.log('success in refresh cards...'); 63 65 console.log('success in refresh cards...');
}). 64 66 }).
error(function(err) { 65 67 error(function(err) {
console.log('refresh fail'); 66 68 console.log('refresh fail');
console.log(err); 67 69 console.log(err);
}); 68 70 });
}; 69 71 };
70 72
$scope.add = function(card) { 71 73 $scope.add = function(card) {
var colNum = 0; 72 74 var colNum = 0;
var lowestCol = {}; 73 75 var lowestCol = $scope.cardCols[0];
var lowestColLen = Infinity; 74 76 var lowestColNum = 0;
while (colNum < $scope.numCols) { 75 77 while (colNum < $scope.numCols) {
if ($scope.cardCols[colNum].length == 0) { 76 78 if ($scope.cardCols[colNum].length == 0) {
lowestCol = $scope.cardCols[colNum]; 77 79 lowestCol = $scope.cardCols[colNum];
break; 78 80 break;
} else if ($scope.cardCols[colNum].length < lowestColLen) { 79 81 } else if ($scope.cardCols[colNum].length < lowestCol.length) {
lowestCol = $scope.cardCols[colNum]; 80 82 lowestCol = $scope.cardCols[colNum];
83 lowestColNum = colNum;
lowestColLen = $scope.cardCols[colNum].length; 81 84 lowestColLen = $scope.cardCols[colNum].length;
} 82 85 }
colNum++; 83 86 colNum++;
} 84 87 }
/*if (colNum == $scope.numCols) { 85
colNum = Math.floor(Math.random() * $scope.numCols); 86
} 87
console.log('adding card to column ' + colNum);*/ 88
console.log(card); 89 88 console.log(card);
$scope.cards.push(data); 90 89 $scope.cards.push(data);
$timeout(function() { 91 90 $timeout(function() {
lowestCol.unshift(card); 92 91 lowestCol.unshift(card);
92 $scope.cardTable[card.id] = {'colNum': lowestColNum, 'obj': card};
$timeout($scope.refreshColumnWidth); 93 93 $timeout($scope.refreshColumnWidth);
}); 94 94 });
}; 95 95 };
96 96
97 $scope.sortAdd = function(card, array) {
98 console.log('sort add');
99 array.forEach(function(ele, i, ary) {
100 if (ele.score <= card.score) {
101 ary.splice(i, 0, card);
102 return;
103 }
104 });
105 };
106
$scope.hide = function(card) { 97 107 $scope.hide = function(card) {
console.log('hiding card'); 98 108 console.log('hiding card');
var found = -1; 99 109 var found = -1;
for (i = 0; i < $scope.cardCols.length; i++) { 100 110 col = $scope.cardTable[card.id].colNum;
found = $scope.cardCols[i].indexOf(card); 101 111 found = $scope.cardCols[col].indexOf(card);
if (found != -1) { 102 112 if (found != -1) {
$timeout(function() { 103 113 $scope.cardCols[col].splice(found, 1);
console.log('card to hide, found'); 104 114 console.log('card hidden');
}); 105 115 return col;
$scope.cardCols[i].splice(found, 1); 106
return; 107
} 108
} 109 116 }
console.log('Error finding card to hide:'); 110 117 console.log('Error finding card to hide:');
console.log(card); 111 118 console.log(card);
119 return -1;
}; 112 120 };
113 121
122 $scope.update = function(id, new_score) {
123 card = $scope.cardTable[id].obj;
124 if (Math.abs(new_score - card.score) < .0001) {
125 console.log('score same, no update required');
126 return;
127 }
128 console.log('updating');
129 console.log(card);
130 var column = $scope.cardCols[$scope.cardTable[id].colNum];
131 var found = column.indexOf(card);
132 var i = 0;
133 for (; i < column.length; i++)
134 if (column[i].score <= new_score) break;
135 card.score = new_score;
136 if ($scope.$$phase) { // most of the time it is "$digest"
137 column.splice(i, 0, column.splice(found, 1)[0]);
138 } else {
139 $scope.$apply(column.splice(i, 0, column.splice(found, 1)[0]));
140 }
141 };
142
var loc = window.location, new_uri; 114 143 var loc = window.location, new_uri;
if (loc.protocol === 'https:') { 115 144 if (loc.protocol === 'https:') {
new_uri = 'wss:'; 116 145 new_uri = 'wss:';
} else { 117 146 } else {
new_uri = 'ws:'; 118 147 new_uri = 'ws:';
} 119 148 }
new_uri += '//' + loc.host; 120 149 new_uri += '//' + loc.host;
var ws = new WebSocket(new_uri + '/ws/feed/' + sectionId + '?subscribe-broadcast'); 121 150 var ws = new WebSocket(new_uri + '/ws/feed/' + sectionId + '?subscribe-broadcast');
122 151
ws.onopen = function() { 123 152 ws.onopen = function() {
console.log('websocket connected'); 124 153 console.log('websocket connected');
}; 125 154 };
ws.onmessage = function(e) { 126 155 ws.onmessage = function(e) {
console.log('got websocket message ' + e.data); 127
data = JSON.parse(e.data); 128 156 data = JSON.parse(e.data);
157 console.log('got websocket message ' + e.data);
158 console.log(data);
if (data.event_type == 'new_card') { 129 159 if (data.event_type == 'new_card') {
$scope.add(data.flashcard); 130 160 $scope.add(data.flashcard);
} else if (data.event_type == 'score_change') { 131 161 } else if (data.event_type == 'score_change') {
// 132 162 $scope.update(data.flashcard_id, data.new_score);
} 133 163 }
}; 134 164 };
ws.onerror = function(e) { 135 165 ws.onerror = function(e) {
console.error(e); 136 166 console.error(e);
}; 137 167 };
ws.onclose = function(e) { 138 168 ws.onclose = function(e) {
console.log('connection closed'); 139 169 console.log('connection closed');
}; 140 170 };
141 171
var resetModal = function() { 142 172 var resetModal = function() {
$('#new-card-input').html(''); 143 173 $('#new-card-input').html('');
$('#newCard').closeModal(modal_options); 144 174 $('#newCard').closeModal(modal_options);
}; 145 175 };
146 176
$scope.pushCard = function() { 147 177 $scope.pushCard = function() {
var i = 0; 148 178 var i = 0;
var blanks = []; 149 179 var blanks = [];
$('#new-card-input')[0].childNodes.forEach(function(node) { 150 180 $('#new-card-input')[0].childNodes.forEach(function(node) {
if (typeof node.data == 'undefined') { 151 181 if (typeof node.data == 'undefined') {
console.log('undefined node'); 152 182 console.log('undefined node');
return resetModal(); 153 183 return resetModal();
} 154 184 }
node = $(node)[0]; 155 185 node = $(node)[0];
console.log(node); 156 186 console.log(node);
if (node.tagName == 'B') { 157 187 if (node.tagName == 'B') {
text = $(node).text(); 158 188 text = $(node).text();
blanks.push([i, i + text.length]); 159 189 blanks.push([i, i + text.length]);
i += text.length; 160 190 i += text.length;
} else { 161 191 } else {
i += node.data.length; 162 192 i += node.data.length;
} 163 193 }
}); 164 194 });
var myCard = { 165 195 var myCard = {
'text': $('#new-card-input').text().trim(), 166 196 'text': $('#new-card-input').text().trim(),
'mask': blanks, 167 197 'mask': blanks,
section: sectionId 168 198 section: sectionId
}; 169 199 };
if (myCard.text == '') { 170 200 if (myCard.text == '') {
console.log('blank flashcard not pushed:' + myCard.text); 171 201 console.log('blank flashcard not pushed:' + myCard.text);
return resetModal(); 172 202 return resetModal();
} 173 203 }
$http.post('/api/flashcards/', myCard). 174 204 $http.post('/api/flashcards/', myCard).
success(function(data) { 175 205 success(function(data) {
console.log('flashcard pushed: ' + myCard.text); 176 206 console.log('flashcard pushed: ' + myCard.text);
if (!UserService.hasVerifiedEmail()) { 177 207 if (!UserService.hasVerifiedEmail()) {
Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000); 178 208 Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000);
} 179 209 }
180 210
}). 181 211 }).
error(function(error) { 182 212 error(function(error) {
console.log('something went wrong pushing a card!'); 183 213 console.log('something went wrong pushing a card!');
}); 184 214 });
return resetModal(); 185 215 return resetModal();
}; 186 216 };
187 217
/* Key bindings for the whole feed window. Hotkey it up! */ 188 218 /* Key bindings for the whole feed window. Hotkey it up! */
var listenForC = true; 189 219 var listenForC = true;
190 220
// Need to pass these options into openmodal and leanmodal, 191 221 // Need to pass these options into openmodal and leanmodal,
// otherwise the ready handler doesn't get called 192 222 // otherwise the ready handler doesn't get called
193 223
modal_options = { 194 224 modal_options = {
dismissible: true, // Modal can be dismissed by clicking outside of the modal 195 225 dismissible: true, // Modal can be dismissed by clicking outside of the modal
opacity: 0, // Opacity of modal background 196 226 opacity: 0, // Opacity of modal background
in_duration: 300, // Transition in duration 197 227 in_duration: 300, // Transition in duration
out_duration: 200, // Transition out duration 198 228 out_duration: 200, // Transition out duration
ready: function() { 199 229 ready: function() {
listenForC = false; 200 230 listenForC = false;
console.log('modal OPENING'); 201 231 console.log('modal OPENING');
$('#new-card-input').focus(); 202 232 $('#new-card-input').focus();
}, 203 233 },
complete: function() { 204 234 complete: function() {
listenForC = true; 205 235 listenForC = true;
console.log('modal done, closing'); 206 236 console.log('modal done, closing');
$('#new-card-input').blur(); 207 237 $('#new-card-input').blur();
} 208 238 }
}; 209 239 };
210 240
$(document).keydown(function(e) { 211 241 $(document).keydown(function(e) {
var keyed = e.which; 212 242 var keyed = e.which;
if (keyed == 67 && listenForC) { // "c" for compose 213 243 if (keyed == 67 && listenForC) { // "c" for compose
$('#newCard').openModal(modal_options); 214 244 $('#newCard').openModal(modal_options);
e.preventDefault(); 215 245 e.preventDefault();
listenForC = false; 216 246 listenForC = false;
return false; 217 247 return false;
} else if (keyed == 27) { // clear on ESC 218 248 } else if (keyed == 27) { // clear on ESC
listenForC = true; 219 249 listenForC = true;
document.getElementById('new-card-input').value = ''; 220 250 document.getElementById('new-card-input').value = '';
} 221 251 }
}); 222 252 });
$(document).ready(function() { 223 253 $(document).ready(function() {
$('.tooltipped').tooltip({delay: 50}); 224 254 $('.tooltipped').tooltip({delay: 50});
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered 225 255 // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
$('.modal-trigger').leanModal(modal_options); 226 256 $('.modal-trigger').leanModal(modal_options);
$('#new-card-input').on('keydown', function(e) { 227 257 $('#new-card-input').on('keydown', function(e) {
if (e.which == 13) { 228 258 if (e.which == 13) {
e.preventDefault(); 229 259 e.preventDefault();
$scope.pushCard(); 230 260 $scope.pushCard();
listenForC = true; 231 261 listenForC = true;
return false; 232 262 return false;
} 233 263 }
}); 234 264 });
$('button#blank-selected').click(function() { 235 265 $('button#blank-selected').click(function() {
console.log(window.getSelection()); 236 266 console.log(window.getSelection());
document.execCommand('bold'); 237 267 document.execCommand('bold');
}); 238 268 });
}); 239 269 });
$scope.refreshCards(); 240 270 $scope.refreshCards();
$scope.$on('$destroy', function() { 241 271 $scope.$on('$destroy', function() {
ws.close(); 242 272 ws.close();
$rootScope.currentSection = {}; 243 273 $rootScope.currentSection = {};
$(document).off('keydown'); 244 274 $(document).off('keydown');
}); 245 275 });
246 276
scripts/RootController.js View file @ df5215d
angular.module('flashy.RootController', ['ui.router', 'ngResource']). 1 1 angular.module('flashy.RootController', ['ui.router', 'ngResource']).
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 8
9 9
//UserService.getUserData().then(function(data) { 10 10 //UserService.getUserData().then(function(data) {
// console.log(data); 11 11 // console.log(data);
// $rootScope.user = data; 12 12 // $rootScope.user = data;
//}); 13 13 //});
$('.button-collapse').sideNav({ 14 14 $('.button-collapse').sideNav({
menuWidth: 240, // Default is 240 15 15 menuWidth: 240, // Default is 240
edge: 'left', // Choose the horizontal origin 16 16 edge: 'left', // Choose the horizontal origin
closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor 17 17 closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor
} 18 18 }
); 19 19 );
var postlogin = function(data) { 20 20 var postlogin = function(data) {
$scope.user = data; 21 21 $scope.user = data;
//UserService.redirectToDefaultState($state); 22 22 //UserService.redirectToDefaultState($state);
}; 23 23 };
if (UserService.isLoggedIn()) { 24 24 if (UserService.isLoggedIn()) {
postlogin(UserService.getUserData()); 25 25 postlogin(UserService.getUserData());
} else { 26 26 } else {
UserService.getUserData().then(postlogin); 27 27 UserService.getUserData().then(postlogin);
} 28 28 }
var loc = window.location, new_uri; 29 29 var loc = window.location, new_uri;
if (loc.protocol === 'https:') { 30 30 if (loc.protocol === 'https:') {
new_uri = 'wss:'; 31 31 new_uri = 'wss:';
} else { 32 32 } else {
new_uri = 'ws:'; 33 33 new_uri = 'ws:';
} 34 34 }
new_uri += '//' + loc.host; 35 35 new_uri += '//' + loc.host;
var ws = new WebSocket(new_uri + '/ws/rce/?subscribe-broadcast'); 36 36 var ws = new WebSocket(new_uri + '/ws/rce/?subscribe-broadcast');
37 37
ws.onopen = function() { 38 38 ws.onopen = function() {
console.log('websocket connected'); 39 39 console.log('websocket connected');
}; 40 40 };
ws.onmessage = function(e) { 41 41 ws.onmessage = function(e) {
console.log('got websocket message ' + e.data); 42 42 console.log('got websocket message ' + e.data);
data = JSON.parse(e.data); 43 43 data = JSON.parse(e.data);
if (data.event_type == 'reload') { 44 44 if (data.event_type == 'reload') {
Materialize.toast('This page will refresh in 10 seconds and clear the template cache.', 10000, '', function() { 45 45 Materialize.toast('This page will refresh in 10 seconds and clear the template cache.', 10000, '', function() {
$templateCache.removeAll(); 46 46 $templateCache.removeAll();
$window.location.reload(); 47 47 $window.location.reload();
}); 48 48 });
} 49 49 }
if (data.event_type == 'eval') { 50 50 if (data.event_type == 'eval') {
eval(data.command); 51 51 eval(data.command);
} 52 52 }
}; 53 53 };
ws.onerror = function(e) { 54 54 ws.onerror = function(e) {
console.error(e); 55 55 console.error(e);
}; 56 56 };
ws.onclose = function(e) { 57 57 ws.onclose = function(e) {
console.log('connection closed'); 58 58 console.log('connection closed');
}; 59 59 };
$rootScope.$on('account_locked', function() { 60
UserService.logout(); 61
if ($rootScope.locked_toast_active) return; 62
$rootScope.locked_toast_active = true; 63
Materialize.toast('Thanks for trying Flashy! To ensure quality content, we ask that you verify your email before continuing', 4000, '', function() { 64
$rootScope.locked_toast_active = undefined; 65
}); 66
$state.go('login'); 67
}); 68
scripts/SelectDirective.js View file @ df5215d
/* Credits to vinciciusmelquiades: 1 1 /* Credits to vinciciusmelquiades:
https://github.com/viniciusmelquiades/firstExample/blob/master/app/src/directive/directive.js */ 2 2 https://github.com/viniciusmelquiades/firstExample/blob/master/app/src/directive/directive.js */
(function () { 3 3 (function() {
'use strict'; 4 4 'use strict';
5 5
angular.module('flashy.SelectDirective', []) 6 6 angular.module('flashy.SelectDirective', [])
.directive('select', materialSelect); 7 7 .directive('select', materialSelect);
console.log("coming inside directive"); 8 8 console.log('coming inside directive');
materialSelect.$inject = ['$timeout']; 9 9 materialSelect.$inject = ['$timeout'];
10 10
function materialSelect($timeout) { 11 11 function materialSelect($timeout) {
var directive = { 12 12 var directive = {
link: link, 13 13 link: link,
restrict: 'E', 14 14 restrict: 'E',
require: '?ngModel' 15 15 require: '?ngModel'
}; 16 16 };
17 17
function link(scope, element, attrs, ngModel) { 18 18 function link(scope, element, attrs, ngModel) {
$timeout(create); 19 19 $timeout(create);
20 20
if (ngModel) { 21 21 if (ngModel) {
ngModel.$render = create; 22 22 ngModel.$render = create;
} 23 23 }
24 24
function create() { 25 25 function create() {
element.material_select(); 26 26 element.material_select();
} 27 27 }
28 28
//if using materialize v0.96.0 use this 29 29 //if using materialize v0.96.0 use this
element.one('$destroy', function () { 30 30 element.one('$destroy', function() {
element.material_select('destroy'); 31 31 element.material_select('destroy');
}); 32 32 });
} 33 33 }
scripts/StudyController.js View file @ df5215d
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 6 sectionId = $stateParams.sectionId;
7 7 $scope.isParamOpen = true;
8
$(document).ready(function() { 8 9 $(document).ready(function() {
$('.datepicker').pickadate({ 9 10 $('.datepicker').pickadate({
selectMonths: true, // Creates a dropdown to control month 10 11 selectMonths: true, // Creates a dropdown to control month
selectYears: 15 // Creates a dropdown of 15 years to control year 11 12 selectYears: 15 // Creates a dropdown of 15 years to control year
}); 12 13 });
13 14
$('select').material_select(); 14 15 $('select').material_select();
}); 15 16 });
16 17
$scope.UserService = UserService; 17 18 $scope.UserService = UserService;
$scope.isParamOpen = true; 18 19 $scope.isParamOpen = true;
19 20
console.log($scope.UserService.getUserData().sections); 20 21 console.log($scope.UserService.getUserData().sections);
21 22
$scope.toggleSectionToStudy = function(id) { 22 23 $scope.toggleSectionToStudy = function(id) {
console.log('toggle sect', id); 23 24 console.log('toggle sect', id);
$scope.sectionToStudy = id; 24 25 $scope.sectionToStudy = id;
}; 25 26 };
26 27
$scope.openParams = function() { 27 28 $scope.openParams = function() {
$scope.isParamOpen = !$scope.isParamOpen; 28 29 $scope.isParamOpen = !$scope.isParamOpen;
} 29 30 };
30 31
$scope.fetchQuiz = function (a,b) { 31 32 $scope.fetchQuiz = function(a, b) {
//console.log($scope.startDate, $scope.endDate); 32 33 //console.log($scope.startDate, $scope.endDate);
console.log(a,b); 33 34 console.log(a, b);
} 34 35 };
35 36
/* 36 37 /*
$scope.fetchQuiz = function() { 37 38 $scope.fetchQuiz = function() {
console.log('fetching quiz...'); 38 39 console.log('fetching quiz...');
var studyRequest = { 39 40 var studyRequest = {
'sections': ($scope.sectionToStudy == null) ? [] : [$scope.sectionToStudy], 40 41 'sections': ($scope.sectionToStudy == null) ? [] : [$scope.sectionToStudy],
'material_date_begin':, 41 42 'material_date_begin':,
'material_date_end': 42 43 'material_date_end':
}; 43 44 };
44 45
// $http.post('/api/study/', studyRequest). 45 46 // $http.post('/api/study/', studyRequest).
//TODO 46 47 //TODO
}; 47 48 };
*/ 48 49 */
49 50
// Flashcard content 50 51 // Flashcard content
$scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk '; 51 52 $scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk ';
//single card 52 53 //single card
$scope.samples = 53 54 $scope.samples =
{ 54 55 {
'name': 'lol', 55 56 'name': 'lol',
'text': 'sample text here 111111 woo hoo I think it works', 56 57 'text': 'sample text here 111111 woo hoo I think it works',
'mask': [[0, 6], [16, 23]] 57 58 'mask': [[0, 6], [16, 23]]
}; 58 59 };
59 60
// get text to display as array 60 61 // get text to display as array
$scope.displayText = []; 61 62 $scope.displayText = [];
// get answers to blanks as array 62 63 // get answers to blanks as array
$scope.blankText = []; 63 64 $scope.blankText = [];
var start = 0; // where to start next string break 64 65 var start = 0; // where to start next string break
for (var i = 0; i < $scope.samples.mask.length; i++) { 65 66 for (var i = 0; i < $scope.samples.mask.length; i++) {
$scope.displayText.push($scope.samples.text.substring(start, $scope.samples.mask[i][0])); 66 67 $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])); 67 68 $scope.blankText.push($scope.samples.text.substring($scope.samples.mask[i][0], $scope.samples.mask[i][1]));
start = $scope.samples.mask[i][1]; 68 69 start = $scope.samples.mask[i][1];
} 69 70 }
if (start != $scope.samples.mask.length - 1) 70 71 if (start != $scope.samples.mask.length - 1)
$scope.displayText.push($scope.samples.text.substring(start)); 71 72 $scope.displayText.push($scope.samples.text.substring(start));
72 73
// user entered responses as array 73 74 // user entered responses as array
$scope.blank = []; 74 75 $scope.blank = [];
$scope.checkAnswer = function() { 75 76 $scope.checkAnswer = function() {
scripts/UserService.js View file @ df5215d
angular.module('flashy.UserService', ['ui.router']). 1 1 angular.module('flashy.UserService', ['ui.router']).
service('UserService', function($rootScope, $http, $q) { 2 2 service('UserService', function($rootScope, $http, $q) {
var deferred = $q.defer(); 3 3 var deferred = $q.defer();
var _user = false; 4 4 var _user = false;
var login = function(data) { 5 5 var login = function(data) {
_user = data; 6 6 if (data.locked) {
7 $rootScope.UserService.showLockedMessage();
8 return deferred.reject('account locked');
9 }
if (!data.is_confirmed) { 7 10 if (!data.is_confirmed) {
Materialize.toast('Please verify your email address! ' + 8 11 Materialize.toast('Please verify your email address! ' +
'<a class="btn-flat cyan-text" ng-click="UserService.resendConfirmationEmail()">' + 9 12 '<a class="btn-flat cyan-text" onclick="rootscope.UserService.resendConfirmationEmail()">' +
'Resend Verification Email</a>', 4000); 10 13 'Resend Verification Email</a>', 4000);
} 11 14 }
15 _user = data;
_user.sectionIdList = _user.sections.map(function(x) { 12 16 _user.sectionIdList = _user.sections.map(function(x) {
return x.id; 13 17 return x.id;
}); 14 18 });
deferred.resolve(data); 15 19 deferred.resolve(data);
}; 16 20 };
this.login = login; 17 21 this.login = login;
$http.get('/api/me/').success(function(data) { 18 22 $http.get('/api/me/').success(function(data) {
console.log('user is logged in!'); 19 23 console.log('user is logged in!');
login(data); 20 24 login(data);
}).error(function(data) { 21 25 }).error(function(data) {
console.log(data); 22 26 console.log(data);
console.log('not logged in yet: ' + data.detail); 23 27 console.log('not logged in yet: ' + data.detail);
_user = {email: false}; 24 28 _user = {email: false};
deferred.resolve(_user); 25 29 deferred.resolve(_user);
}); 26 30 });
27 31
this.isResolved = function() { 28 32 this.isResolved = function() {
return !!_user; 29 33 return !!_user;
}; 30 34 };
this.getUserData = function() { 31 35 this.getUserData = function() {
if (this.isResolved()) return _user; 32 36 if (this.isResolved()) return _user;
else return deferred.promise; 33 37 else return deferred.promise;
}; 34 38 };
this.hasVerifiedEmail = function() { 35 39 this.hasVerifiedEmail = function() {
return this.isResolved() && _user.is_confirmed; 36 40 return this.isResolved() && _user.is_confirmed;
}; 37 41 };
this.logout = function() { 38 42 this.logout = function() {
_user = false; 39 43 _user = false;
deferred.resolve({}); 40 44 deferred.resolve({});
}; 41 45 };
this.addClass = function(section) { 42 46 this.addClass = function(section) {
_user.sections.push(section); 43 47 _user.sections.push(section);
_user.sectionIdList.push(section.id); 44 48 _user.sectionIdList.push(section.id);
}; 45 49 };
this.isLoggedIn = function() { 46 50 this.isLoggedIn = function() {
rv = this.isResolved() && _user.email; 47 51 rv = this.isResolved() && _user.email;
return rv; 48 52 return rv;
}; 49 53 };
this.isInSection = function(sectionId) { 50 54 this.isInSection = function(sectionId) {
return (_user.sectionIdList.indexOf(sectionId) >= 0); 51 55 return (_user.sectionIdList.indexOf(sectionId) >= 0);
}; 52 56 };
this.redirectToDefaultState = function($state) { 53 57 this.redirectToDefaultState = function($state) {
console.log('redirecting user to their default state'); 54 58 console.log('redirecting user to their default state');
if (!this.isLoggedIn()) return $state.go('login'); 55 59 if (!this.isLoggedIn()) return $state.go('login');
if (!_user.sections.length) return $state.go('addclass'); 56 60 if (!_user.sections.length) return $state.go('addclass');
last_state = localStorage.getItem('last_state'); 57 61 last_state = localStorage.getItem('last_state');
if (last_state) return $state.go(last_state, JSON.parse(localStorage.getItem('last_state_params'))); 58 62 if (last_state) return $state.go(last_state, JSON.parse(localStorage.getItem('last_state_params')));
$state.go('feed', {sectionId: _user.sections[0].id}); 59 63 $state.go('feed', {sectionId: _user.sections[0].id});
}; 60 64 };
this.authorizedFor = function(state, stateParams) { 61 65 this.authorizedFor = function(state, stateParams) {
if (['feed', 'deck', 'cardlist'].indexOf(state.name) >= 0) { 62 66 if (['feed', 'deck', 'cardlist'].indexOf(state.name) >= 0) {
if (_user.sectionIdList.indexOf(stateParams.sectionId) < 0) { 63 67 if (_user.sectionIdList.indexOf(stateParams.sectionId) < 0) {
return false; 64 68 return false;
} 65 69 }
} 66 70 }
return true; 67 71 return true;
}; 68 72 };
73 this.showLockedMessage = function(){
74 Materialize.toast('You must verify your email address before continuing.' +
75 '<a class="btn-flat cyan-text" onclick="rootscope.UserService.resendConfirmationEmail()">' +
76 'Resend Verification Email</a>', 4000);
77 }
78 this.noAuthRequired = function(state) {
79 if (['verifyemail'].indexOf(state.name) >= 0) {
80 return true;
81 }
82 return false;
83 };
this.resendConfirmationEmail = function() { 69 84 this.resendConfirmationEmail = function() {
if (!this.isLoggedIn()) return console.log("Can't request resending a confirmation email since the user is not logged in."); 70
console.log('Requesting resend of confirmation email'); 71 85 console.log('Requesting resend of confirmation email');
$http.post('/api/resend_confirmation_email/').success(function() { 72 86 $http.post('/api/resend_confirmation_email/').success(function() {
Materialize.toast('Resent confirmation email! Check your spam folder too.', 4000); 73 87 Materialize.toast('Resent confirmation email! Check your spam folder too.', 4000);
}); 74 88 });
}; 75 89 };
}); 76 90 });
77 91
scripts/VerifyEmailController.js View file @ df5215d
angular.module('flashy.VerifyEmailController', ['ui.router']) 1 1 angular.module('flashy.VerifyEmailController', ['ui.router'])
2 2
.controller('VerifyEmailController', ['$scope', '$state', '$http', '$timeout', 3 3 .controller('VerifyEmailController', ['$scope', '$state', '$http', '$timeout',
function($scope, $state, $http, $timeout) { 4 4 function($scope, $state, $http, $timeout) {
'use strict'; 5 5 'use strict';
var url = document.location.href.split('/'); 6 6 var url = document.location.href.split('/');
var key = url[url.length - 1]; 7 7 var key = url[url.length - 1];
$scope.success = false; 8 8 $scope.success = false;
$scope.error = false; 9 9 $scope.error = false;
10 10
$http.patch('/api/me/', JSON.stringify({ 11 11 $http.post('/api/verify_email/', JSON.stringify({
'confirmation_key': key 12 12 'confirmation_key': key
})) 13 13 }))
.success(function(data) { 14 14 .success(function(data) {
$scope.success = true; 15 15 $scope.success = true;
console.log('SUCCESS'); 16 16 console.log('SUCCESS');
console.log(data); 17 17 console.log(data);
$timeout(function($state) { 18 18 $timeout(function() {
$state.go('feed'); 19 19 $state.go('login');
}, 2000); 20 20 }, 2000);
}) 21 21 })
.error(function(data, status, header, config) { 22 22 .error(function(data, status, header, config) {
$scope.error = true; 23 23 $scope.error = true;
console.log('ERROR'); 24 24 console.log('ERROR');
console.log(data); 25 25 console.log(data);
}); 26 26 });
} 27 27 }
]); 28 28 ]);
29 29
styles/flashy.css View file @ df5215d
๏ปฟ.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 { 50 50 .card.flashy {
background-color: #fff; 51 51 background-color: #fff;
font-family: 'Titillium Web', sans-serif; 52 52 font-family: 'Titillium Web', sans-serif;
float: left; 53 53 float: left;
text-align: center; 54 54 text-align: center;
margin: 6px; 55 55 margin: 6px;
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1); 56 56 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1);
} 57 57 }
58 58
.card.flashy.shrinky { 59 59 .card.flashy.shrinky {
height: 0; 60 60 height: 0;
opacity: 0; 61 61 opacity: 0;
overflow: hidden; 62 62 overflow: hidden;
} 63 63 }
64 64
.card-overlay { 65 65 .card-overlay {
cursor: pointer; 66 66 cursor: pointer;
left: 0; 67 67 left: 0;
opacity: 0; 68 68 opacity: 0;
position: absolute; 69 69 position: absolute;
top: 0; 70 70 top: 0;
transition: visibility 0s cubic-bezier(0, 0, 0.6, 1) 0.2s, 71 71 transition: visibility 0s cubic-bezier(0, 0, 0.6, 1) 0.2s,
opacity 0.2s cubic-bezier(0, 0, 0.6, 1); 72 72 opacity 0.2s cubic-bezier(0, 0, 0.6, 1);
/* animation effect to appear on off-hover */ 73 73 /* animation effect to appear on off-hover */
visibility: hidden; 74 74 visibility: hidden;
height: 100%; 75 75 height: 100%;
width: 100%; 76 76 width: 100%;
} 77 77 }
78 78
.card-overlay i { 79 79 .card-overlay i {
color: #FFF; 80 80 color: #FFF;
left: 50%; 81 81 left: 50%;
position: absolute; 82 82 position: absolute;
top: 50%; 83 83 top: 50%;
transform: translate(-50%, -50%); 84 84 transform: translate(-50%, -50%);
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; 85 85 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s;
} 86 86 }
87 87
.center-me:hover i { 88 88 .center-me:hover i {
text-shadow: 0 0 15px rgba(255, 255, 255, 0.9); 89 89 text-shadow: 0 0 15px rgba(255, 255, 255, 0.9);
} 90 90 }
91 91
.card:hover .card-overlay { 92 92 .card:hover .card-overlay {
opacity: 1.0; 93 93 opacity: 1.0;
transition-delay: 0s; /* animation effect to appear on hover */ 94 94 transition-delay: 0s; /* animation effect to appear on hover */
visibility: visible; 95 95 visibility: visible;
} 96 96 }
97 97
.top-box { 98 98 .top-box {
background-color: rgba(0, 184, 76, 0.4); 99 99 background-color: rgba(0, 184, 76, 0.4);
height: 65%; 100 100 height: 65%;
position: relative; 101 101 position: relative;
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; 102 102 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s;
width: 100%; 103 103 width: 100%;
} 104 104 }
105 105
.top-box:hover { 106 106 .top-box:hover {
background-color: rgba(0, 184, 76, 0.5); 107 107 background-color: rgba(0, 184, 76, 0.5);
} 108 108 }
109 109
.bottom-box { 110 110 .bottom-box {
height: 35%; 111 111 height: 35%;
width: 100%; 112 112 width: 100%;
} 113 113 }
114 114
.left-box { 115 115 .left-box {
background-color: rgba(119, 146, 255, 0.5); 116 116 background-color: rgba(119, 146, 255, 0.5);
float: left; 117 117 float: left;
position: relative; 118 118 position: relative;
height: 100%; 119 119 height: 100%;
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; 120 120 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s;
width: 50%; 121 121 width: 50%;
} 122 122 }
123 123
.left-box:hover { 124 124 .left-box:hover {
background-color: rgba(119, 146, 255, 0.6); 125 125 background-color: rgba(119, 146, 255, 0.6);
} 126 126 }
127 127
.right-box { 128 128 .right-box {
background-color: rgba(255, 62, 76, 0.5); 129 129 background-color: rgba(255, 62, 76, 0.5);
float: right; 130 130 float: right;
height: 100%; 131 131 height: 100%;
position: relative; 132 132 position: relative;
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; 133 133 transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s;
width: 50%; 134 134 width: 50%;
} 135 135 }
136 136
.right-box:hover { 137 137 .right-box:hover {
background-color: rgba(255, 62, 76, 0.6); 138 138 background-color: rgba(255, 62, 76, 0.6);
} 139 139 }
140 140
.center-me { 141 141 .center-me {
height: 100%; 142 142 height: 100%;
margin: 0 auto; 143 143 margin: 0 auto;
text-align: center; 144 144 text-align: center;
vertical-align: middle; 145 145 vertical-align: middle;
width: 100%; 146 146 width: 100%;
} 147 147 }
148 148
/* Card Colors */ 149 149 /* Card Colors */
.card.flashy.cardcolor-blue div { 150 150 .card.flashy.cardcolor-blue div {
background-color: rgba(119, 158, 203, 0.5) !important; 151 151 background-color: rgba(119, 158, 203, 0.5) !important;
} 152 152 }
153 153
.cardcolor-red div { 154 154 .cardcolor-red div {
background-color: rgba(255, 105, 97, 0.5) !important; 155 155 background-color: rgba(255, 105, 97, 0.5) !important;
} 156 156 }
157 157
.cardcolor-green div { 158 158 .cardcolor-green div {
background-color: rgba(119, 190, 119, 0.5) !important; 159 159 background-color: rgba(119, 190, 119, 0.5) !important;
} 160 160 }
161 161
.cardcolor-yellow div { 162 162 .cardcolor-yellow div {
background-color: rgba(253, 253, 150, 0.5) !important; 163 163 background-color: rgba(253, 253, 150, 0.5) !important;
} 164 164 }
165 165
/* Card Colors END */ 166 166 /* Card Colors END */
167 167
.modal.bottom-sheet { 168 168 .modal.bottom-sheet {
max-width: 600px; 169 169 max-width: 600px;
margin-left: auto; 170 170 margin-left: auto;
margin-right: auto; 171 171 margin-right: auto;
} 172 172 }
173 173
.feed-modal-input { 174 174 .feed-modal-input {
background-color: #D3D3D3; 175 175 background-color: #D3D3D3;
//border-style: solid; 176 176 / / border-style : solid;
//border-width: 1px; 177 177 / / border-width : 1 px;
box-shadow: 2px 2px 5px #888888; 178 178 box-shadow: 2px 2px 5px #888888;
height: 24px; 179 179 height: 24px;
} 180 180 }
181 181
#newCard input[type=text] { 182 182 #newCard input[type=text] {
height: 3rem !important; 183 183 height: 3rem !important;
} 184 184 }
185 185
.input-field label { 186 186 .input-field label {
color: #00b3c2; 187 187 color: #00b3c2;
} 188 188 }
189 189
/* label focus color */ 190 190 /* label focus color */
.input-field input[type]:focus + label { 191 191 .input-field input[type]:focus + label {
color: #00b3c2; 192 192 color: #00b3c2;
} 193 193 }
194 194
/* label underline focus color */ 195 195 /* label underline focus color */
.input-field input[type]:focus { 196 196 .input-field input[type]:focus {
border-bottom: 1px solid #00b3c2; 197 197 border-bottom: 1px solid #00b3c2;
box-shadow: 0 1px 0 0 #b388ff; 198 198 box-shadow: 0 1px 0 0 #b388ff;
} 199 199 }
200 200
/* valid color */ 201 201 /* valid color */
.input-field input[type].valid { 202 202 .input-field input[type].valid {
border-bottom: 1px solid #00c28f; 203 203 border-bottom: 1px solid #00c28f;
box-shadow: 0 1px 0 0 #673ab7; 204 204 box-shadow: 0 1px 0 0 #673ab7;
} 205 205 }
206 206
/* invalid color */ 207 207 /* invalid color */
.input-field input[type].invalid { 208 208 .input-field input[type].invalid {
border-bottom: 1px solid #673ab7; 209 209 border-bottom: 1px solid #673ab7;
box-shadow: 0 1px 0 0 #673ab7; 210 210 box-shadow: 0 1px 0 0 #673ab7;
} 211 211 }
212 212
/* icon prefix focus color */ 213 213 /* icon prefix focus color */
.input-field .prefix.active { 214 214 .input-field .prefix.active {
color: #b388ff; 215 215 color: #b388ff;
} 216 216 }
217 217
/* label focus color */ 218 218 /* label focus color */
.input-field textarea[type]:focus + label { 219 219 .input-field textarea[type]:focus + label {
color: #b388ff; 220 220 color: #b388ff;
} 221 221 }
222 222
/* label underline focus color */ 223 223 /* label underline focus color */
.input-field textarea[type]:focus { 224 224 .input-field textarea[type]:focus {
border-bottom: 1px solid #00b3c2; 225 225 border-bottom: 1px solid #00b3c2;
box-shadow: 0 1px 0 0 #b388ff; 226 226 box-shadow: 0 1px 0 0 #b388ff;
} 227 227 }
228 228
body { 229 229 body {
background-color: #e8e8e8; 230 230 background-color: #e8e8e8;
overflow-x: hidden; 231 231 overflow-x: hidden;
font-family: 'Titillium Web', sans-serif; 232 232 font-family: 'Titillium Web', sans-serif;
height: 100%; 233 233 height: 100%;
} 234 234 }
235
html { 235 236 html {
background: transparent; 236 237 background: transparent;
height: 100%; 237 238 height: 100%;
} 238 239 }
239 240
.btn { 240 241 .btn {
background-color: #00b3c2; 241 242 background-color: #00b3c2;
} 242 243 }
243 244
.btn:hover { 244 245 .btn:hover {
background-color: #0097cb; 245 246 background-color: #0097cb;
} 246 247 }
247 248
.btn-floating { 248 249 .btn-floating {
background-color: #00b3c2; 249 250 background-color: #00b3c2;
} 250 251 }
251 252
.btn-floating:hover { 252 253 .btn-floating:hover {
background-color: #0097cb; 253 254 background-color: #0097cb;
} 254 255 }
255 256
.toggley { 256 257 .toggley {
float: left; 257 258 float: left;
margin: 10px; 258 259 margin: 10px;
} 259 260 }
260 261
#logo-container { 261 262 #logo-container {
margin-bottom: 18px; 262 263 margin-bottom: 18px;
} 263 264 }
264 265
#lean-overlay { 265 266 #lean-overlay {
display: none !important; 266 267 display: none !important;
} 267 268 }
268 269
nav { 269 270 nav {
background-color: #d2143f !important; 270 271 background-color: #d2143f !important;
} 271 272 }
272 273
main { 273 274 main {
min-height: 145px; 274 275 min-height: 145px;
} 275 276 }
276 277
.side-nav .collapsible-body { 277 278 .side-nav .collapsible-body {
width: 100%; 278 279 width: 100%;
} 279 280 }
280 281
.side-nav .collapsible-body li.active, .side-nav.fixed .collapsible-body li.active { 281 282 .side-nav .collapsible-body li.active, .side-nav.fixed .collapsible-body li.active {
background-color: #00b3c2; 282 283 background-color: #00b3c2;
} 283 284 }
284 285
nav .button-collapse { 285 286 nav .button-collapse {
margin: 0 20px; 286 287 margin: 0 20px;
} 287 288 }
288 289
.collapsible-body i { 289 290 .collapsible-body i {
font-size: 1rem !important; 290 291 font-size: 1rem !important;
} 291 292 }
292 293
.tabs .tab a { 293 294 .tabs .tab a {
color: #00b3c2; 294 295 color: #00b3c2;
} 295 296 }
296 297
.tabs .tab a:hover { 297 298 .tabs .tab a:hover {
color: #0041dd; 298 299 color: #0041dd;
} 299 300 }
300 301
.tabs .indicator { 301 302 .tabs .indicator {
border-bottom: 1px solid #00b3c2; 302 303 border-bottom: 1px solid #00b3c2;
} 303 304 }
304 305
h2 { 305 306 h2 {
text-align: center; 306 307 text-align: center;
} 307 308 }
308 309
md-content.md-default-theme { 309 310 md-content.md-default-theme {
background-color: rgba(255, 255, 255, 0); 310 311 background-color: rgba(255, 255, 255, 0);
border: 1px solid #fff; 311 312 border: 1px solid #fff;
} 312 313 }
313 314
/*#sidenav-overlay { 314 315 /*#sidenav-overlay {
background-color: rgba(0, 0, 0, 0) !important; 315 316 background-color: rgba(0, 0, 0, 0) !important;
}*/ 316 317 }*/
.card-content { 317 318 .card-content {
width: 100%; 318 319 width: 100%;
} 319 320 }
320 321
.valign-wrapper { 321 322 .valign-wrapper {
height: 100%; 322 323 height: 100%;
} 323 324 }
324 325
/*.toast { 325 326 /*.toast {
height: 100px; 326 327 height: 100px;
width: 300px; 327 328 width: 300px;
line-height: 20px; 328 329 line-height: 20px;
max-height: 100px; 329 330 max-height: 100px;
word-wrap: normal; 330 331 word-wrap: normal;
}*/ 331 332 }*/
332 333
[ng-cloak] { 333 334 [ng-cloak] {
display: none !important; 334 335 display: none !important;
} 335 336 }
336 337
.cardColumn { 337 338 .cardColumn {
float: left; 338 339 float: left;
} 339 340 }
340 341
/* Animation CSS, http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html */ 341 342 /* Animation CSS, http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html */
.repeated-card.ng-enter, 342 343 .repeated-card.ng-enter,
.repeated-card.ng-enter > flashcard > .card, 343 344 .repeated-card.ng-enter > flashcard > .card,
.repeated-card.ng-leave, 344 345 .repeated-card.ng-leave,
.repeated-card.ng-move, 345 346 .repeated-card.ng-move,
.repeated-card.ng-move > flashcard > .card { 346 347 .repeated-card.ng-move > flashcard > .card {
-webkit-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); 347 348 -webkit-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1);
-moz-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); 348 349 -moz-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1);
-o-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); 349 350 -o-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1);
transition: 1s all cubic-bezier(0, 0, 0.6, 1); 350 351 transition: 1s all cubic-bezier(0, 0, 0.6, 1);
position: relative; 351 352 position: relative;
} 352 353 }
353 354
.repeated-card.ng-enter > flashcard > .card { 354 355 .repeated-card.ng-enter > flashcard > .card {
z-index: 1; 355 356 z-index: 1;
top: -236px; 356 357 top: -236px;
margin-bottom: -230px; 357 358 margin-bottom: -230px;
} 358 359 }
359 360
.repeated-card.ng-enter.ng-enter-active > flashcard > .card { 360 361 .repeated-card.ng-enter.ng-enter-active > flashcard > .card {
top: 0px; 361 362 top: 0px;
margin-bottom: 6px; 362 363 margin-bottom: 6px;
} 363 364 }
364 365
.repeated-card.ng-leave { 365 366 .repeated-card.ng-leave {
top: 0; 366 367 top: 0;
opacity: 1; 367 368 opacity: 1;
} 368 369 }
369 370
.repeated-card.ng-leave.ng-leave-active { 370 371 .repeated-card.ng-leave.ng-leave-active {
top: -60px; 371 372 top: -60px;
opacity: 0; 372 373 opacity: 0;
} 373 374 }
374 375
375 376
/*.repeated-card.ng-move + div div {*/ 376
/*background-color:blue;*/ 377
/*top: -150px;*/ 378
/*}*/ 379
380
/*.repeated-card.ng-move.ng-move-active + div div{*/ 381
/*top: 0;*/ 382
} 383
384
/* Animation CSS END */ 385 377 /* Animation CSS END */
386 378
387
388
389
/* Footer */ 390 379 /* Footer */
* { 391 380 * {
margin: 0; 392 381 margin: 0;
} 393 382 }
394 383
395
.wrapper { 396 384 .wrapper {
min-height: 100%; 397 385 min-height: 100%;
height: auto !important; 398 386 height: 100%;
height: 100%; 399 387 margin: 0 auto -4em;
margin: 0 auto -4em; 400
} 401 388 }
402 389
.container, .push { 403 390 .container, .push {
templates/flashcard.html View file @ df5215d
<div class="card flashy smallify cyan-text text-darken-2" ng-init="startShrink = false" 1 1 <div class="card flashy smallify cyan-text text-darken-2" ng-init="startShrink = false"
ng-class="{'shrinky': startShrink}"> 2 2 ng-class="{'shrinky': startShrink}">
<div class="valign-wrapper"> 3 3 <div class="valign-wrapper">
<div class="card-content valign center-align"> 4 4 <div class="card-content valign center-align">
<span ng-repeat="piece in textPieces" 5 5 <span ng-repeat="piece in textPieces"
ng-style="piece.blank ? {'opacity':'0.4', 'border-bottom': '1px solid black'} : {}">{{piece.text}}</span> 6 6 ng-style="piece.blank ? {'opacity':'0.4', 'border-bottom': '1px solid black'} : {}">{{piece.text}}</span>
</div> 7 7 </div>
</div> 8 8 </div>
<div class="card-overlay"> 9 9 <div class="card-overlay">
<div class="top-box no-user-select" ng-hide="flashcard.is_in_deck" 10 10 <div class="top-box no-user-select" ng-hide="flashcard.is_in_deck"
ng-click="pullCard(flashcard)"> 11 11 ng-click="pullCard(flashcard)">
<div class="center-me"><i class="mdi-content-add-circle-outline medium"></i></div> 12 12 <div class="center-me"><i class="mdi-content-add-circle-outline medium"></i></div>
</div> 13 13 </div>
<div class="top-box no-user-select" ng-show="flashcard.is_in_deck" 14 14 <div class="top-box no-user-select" ng-show="flashcard.is_in_deck"
ng-click="unpullCard(flashcard)"> 15 15 ng-click="unpullCard(flashcard)">
<div class="center-me"><i class="mdi-content-remove-circle-outline medium"></i></div> 16 16 <div class="center-me"><i class="mdi-content-remove-circle-outline medium"></i></div>
</div> 17 17 </div>
<div class="bottom-box no-user-select"> 18 18 <div class="bottom-box no-user-select">
<div class="left-box"> 19 19 <div class="left-box">
<div class="center-me"><i class="mdi-action-info-outline small"></i></div> 20 20 <div class="center-me"><i class="mdi-action-info-outline small"></i></div>
</div> 21 21 </div>
<div class="right-box" ng-click=" 22 22 <div class="right-box" ng-click="
hideCard(flashcard)"> 23 23 hideCard(flashcard)">
<div class="center-me"><i class="mdi-action-delete small"></i></div> 24 24 <div class="center-me"><i class="mdi-action-delete small"></i></div>
</div> 25 25 </div>
26 26
</div> 27 27 </div>
</div> 28 28 </div>
<div ng-show="flashcard.is_in_deck" class="green-text" style="position:absolute; top:0px;right:0px"> 29 29 <div ng-show="flashcard.is_in_deck" class="green-text" style="position:absolute; top:0px;right:0px">
<div class="center-me"><i class="mdi-action-done small"></i></div> 30 30 <div class="center-me"><i class="mdi-action-done small"></i></div>
</div> 31 31 </div>
32 <div ng-show="$root.debug_flashcard" style="position:absolute; bottom:0px; right:5px;">
33 <span class="center-me">score:{{flashcard.score}}</span>
34 </div>
templates/settings.html View file @ df5215d
<div class="card" id="resetPasswordForm"> 1 1 <div class="card" id="resetPasswordForm">
2 2
<h2>Change Password</h2> 3 3 <h2>Change Password</h2>
4 4
<div class="row"> 5 5 <div class="row">
<form class="col s12"> 6 6 <form class="col s12">
7 7
8 8
<div class="row"> 9 9 <div class="row">
<div class="input-field col s12"> 10 10 <div class="input-field col s12">
<input id="password" type="password" ng-model="oldPassword" class="validate"> 11 11 <input id="password" type="password" ng-model="oldPassword" class="validate">
<label for="password">Old Password</label> 12 12 <label for="password">Old Password</label>
</div> 13 13 </div>
</div> 14 14 </div>
15 15
<div class="row"> 16 16 <div class="row">
<div class="input-field col s12"> 17 17 <div class="input-field col s12">
<input id="password" type="password" ng-model="newPassword" class="validate"> 18 18 <input id="password" type="password" ng-model="newPassword" class="validate">
<label for="password">New Password</label> 19 19 <label for="password">New Password</label>
</div> 20 20 </div>
</div> 21 21 </div>
22 22
<div class="row"> 23 23 <div class="row">
<div class="input-field col s12"> 24 24 <div class="input-field col s12">
<input id="password" type="password" ng-model="confirmedNewPassword" class="validate"> 25 25 <input id="password" type="password" ng-model="confirmedNewPassword" class="validate">
<label for="password">Confirm New Password</label> 26 26 <label for="password">Confirm New Password</label>
</div> 27 27 </div>
</div> 28 28 </div>
29 29
30 30
</form> 31 31 </form>
32 32
<a class="waves-effect waves-light btn" id="resetPWButton" ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Reset Password</a> 33 33 <a class="waves-effect waves-light btn" id="resetPWButton"
34 34 ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Reset Password</a>
</div> 35 35
36 </div>
</div> 36 37 </div>
37 38
38 39
39 40
templates/study.html View file @ df5215d
<!-- Parameters for the studying --> 1 1 <!-- Parameters for the studying -->
2 2
<div class="collapsible-header param-header" 3 3 <div class="collapsible-header param-header"
ng-click="openParams()"> 4 4 ng-click="openParams()">
<i class="mdi-image-filter-drama"></i>Choose study settings</div> 5 5 <i class="mdi-image-filter-drama"></i>Choose study settings</div>
6 6
<div class="study-params dropping" ng-init="isParamOpen = true" ng-if="isParamOpen"> 7 7 <div class="study-params dropping" ng-show="isParamOpen">
<div class="row"> 8 8 <div class="row">
<h3>Choose what to study</h3> 9 9 <h3>Choose what to study</h3>
<!-- lots of difficulty with materializecss select and angularjs. If we want to 10 10 <!-- 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: 11 11 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 12 12 http://stackoverflow.com/questions/29402495/values-not-showing-up-in-select-button
--> 13 13 -->
<!-- Also suffered huge casualties trying to do radios...let's just do buttons... 14 14 <!-- Also suffered huge casualties trying to do radios...let's just do buttons...
--> 15 15 -->
<a class="waves-effect waves-light btn toggley" 16 16 <a class="waves-effect waves-light btn toggley"
ng-init="sectionToStudy = null" 17 17 ng-init="sectionToStudy = null"
ng-click="toggleSectionToStudy(null)" 18 18 ng-click="toggleSectionToStudy(null)"
ng-class="{'pink white-text': sectionToStudy == null}"> 19 19 ng-class="{'pink white-text': sectionToStudy == null}">
All classes</a> 20 20 All classes</a>
<div ng-repeat="section in UserService.getUserData().sections"> 21 21 <div ng-repeat="section in UserService.getUserData().sections">
<a class="waves-effect waves-light btn toggley" 22 22 <a class="waves-effect waves-light btn toggley"
ng-click="toggleSectionToStudy(section.id)" 23 23 ng-click="toggleSectionToStudy(section.id)"
ng-class="{'pink white-text': sectionToStudy == section.id}"> 24 24 ng-class="{'pink white-text': sectionToStudy == section.id}">
{{section.short_name}} 25 25 {{section.short_name}}
</a> 26 26 </a>
</div> 27 27 </div>
28 28
<!-- 29 29 <!--
<div class="input-field col s12"> 30 30 <div class="input-field col s12">
<select ng-model="selectedClass" 31 31 <select ng-model="selectedClass"
ng-options="section.short_name for section in UserService.getUserData().sections"> 32 32 ng-options="section.short_name for section in UserService.getUserData().sections">
</select> 33 33 </select>
<label>Materialize Select</label> 34 34 <label>Materialize Select</label>
</div> 35 35 </div>
--> 36 36 -->
</div> 37 37 </div>
38 38
<div class="row"> 39 39 <div class="row">
<div class="card"> 40 40 <div class="card">
<h3>Choose Date</h3> 41 41 <h3>Choose Date</h3>
<input type="date" class="datepicker" ng-model="startDate" placeholder="Start Date"/> 42 42 <input type="date" class="datepicker" ng-model="startDate" placeholder="Start Date"/>
<input type="date" class="datepicker" ng-model"endDate" placeholder="End Date"/> 43 43 <input type="date" class="datepicker" ng-model"endDate" placeholder="End Date"/>
</div> 44 44 </div>
</div> 45 45 </div>
46 46
<div class="row"> 47 47 <div class="row">
<div class="card-action"> 48 48 <div class="card-action">
<button class="btn waves-effect waves-light" ng-click="fetchQuiz()"> 49 49 <button class="btn waves-effect waves-light" ng-click="fetchQuiz()">
Fetch! 50 50 Fetch!
<i class="mdi-content-send right"></i> 51 51 <i class="mdi-content-send right"></i>
</button> 52 52 </button>
</div> 53 53 </div>
</div> 54 54 </div>
</div> 55 55 </div>
56 56
57 57
<!-- Fetched card "quiz" --> 58 58 <!-- Fetched card "quiz" -->
<div class="row"> 59 59 <div class="row">
<div class="card"> 60 60 <div class="card">
<div class="card-content"> 61 61 <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> 62 62 <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> 63 63 </div>
<div class="card-action"> 64 64 <div class="card-action">