diff --git a/scripts/StudyController.js b/scripts/StudyController.js index 07d13d0..31b508b 100644 --- a/scripts/StudyController.js +++ b/scripts/StudyController.js @@ -3,8 +3,6 @@ angular.module('flashy.StudyController', ['ui.router']). controller('StudyController', ['$scope', '$stateParams', '$state', '$http', 'UserService', function($scope, $stateParams, $state, $http, UserService) { console.log('Flashy study controller content in this file. also hell0'); - sectionId = $stateParams.sectionId; - $scope.isParamOpen = true; $(document).ready(function() { $('.datepicker').pickadate({ @@ -13,22 +11,25 @@ controller('StudyController', ['$scope', '$stateParams', '$state', '$http', 'Use }); $('select').material_select(); + + // Open by default + $('#content-x').slideDown(250).addClass('open'); }); + sectionId = $stateParams.sectionId; + $scope.isParamOpen = true; $scope.UserService = UserService; $scope.isParamOpen = true; - console.log($scope.UserService.getUserData().sections); + console.log('user sections', $scope.UserService.getUserData().sections); + /* Sets current study class to the one passed in (y) */ $scope.toggleSectionToStudy = function(id) { console.log('toggle sect', id); $scope.sectionToStudy = id; }; - $scope.openParams = function() { - $scope.isParamOpen = !$scope.isParamOpen; - }; - + /* Opens or closes content collapsible */ $scope.toggleContent = function(event, index) { if ($('#content-x').hasClass('open')) { // let's close it // Note: 250 is duration (ms) of animation @@ -39,27 +40,21 @@ controller('StudyController', ['$scope', '$stateParams', '$state', '$http', 'Use }; - /* - $scope.fetchQuiz = function(a, b) { - //console.log($scope.startDate, $scope.endDate); - console.log(a, b); - console.log($('#start-date').val()); - }; - */ - $scope.fetchQuiz = function() { console.log('fetching quiz...'); + console.log('study sect', $scope.sectionToStudy, parseInt($scope.sectionToStudy)); var studyRequest = { - 'sections': ($scope.sectionToStudy == null) ? [] : [$scope.sectionToStudy] + 'sections': ($scope.sectionToStudy == null) ? [] : [parseInt($scope.sectionToStudy)] }; + console.log('startdate:', new Date($('#start-date').val())); console.log('enddate:', $('#end-date').val() + 'T00:00:00Z'); - console.log('study sect', $scope.sectionToStudy); $http.post('/api/study/', studyRequest). success(function(data) { console.log('Fetched card:', data); }).error(function(err) { + console.log('Fetch Error'); }); }; diff --git a/templates/study.html b/templates/study.html index ec7a424..f2143e1 100644 --- a/templates/study.html +++ b/templates/study.html @@ -12,6 +12,7 @@ --> +