'use strict';
angular.module('ocreApp')
-.controller('MainCtrl', function ($scope, $http, $window, $location, $anchorScroll, socket) {
+.controller('MainCtrl', function ($scope, $rootScope, $http, $window, $location, $anchorScroll, socket) {
- /**
- *
- * @function setStyles
- * @description Setting styles in scope
- *
- **/
- var setStyles = function () {
-
- // Main section style
- $scope.sectionStyle = {
- marginTop : 50,
- height : $window.innerHeight
- };
-
- // Carousel style
- $scope.carouselStyle = {
- width : $scope.sectionStyle.width,
- height : $scope.sectionStyle.height * 0.85 - 50
- };
-
- // Carousel > Image style
- $scope.imgStyle = {
- width : $scope.sectionStyle.width,
- height : $scope.sectionStyle.height * 0.85 - 50
- };
-
- // Carousel banner style
- $scope.bannerStyle = {
- backgroundColor : '#cc7722',
- height : $scope.sectionStyle.height * 0.15,
- textAlign : 'center'
- };
- };
-
- // Initializing styles
- setStyles();
+ $scope.myInterval = 5000;
+ $scope.slides = [];
+ $scope.slides.push({
+ title : 'Bienvenue sur OCRE',
+ text: "L'application Open Source d'aide à la conception et au financement participatif !",
+ about : "/about"
+ });
- // Listening to window resize events
- angular.element($window).bind('resize', function() {
- // Resetting styles on resize
- setStyles();
- // Applying to scope - refresh the scope
- $scope.$apply();
+ $scope.slides.push({
+ title : 'Participez au projet OCRE!',
+ text : "Vous êtes développeur? Venez soutenir la plate-forme sur la forge!",
+ about : "https://bitbucket.org/genonin/ocre",
});
- // Initializing slides used by carousel
- var slides = $scope.slides = [];
+ $scope.projects = [];
+ $http.get('/api/projects').success(function(projects) {
+ $scope.projects = projects;
+ var j = 0;
+ var k = 0;
+ $scope.cfProjects = [];
+ $scope.csProjects = [];
+ for (var i in $scope.projects) {
+ if (j < 3) {
+ if ($scope.projects[i].state === "En financement") {
+ $scope.cfProjects.push($scope.projects[i]);
+ j++;
+ }
+ }
+
+ if (k < 3) {
+ if ($scope.projects[i].state === "En développement") {
+ $scope.csProjects.push($scope.projects[i]);
+ k++;
+ }
+ }
- // Setting carousel interval between slides
- $scope.myInterval = 5000;
+ }
+ });
- /**
- *
- * @function addSlide
- * @description Adding slide in slides array
- *
- **/
- $scope.addSlide = function() {
- slides.push({
- image: 'http://placekitten.com/1600/1200',
- text: ['More','Extra','Lots of','Surplus'][slides.length % 4] + ' ' +
- ['Cats', 'Kittys', 'Felines', 'Cutes'][slides.length % 4]
- });
- };
- // Adding 4 slides in slides array
- for (var i=0; i<4; i++) {
- $scope.addSlide();
+ $scope.convertToLocaleDate = function(date) {
+ return new Date(date).toLocaleDateString();
}
/**
* @description Scrolling to anchor position defined by route
*
**/
- $scope.scrollTo= function(route) {
+ $scope.scrollTo = function(route) {
// Getting location by id
$location.hash(route);
// Scrolling to anchor
$anchorScroll();
};
-
- $scope.projects = [];
-
- $scope.projects.push({
- title : 'Projet 1',
- author : 'Romain Monin',
- category : 'Informatique',
- informations : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam quis bibendum dui, sit amet vehicula odio. Ut dictum lobortis elementum. Donec cursus, dui in fermentum euismod, nibh nunc aliquet dui, quis elementum neque mauris sed felis. Suspendisse facilisis adipiscing felis, sed iaculis tellus molestie at. Cras euismod, nibh vitae congue ultricies, ligula justo imperdiet ante, vitae dictum ante dolor eget tellus. In cursus vehicula lorem, at tristique metus. Vestibulum vel dui accumsan, hendrerit augue eget, dignissim elit. Nullam hendrerit a elit vitae sodales. Fusce id vestibulum nulla. Nulla odio lacus, lacinia eget eleifend eget, porta sit amet justo. Sed aliquet adipiscing nulla, in luctus velit porta vel. Curabitur egestas porta nulla, eget faucibus neque consectetur quis. Mauris venenatis consectetur interdum. Fusce fermentum et erat vitae auctor. Sed quis scelerisque nisi. Vestibulum cursus libero eros, ornare dignissim mi facilisis et.',
- image : 'http://placekitten.com/200/100',
- beginningDate : 14092014,
- endingDate : 30092014,
- url : '/projet1',
- likes : 32,
- comments : 2,
- askedDonations : 20000,
- currentDonations : 11249
- });
-/* $scope.awesomeThings = [];
-
-
- $http.get('/api/things').success(function(awesomeThings) {
- $scope.awesomeThings = awesomeThings;
- socket.syncUpdates('thing', $scope.awesomeThings);
- });
+ /**
+ *
+ * @function goto
+ * @parameters String route, String projectId
+ * @description Going to route and adding projectId to rootScope
+ *
+ **/
+ $scope.goto = function(route, projectId) {
+ $rootScope.project_id = projectId;
+ $location.path(route);
- $scope.addThing = function() {
- if($scope.newThing === '') {
- return;
- }
- $http.post('/api/things', { name: $scope.newThing });
- $scope.newThing = '';
- };
+ }
- $scope.deleteThing = function(thing) {
- $http.delete('/api/things/' + thing._id);
- };
+ $scope.goto2 = function(route, profileId) {
+ $rootScope.profile_id = profileId;
+ $location.path(route);
- $scope.$on('$destroy', function () {
- socket.unsyncUpdates('thing');
- });*/
+ }
});
\ No newline at end of file