Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
33,461 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ results | |
node_modules | ||
|
||
npm-debug.log | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"dependencies": | ||
{ | ||
"express": "3.x", | ||
"couchbase": "0.0.11" | ||
"couchbase": "0.0.11", | ||
"ejs": ">= 0.0.1" | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
// Declare app level module which depends on filters, and services | ||
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives']). | ||
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { | ||
$routeProvider. | ||
when('/', {templateUrl: 'partials/index.html', controller: EntriesListCtrl }). | ||
when('/idea/new', {templateUrl: 'partials/idea-form.html', controller: IdeaFormCtrl }). | ||
when('/idea/edit/:id', {templateUrl: 'partials/idea-form.html', controller: IdeaFormCtrl }). | ||
when('/idea/:id', {templateUrl: 'partials/idea.html', controller: IdeaViewCtrl }). | ||
when('/idea/:id/vote', {templateUrl: 'partials/vote-form.html', controller: VoteFormCtrl }). | ||
when('/idea/:id/vote/:voteId', {templateUrl: 'partials/vote-form.html', controller: VoteFormCtrl }). | ||
otherwise({redirectTo: '/'}); | ||
|
||
}]); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
'use strict'; | ||
|
||
/* Controllers */ | ||
|
||
|
||
function AppCtrl($scope, $http) { | ||
$scope.user = null; | ||
} | ||
AppCtrl.$inject = ['$scope', '$http']; | ||
|
||
|
||
function NavBarController($scope) { | ||
} | ||
NavBarController.$inject = ['$scope']; | ||
|
||
function EntriesListCtrl($scope, $http) { | ||
$http({method: 'GET', url: '/api/results' }).success(function(data, status, headers, config) { | ||
$scope.entries = data; | ||
}) | ||
.error(function(data, status, headers, config) { | ||
$scope.name = 'Error!' | ||
}); | ||
} | ||
EntriesListCtrl.$inject = ['$scope', '$http']; | ||
|
||
function IdeaViewCtrl($rootScope, $scope, $routeParams, $http, $location) { | ||
$scope.numberOfVote = 0; | ||
$http({method: 'GET', url: '/api/idea/'+ $routeParams.id }).success(function(data, status, headers, config) { | ||
$scope.entry = data; | ||
}) | ||
.error(function(data, status, headers, config) { | ||
$scope.name = 'Error!' | ||
}); | ||
$http({method: 'GET', url: '/api/votes/'+ $routeParams.id }).success(function(data, status, headers, config) { | ||
$scope.votes = data; | ||
$scope.numberOfVote = data.length; | ||
}) | ||
.error(function(data, status, headers, config) { | ||
$scope.name = 'Error!' | ||
}); | ||
|
||
$scope.delete = function(vote) { | ||
$http.delete('/api/vote/'+ vote.id).success(function(data) { | ||
// remove the data from the vote list | ||
for (var i in $scope.votes) { | ||
if ( $scope.votes[i] == vote ) { | ||
$scope.votes.splice(i, 1); | ||
$scope.numberOfVote = $scope.numberOfVote -1; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
IdeaViewCtrl.$inject = ['$rootScope', '$scope', '$routeParams','$http', '$location']; | ||
|
||
function VoteFormCtrl($rootScope, $scope, $routeParams, $http, $location) { | ||
$http({method: 'GET', url: '/api/idea/'+ $routeParams.id }).success(function(data, status, headers, config) { | ||
$scope.entry = data; | ||
}) | ||
.error(function(data, status, headers, config) { | ||
$scope.name = 'Error!' | ||
console.log("Error in VoteFormCtrl"); | ||
}); | ||
|
||
// if a parameter exit we should load the vote | ||
if ($routeParams.voteId) { | ||
$http({method: 'GET', url: '/api/vote/'+ $routeParams.voteId }).success(function(data, status, headers, config) { | ||
$scope.vote = data; | ||
}) | ||
.error(function(data, status, headers, config) { | ||
$scope.name = 'Error!' | ||
console.log("Error in VoteFormCtrl"); | ||
}); | ||
} | ||
|
||
$scope.save = function() { | ||
$scope.vote.type = "vote"; | ||
$scope.vote.user_id = $scope.user; | ||
$scope.vote.idea_id = $routeParams.id; | ||
$http.post('/api/vote',$scope.vote).success(function(data) { | ||
$location.path('/idea/'+ $routeParams.id ); | ||
}); | ||
} | ||
|
||
} | ||
VoteFormCtrl.$inject = ['$rootScope', '$scope', '$routeParams','$http', '$location']; | ||
|
||
|
||
/** | ||
* Manage the Creation & Edit of ideas | ||
*/ | ||
function IdeaFormCtrl($rootScope, $scope, $routeParams, $http, $location) { | ||
$scope.idea = null; | ||
if ($routeParams.id ) { | ||
$http({method: 'GET', url: '/api/idea/'+ $routeParams.id }).success(function(data, status, headers, config) { | ||
$scope.idea = data; | ||
}); | ||
} | ||
|
||
$scope.save = function() { | ||
$scope.idea.type = "idea"; // set the type | ||
$scope.idea.user_id = $scope.user; | ||
$http.post('/api/idea',$scope.idea).success(function(data) { | ||
$location.path('/'); | ||
}); | ||
} | ||
$scope.cancel = function() { | ||
$location.path('/'); | ||
} | ||
|
||
} | ||
IdeaFormCtrl.$inject = ['$rootScope', '$scope', '$routeParams','$http', '$location']; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
'use strict'; | ||
|
||
/* Directives */ | ||
|
||
|
||
angular.module('myApp.directives', []) | ||
.directive('appVersion', ['version', function(version) { | ||
return function(scope, elm, attrs) {elm.text(version);}; | ||
}]) | ||
.directive('dropdown', function () { | ||
return function (scope, elm, attrs) { | ||
$(elm).dropdown(); | ||
}; | ||
}) | ||
.directive('buttonGroup', function(){ | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
states: '=', | ||
state: '=', | ||
onStateChange: '=' | ||
}, | ||
template: '<div class="btn-group">' + | ||
'<button class="btn" ng-repeat="s in states" ng-click="select(s, $event)">' + | ||
'{{s}}' + | ||
'</button>' + | ||
'</div>', | ||
replace: true, | ||
controller: function($scope, $element){ | ||
|
||
// Make sure that style is applied to initial state value | ||
$scope.$watch(function () { | ||
return $($element).find('.btn').length; // it checks if the buttons are added to the DOM | ||
}, function (newVal) { | ||
// it applies the selected style to the currently defined state, if any | ||
if (newVal > 0) { | ||
$($element).find('.btn').each(function(index, elm){ | ||
if ($(elm).text() == $scope.state) $(elm).addClass('btn-primary'); | ||
}); | ||
} | ||
}, true); | ||
|
||
// Apply style changes according to selection | ||
$scope.select = function(s, evt){ | ||
$scope.state = s; | ||
|
||
$($element).find('.btn').removeClass('btn-primary'); // reset styles on all buttons | ||
angular.element(evt.srcElement).addClass('btn-primary'); // apply style only to selected button | ||
}; | ||
|
||
|
||
// Execute callback if it was provided | ||
$scope.$watch('state', function(){ | ||
if ($scope.onStateChange){ | ||
$scope.onStateChange(); | ||
} | ||
}, true); | ||
} | ||
}; | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
/* Filters */ | ||
|
||
angular.module('myApp.filters', []). | ||
filter('interpolate', ['version', function(version) { | ||
return function(text) { | ||
return String(text).replace(/\%VERSION\%/mg, version); | ||
} | ||
}]); |
Oops, something went wrong.