-
Notifications
You must be signed in to change notification settings - Fork 1
/
ranking.html
executable file
·333 lines (300 loc) · 10.9 KB
/
ranking.html
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Rankings</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://www.w3schools.com/lib/w3.js"></script>
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.min.js"></script>
<script src="./plotLine.js"></script>
<script type="text/javascript" src="lib/axios/dist/axios.standalone.js"></script>
<script type="text/javascript" src="lib/CryptoJS/rollups/hmac-sha256.js"></script>
<script type="text/javascript" src="lib/CryptoJS/rollups/sha256.js"></script>
<script type="text/javascript" src="lib/CryptoJS/components/hmac.js"></script>
<script type="text/javascript" src="lib/CryptoJS/components/enc-base64.js"></script>
<script type="text/javascript" src="lib/url-template/url-template.js"></script>
<script type="text/javascript" src="lib/apiGatewayCore/sigV4Client.js"></script>
<script type="text/javascript" src="lib/apiGatewayCore/apiGatewayClient.js"></script>
<script type="text/javascript" src="lib/apiGatewayCore/simpleHttpClient.js"></script>
<script type="text/javascript" src="lib/apiGatewayCore/utils.js"></script>
<script type="text/javascript" src="apigClient.js"></script>
<link rel="stylesheet" type="text/css" href="./style.css">
<title>CSS Website Layout</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
}
/* Style the header */
.header {
background-color: #f1f1f1;
padding: 20px;
text-align: center;
}
/* Style the top navigation bar */
.topnav {
overflow: hidden;
background-color: rgb(228, 226, 226);
}
/* Style the topnav links */
.topnav a {
float: left;
display: block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Change color on hover */
.topnav a:hover {
background-color: rgb(195, 195, 195);
color: black;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 15px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
@media screen and (max-width:600px) {
.column {
width: 100%;
}
}
</style>
</head>
<body>
<!-- <div class="header">
<h1>Header</h1>
<p>Resize the browser window to see the responsive effect.</p>
</div> -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<script type="text/javascript">
var url_str = window.location.href;
var url = new URL(url_str);
var p1 = url.searchParams.get("courseName");
</script>
<a class="navbar-brand" href="#"><script type="text/javascript">
document.write(p1) //parameters to be replaced later
</script></a>
</div>
<div class="my-2 my-lg-0">
<a href ='./Editproject.html'><button class="btn btn-primary mr-sm-2 " >Edit Project</button></a>
<a href ='./GenerateInvite.html'><button class="btn btn-primary my-2 my-sm-0 " >Generate Inivite link</button></a>
</div>
</nav>
<script>
apigClient = apigClientFactory.newClient({
accessKey: 'AKIAICAYKF4PLVB3DWQQ',
secretKey: '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'
});
//https://www.w3schools.com/howto/howto_js_sort_table.asp
function sortTable(tablename) {
var table, rows, switching, i, x, y, shouldSwitch;
table = document.getElementById(tablename);
switching = true;
/* Make a loop that will continue until
no switching has been done: */
while (switching) {
// Start by saying: no switching is done:
switching = false;
rows = table.rows;
/* Loop through all table rows (except the
first, which contains table headers): */
for (i = 1; i < (rows.length - 1); i++) {
// Start by saying there should be no switching:
shouldSwitch = false;
/* Get the two elements you want to compare,
one from current row and one from the next: */
x = rows[i].getElementsByTagName("td")[1];
y = rows[i + 1].getElementsByTagName("td")[1];
// Check if the two rows should switch place:
if (parseInt(x.innerHTML.toLowerCase()) < parseInt(y.innerHTML.toLowerCase())) {
// If so, mark as a switch and break the loop:
shouldSwitch = true;
break;
}
}
if (shouldSwitch) {
/* If a switch has been marked, make the switch
and mark that a switch has been done: */
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
switching = true;
}
}
}
</script>
<div class="row">
<div class="column">
<h4>Group Rankings</h4>
<table id="usersTable" class="w3-table-all">
<tr>
<th onclick="w3.sortHTML('#usersTable', '.item', 'td:nth-child(1)')" style="cursor:pointer">Name</th>
<th onclick="sortTable('usersTable')" style="cursor:pointer">Effort</th>
<!-- <th onclick="w3.sortHTML('#usersTable', '.item', 'td:nth-child(3)')" style="cursor:pointer">Sales Person</th> -->
</tr>
<script type="text/javascript">
var url_str = window.location.href;
var url = new URL(url_str);
var courseName = url.searchParams.get("courseName");
var id = url.searchParams.get("id");
console.log(courseName)
console.log(id)
// var p1 = 'Yuting Project';
var table = document.getElementById("usersTable");
var temp = document.createElement("tr");
function showDetails(p1)
{
window.location = 'ProjectList.html?username='+p1;
}
var params = {
};
var additionalParams = {
headers: {
},
queryParams: {
'id' : id
}
};
var body = {
};
apigClient.courseGet(params, body, additionalParams)
.then(function(result){
// Add success callback code here.
var dat = result['data']
// console.log(dat)
var proj_list = result['data'][0]['projects']['values'] //replace 0 as i
for (var j = 0; j < proj_list.length; j++) {
additionalParams = {
headers: {
},
queryParams: {
'id' : proj_list[j]
}
};
console.log(proj_list[j])
apigClient.projectGet(params, body, additionalParams)
.then(function(rst){
// rst['data'][0]['stats']
// proj_name.push(rst['data'][0]['repoName'])
// commit_count.push(rst['data'][0]['stats']['commits'].length)
var temp = document.createElement("tr")
temp.className = "item"
temp.innerHTML = "<tr class=\"item\"><td>" + rst['data'][0]['repoName'] + "</td><td>" + rst['data'][0]['stats']['commits'].length + "</td></tr>"
table.append(temp)
// console.log(rst['data'][0])
}).catch(function(rst){
// Add error callback code here.
});
}
}).catch(function(result){
// Add error callback code here.
});
</script>
</table>
<!-- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sit amet pretium urna. Vivamus venenatis velit nec neque ultricies, eget elementum magna tristique. Quisque vehicula, risus eget aliquam placerat, purus leo tincidunt eros, eget luctus quam orci in velit. Praesent scelerisque tortor sed accumsan convallis.</p> -->
</div>
<div class="column" id = '2nd_col'>
<h4>Member Rankings</h4>
<table id="usersTable2" class="w3-table-all">
<tr>
<th onclick="w3.sortHTML('#usersTable2', '.item', 'td:nth-child(1)')" style="cursor:pointer">Name</th>
<th onclick="sortTable('usersTable2')" style="cursor:pointer">Effort</th>
</tr>
<script type="text/javascript">
// var p1 = 'Yuting Project';
var table2 = document.getElementById("usersTable2");
var temp2 = document.createElement("tr");
function showDetails(p1)
{
window.location = 'ProjectList.html?username='+p1;
}
var params = {
};
var additionalParams = {
headers: {
},
queryParams: {
'id' : id
}
};
var body = {
};
apigClient.courseGet(params, body, additionalParams)
.then(function(result){
// Add success callback code here.
var dat = result['data']
// console.log(dat)
var proj_list = result['data'][0]['projects']['values'] //replace 0 as i
for (var j = 0; j < proj_list.length; j++) {
additionalParams = {
headers: {
},
queryParams: {
'id' : proj_list[j]
}
};
console.log(proj_list[j])
apigClient.projectGet(params, body, additionalParams)
.then(function(rst){
// rst['data'][0]['stats']
// proj_name.push(rst['data'][0]['repoName'])
// commit_count.push(rst['data'][0]['stats']['commits'].length)
var member = []
var project = rst['data'][0]['projectName']
var commits = rst['data'][0]['stats']['commits']
for (var i = 0; i < commits.length; i++) {
member.push(commits[i]['committer'])
// console.log(member)
}
var mem_set = new Set(member)
var dic = {};
for (var k = 0; k < mem_set.length; k++) {
dic[mem_set[k]] = 0
}
for (var i = 0; i < commits.length; i++) {
dic[commits[i]['committer']] = (dic[commits[i]['committer']] || 0) + 1;
// console.log(dic[commits[i]['committer']])
}
for (var k in dic) {
if (dic.hasOwnProperty(k)) {
console.log(k)
console.log(dic[k])
var temp2 = document.createElement("tr")
temp2.className = "item"
temp2.innerHTML = "<tr class=\"item\"><td>" + k+" in "+project + "</td><td>" + dic[k] + "</td></tr>"
table2.append(temp2)
}
}
// console.log(rst['data'][0]['stats']['commits']['committer'])
}).catch(function(rst){
// Add error callback code here.
});
}
}).catch(function(result){
// Add error callback code here.
});
</script>
</table>
</div>
</div>
</body>
</html>