diff --git a/templates/js/controllers/campusesController.js b/templates/js/controllers/campusesController.js index e1d796b..f7a1033 100644 --- a/templates/js/controllers/campusesController.js +++ b/templates/js/controllers/campusesController.js @@ -1,17 +1,59 @@ angular.module('SeHub') -.controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope) { +.controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope) +{ + $scope.threeSizedArray =[]; + var token = $cookies['com.sehub.www']; + + $scope.campuses = ['Bezalel', 'Ben Gurion', 'Sami Shamoon', 'Afeka', 'Ivrit', 'Kaka', 'Opium']; // TODO REMOVE + - - - - $scope.campuses = ['Bezalel', 'Ben Gurion', 'Sami Shamoon', 'Afeka', 'Ivrit', 'Kaka', 'Opium']; - console.log($scope.campuses); - - // apiService.getCampusesByUser(token).success(function(data) // Get all the campuses + // apiService.getCampusesByUser().success(function(data) // Get all the campuses // { + // console.log("INSIDE"); // $scope.campuses = data; // }).error(function() { // // TODO // }); + console.log($scope.campuses); -}]); \ No newline at end of file + + var init = function() + { + var i, j, counter = 0; + var newLength = 0; + + if(($scope.campuses.length % 3) === 0) + { + newLength = ($scope.campuses.length / 3); + } + else + { + newLength = (Math.ceil($scope.campuses.length / 3)); // Rounds number up + } + + console.log("length: " + newLength); + $scope.threeSizedArray.length = newLength; + + for(j = 0; j < newLength; j++) + { + $scope.threeSizedArray[j] = [3]; // Creating array in size of 3 in each array cell + } + + for(i = 0; i < newLength; i++) + { + for(j = 0; j < newLength; j++) + { + if($scope.campuses[(3*i) + j] != null) + { + $scope.threeSizedArray[i][j] = $scope.campuses[(3*i) + j]; + } + } + } + console.log($scope.threeSizedArray); + } + + init(); // Executing the function to initialize campuses show + + + +}]); diff --git a/templates/js/controllers/myClassesController.js b/templates/js/controllers/myClassesController.js index e4d69d6..9e68070 100644 --- a/templates/js/controllers/myClassesController.js +++ b/templates/js/controllers/myClassesController.js @@ -6,6 +6,7 @@ angular.module('SeHub') $scope.isNewCourse = false; $scope.newClassName = false; $scope.course = {}; + // $scope.globalVar = ''; var token = $cookies['com.sehub.www']; $scope.user.finalDate = ''; $scope.user.startDate = ''; @@ -24,15 +25,51 @@ angular.module('SeHub') $scope.courses = ['SE', 'PC', 'Math', 'Calculus', 'Ivrit', 'English', 'Drugs']; + console.log($scope.courses); - - // apiService.getClassesByUser(token).success(function(data) // Get all the campuses + // apiService.getClassesByUser().success(function(data) // Get all the courses // { // $scope.courses = data; // }).error(function() { // // TODO // }); + var init = function() + { + var i, j, counter = 0; + var newLength = 0; + + if(($scope.courses.length % 3) === 0) + { + newLength = ($scope.courses.length / 3); + } + else + { + newLength = (Math.ceil($scope.courses.length / 3)); // Rounds number up + } + + $scope.holdArrays.length = newLength; + + for(j = 0; j < newLength; j++) + { + $scope.holdArrays[j] = [3]; // Creating array in size of 3 in each array cell + } + + for(i = 0; i < newLength; i++) + { + for(j = 0; j < newLength; j++) + { + if($scope.courses[(3*i) + j] != null) + { + $scope.holdArrays[i][j] = $scope.courses[(3*i) + j]; + } + } + } + console.log($scope.holdArrays); + } + + init(); // Executing the function to initialize course display + $scope.chooseCourseClicked = function() { @@ -65,6 +102,8 @@ angular.module('SeHub') } }; + // $scope.globalVar = jsonNewCourse; + console.log("Json here:"); console.log(jsonNewCourse); @@ -89,6 +128,41 @@ angular.module('SeHub') } } + var init = function() + { + var i, j, counter = 0; + var newLength = 0; + + if(($scope.courses.length % 3) === 0) + { + newLength = ($scope.courses.length / 3); + } + else + { + newLength = (Math.ceil($scope.courses.length / 3)); // Rounds number up + } + + console.log("length: " + newLength); + $scope.holdArrays.length = newLength; + + for(j = 0; j < newLength; j++) + { + $scope.holdArrays[j] = [3]; // Creating array in size of 3 in each array cell + } + + for(i = 0; i < newLength; i++) + { + for(j = 0; j < newLength; j++) + { + if($scope.courses[(3*i) + j] != null) + { + $scope.holdArrays[i][j] = $scope.courses[(3*i) + j]; + } + } + } + console.log($scope.holdArrays); + } + }]); \ No newline at end of file diff --git a/templates/js/controllers/projectsController.js b/templates/js/controllers/projectsController.js index 617a7a5..0a68d3b 100644 --- a/templates/js/controllers/projectsController.js +++ b/templates/js/controllers/projectsController.js @@ -19,5 +19,42 @@ angular.module('SeHub') // // TODO // }); + var init = function() + { + var i, j, counter = 0; + var newLength = 0; + + if(($scope.projects.length % 3) === 0) + { + newLength = ($scope.projects.length / 3); + } + else + { + newLength = (Math.ceil($scope.projects.length / 3)); // Rounds number up + } + + console.log("length: " + newLength); + $scope.arrayHolder.length = newLength; + + for(j = 0; j < newLength; j++) + { + $scope.arrayHolder[j] = [3]; // Creating array in size of 3 in each array cell + } + + for(i = 0; i < newLength; i++) + { + for(j = 0; j < newLength; j++) + { + if($scope.projects[(3*i) + j] != null) + { + $scope.arrayHolder[i][j] = $scope.projects[(3*i) + j]; + } + } + } + console.log($scope.arrayHolder); + } + + init(); // Executing the function to initialize projects display + }]); \ No newline at end of file diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 589c5fd..928bca6 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -90,7 +90,7 @@ angular.module('SeHub') }; $scope.createCampus = function(ev) { - $scope.createCampusClicked = true; + $scope.createCampusClicked = !$scope.createCampusClicked; if (!$scope.isLecturer) // "!isLecturer" Means => I Am Lecturer; if i am a lecturer (when pressing -> getting last data value before pressing) { diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index e619186..41ad264 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -44,29 +44,18 @@ service.factory('apiService', ['$http', function($http) { return $http(req); }, getCourseByCampusName: function(token){ - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token; + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseByCampusName/" + token; req = { method : "GET", url : url - }; return $http(req); }, - getAllCourses: function(token){ - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token; - req = { - method : "GET", - url : url - - }; - return $http(req); - }, - getAllMessages: function(token){ + getAllMessages: function(){ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAllMessages/" + token; req = { method : "GET", url : url - }; return $http(req); }, @@ -76,7 +65,6 @@ service.factory('apiService', ['$http', function($http) { method : "POST", url : url, data: payLoad - }; return $http(req); }, @@ -85,7 +73,6 @@ service.factory('apiService', ['$http', function($http) { req = { method : "GET", url : url - }; return $http(req); }, @@ -95,25 +82,22 @@ service.factory('apiService', ['$http', function($http) { method : "POST", url : url, data: payLoad - }; return $http(req); }, - getCampusesByUser: function(){ + getCampusesByUser: function(token){ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCampusesByUser/" + token; req = { method : "GET", url : url - }; return $http(req); }, - getClassesByCourse: function(){ // Need to add camusName (ngRoute) ~ sagi //TODO + getClassesByUser: function(){ // Need to add campusName (ngRoute) ~ sagi //TODO var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/ClassesByCourse/" + token; req = { method : "GET", url : url - }; return $http(req); }, @@ -122,7 +106,6 @@ service.factory('apiService', ['$http', function($http) { req = { method : "GET", url : url - }; return $http(req); } diff --git a/templates/views/campuses.html b/templates/views/campuses.html index 8d0ddf8..efc9846 100644 --- a/templates/views/campuses.html +++ b/templates/views/campuses.html @@ -3,10 +3,10 @@