-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.js
181 lines (159 loc) · 5.49 KB
/
javascript.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
angular.module('portalApp')
// Widget controller - runs every time widget is shown
.controller('connectCtrl', ['$scope', '$http', '$q', 'connectFactory', function ($scope, $http, $q, connectFactory) {
// Widget Configuration
$scope.portalHelpers.config = {
// make 'widgetMenu.html' the template for the top right menu
"widgetMenu": "widgetMenu.html"
};
// Import variables and functions from service
$scope.data = connectFactory.data;
$scope.studentData = {};
$scope.portalHelpers.showView('main.html', 1);
$scope.portalHelpers.toggleLoading(false);
$scope.item = {value:''};
// Model for the search and list example
$scope.model = [{
title: "Jessie Won",
details: "Hey, how's it going?",
ingroup: '0',
incontacts: '1',
user_id: 'jwon',
program: 'Systems Design Engineering'
}, {
title: "Portal Hackathon Team",
details: "Hey guys! Lunch is at 12!",
ingroup: '1',
incontacts: '1'
}, {
title: "SYDE 2020",
details: "When's our last exam?",
ingroup: '1',
incontacts: '1'
}, {
title: "Tara Yuen",
details: "Are you going to the portal hackathon today?",
ingroup: '0',
incontacts: '1',
user_id: 'tyuen',
program: 'Systems Design Engineering'
}, {
title: "Krystyna Brudnicki",
details: "I LOVE CONNOR #krishnor",
ingroup: '0',
incontacts: '1',
user_id: 'kbrudnicki',
program: 'Systems Design Engineering'
}, {
title: "Zak Keller",
details: "item 6 details",
ingroup: '0',
incontacts: '1',
user_id: 'zkeller',
program: 'Systems Design Engineering'
}];
// Call server to fetch student data
$scope.portalHelpers.invokeServerFunction('getData')
.then(function (result) {
$scope.studentData = result;
console.log(result);
});
// OPEN DATA API EXAMPLE
$scope.portalHelpers.invokeServerFunction('getOpenData')
.then(function (result) {
$scope.openDataPeopleData = result;
console.log('getopendata data: ', result);
openDataPeopleData.value = result.data;
});
// MOCK DATA API EXAMPLE
$scope.portalHelpers.invokeServerFunction('getMockData')
.then(function (result) {
$scope.mockDataPeopleData.value = result;
console.log('getmockdata data: ', result);
mockDataPeopleData.value = result.data;
});
// initialize the service
connectFactory.init($scope);
// watch for changes in the loading variable
$scope.$watch('loading.value', function () {
// if loading
if ($scope.loading.value) {
// show loading screen in the first column, and don't append it to browser history
$scope.portalHelpers.showView('loading.html', 1, false);
// show loading animation in place of menu button
$scope.portalHelpers.toggleLoading(true);
} else {
$scope.portalHelpers.showView('main.html', 1);
$scope.portalHelpers.toggleLoading(false);
}
});
// Handle click on event
$scope.showEvent = function (event) {
$scope.portalHelpers.showView('event.html', 2);
};
// Handle click on new message icon in the messages and create message
$scope.showMessage = function (newmessage) {
$scope.portalHelpers.showView('newmessage.html', 2);
};
// Handle click on an item in the list and search example
$scope.showDetails = function (item) {
// Set which item to show in the details view
$scope.item.value = item;
// Show details view in the second column
$scope.portalHelpers.showView('details.html', 2);
};
// Handle "previous item" click from the details page
$scope.prevItem = function () {
// get previous items in the list
var prevItem = $scope.portalHelpers.getPrevListItem();
// refresh details view with the new item
$scope.showDetails(prevItem);
}
$scope.nextItem = function () {
var nextItem = $scope.portalHelpers.getNextListItem();
$scope.showDetails(nextItem);
}
// Get list to search for students
$scope.portalHelpers.invokeServerFunction('privDataRead').then(function (result) {
console.log('priv read result',result);
});
}])
// Factory maintains the state of the widget
.factory('connectFactory', ['$http', '$rootScope', '$filter', '$q', function ($http, $rootScope, $filter, $q) {
var initialized = {
value: false
};
// Your variable declarations
var data = {
value: null
};
var loading = {
value: true
};
var init = function ($scope) {
if (initialized.value)
return;
initialized.value = true;
}
// Expose init(), and variables
return {
init: init,
data: data,
loading: loading,
};
}])
// Custom directive example
.directive('connectDirectiveName', ['$http', function ($http) {
return {
link: function (scope, el, attrs) {
}
};
}])
// Custom filter example
.filter('connectFilterName', function () {
return function (input, arg1, arg2) {
// Filter your output here by iterating over input elements
var output = input;
return output;
}
});