forked from gambogi/CSHMembersPortal
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathapp.js
More file actions
92 lines (82 loc) · 2.39 KB
/
app.js
File metadata and controls
92 lines (82 loc) · 2.39 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var app = angular.module("members", ['webicon']);
app.directive("navbar", function() {
return {
restrict: "E",
templateUrl: "templates/navbar.html"
}
});
app.directive("meetings", function() {
return {
restrict: "E",
templateUrl: "templates/meetings.html",
scope: {
meetings: "=data"
}
};
});
app.directive("quote", function() {
return {
restrict: "E",
templateUrl: "templates/quote.html",
scope: {
quote: "=data"
}
};
});
app.controller("MembersController", ['$scope', '$http', function($scope, $http) {
// Toggle showing the icons
$scope.saveIconSetting = function() {
window.localStorage.setItem("showIcons", $scope.showIcons);
};
// Get the meeting times
$scope.meetings = [];
$http.get("./data/meetings.json").success(function (response) {
$scope.meetings = response;
}).error(function (error) {
console.error("Error getting meetings.json");
});
// Get the quotes
$scope.quote = [];
$http.get("./data/config.json").success(function (response) {
$http.get("https://quotefault-api.csh.rit.edu/" + response['quotefaultAPI'] + "/random").success(function (response) {
$scope.quote = response;
}).error(function (error) {
console.error("Error getting quote from API");
});
}).error(function (error) {
console.error("Error getting config.json");
});
// Get all the links
$scope.sections = [];
$scope.popular = [];
$http.get("./data/links.json").success(function (response) {
$scope.sections = response;
// Find the popular links
for (var i = 0; i < $scope.sections.length; i++) {
var section = $scope.sections[i];
for (var j = 0; j < section.links.length; j++ ) {
if (section.links[j].hasOwnProperty("popular")) {
$scope.popular.push(section.links[j]);
}
}
}
if ($scope.popular.length === 0) $scope.popular = false;
}).error(function (error) {
console.error("Error getting links.json");
});
// Show/hide icons
$scope.showIcons = true;
if (window.localStorage) {
var showIcons = window.localStorage.getItem("showIcons");
if (showIcons === "false") {
$scope.showIcons = false;
}
else if (showIcons === "true") {
$scope.showIcons = true;
}
else {
$scope.showIcons = true;
$scope.saveIconSetting();
}
}
}]);