Commit 3837ecba5e1b268c30f68183fa802f24012a7ad9

Authored by Andrew Buss

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

Showing 4 changed files Inline Diff

login_test.js View file @ 3837ecb
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/StudyController.js View file @ 3837ecb
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
templates/study.html View file @ 3837ecb
<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>