-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
68 lines (57 loc) · 1.98 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var app = angular.module('VotingApp', ['ngCookies']);
app.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);
app.controller('AppController', function($scope, $http, $cookies) {
console.log($cookies);
console.log(localStorage);
if('userName' in localStorage) {
$scope.userName = localStorage.userName;
console.log($scope.userName);
}
$scope.inputs = {
typedName: "",
filter: "",
}
$scope.clear = function() {
$scope.inputs.filter = "";
$("#search").focus();
};
$scope.setName = function() {
$scope.userName = angular.copy($scope.inputs.typedName);
localStorage.userName = $scope.userName;
console.log("set cookies");
};
// load teams
// and set current vote status from backend
$scope.teams = [
{name: 'TEam 1', upVoted: true},
{name: 'Goobers', upVoted: false},
{name: 'Another', upVoted: false},
{name: 'TEam 1', upVoted: true},
{name: 'Goobers', upVoted: false},
{name: 'Another', upVoted: false},
{name: 'TEam 1', upVoted: true},
{name: 'Goobers', upVoted: false},
{name: 'Another', upVoted: false},
{name: 'Another', upVoted: false},
{name: 'TEam 1', upVoted: true},
{name: 'Goobers', upVoted: false},
{name: 'Another', upVoted: false},
{name: 'TEam 1', upVoted: true},
{name: 'Another', upVoted: false},
{name: 'TEam 1', upVoted: true},
{name: 'Goobers', upVoted: false},
{name: 'Another', upVoted: false},
{name: 'TEam 1', upVoted: true},
];
$scope.toggleTeamVote = function(team) {
console.log('toggle vote for', team);
team.upVoted = !team.upVoted;
// PERSIST TO SERVER with user
};
});
window.addEventListener('load', function() {
FastClick.attach(document.body);
}, false);