-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
407 lines (369 loc) · 22.3 KB
/
index.php
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel='shortcut icon' type='image/x-icon' href='favicon.ico' />
<title>CS 1371 TA Index</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400' rel='stylesheet' type='text/css'>
<link href='index.css' rel='stylesheet' type='text/css'>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="./js/iso.js"></script>
<script type="text/javascript" src="./js/cells_by_row.js"></script>
</head>
<body>
<div id="pageWrap">
<div id="popupCover"></div>
<div id="TAInfoPopup">
<div id="closePopup">✗</div>
<div id="TAPopupPic">
<div id="PopupPicDiv"></div>
<div id="popupTAName">
<div id="TAEmail"></div>
</div>
</div>
<div id="TAFunFactsSection" class="clearfix">
<div id="funFactsTitle">Fun Facts:</div>
<div id="funFactButtons" class="clearfix"></div>
<div class="fun-fact-container">
<div id="funFactTitle"></div>
<div id="funFactInnerText"></div>
</div>
</div>
<div id="TAInfoSection" class="clearfix">
<div id="recitationInfo">
<div class="section-title" id="recitationTitle">Recitation</div>
<div class="info-section-wrap border-right">
<div class="rec-info-section clearfix">
<div class="rec-info-icon teach-icon"></div>
<div class="rec-info-data" id="popupSection"></div>
</div>
<div class="rec-info-section clearfix">
<div class="rec-info-icon location-icon"></div>
<div class="rec-info-data" id="popupLocation"></div>
</div>
<div class="rec-info-section clearfix">
<div class="rec-info-icon time-icon"></div>
<div class="rec-info-data" id="popupTime"></div>
</div>
</div>
</div>
<div id="helpdeskInfo">
<div class="section-title" id="helpDeskTitle">Help Desk</div>
<div class="info-section-wrap"></div>
</div>
</div>
</div>
</div>
<h1 id="pageTitle">Meet Your Awesome TAs</h1>
<div id="sortCode">>> sort(TAList, <span id="sortByText">'Section'</span>);</div>
<div id="sortButtons">
<div class="sort-button" id="sortByName">Name</div>
<div class="sort-button" id="sortBySection">Section</div>
<div class="sort-button" id="sortByPosition">Position</div>
<div class="sort-button" id="sortByRandom">I'm Feeling Lucky</div>
</div>
<div class="grid clearfix">
<?php
// Get INFO:
// Info will be JSON:
// gtUsername
// title
// name
// major
// section
// name
// location
// time
// helpDesk (array)
// day
// time
// [['monday','2am-3am'],['friday','1am-3am']]
// funFacts (array)
// question
// answer
// Example JSON
$tmp = file_get_contents("./teachers.json");
// ta-block Start
/*
<div class="ta-block">
<div class="see-more-link">See More</div>
<div class="ta-picture">
<div class="circle-pic-container" id="justingenselPic"></div>
</div>
<div class="ta-info">
<div class="ta-name" data-classInfo="4th year Computer Engineer">Justin Gensel</div>
<div class="ta-section" data-recitationLocation="Klaus 1456" data-recitationTime="R 4:30 - 5:45">D02</div>
</div>
<div class="contact-section">
<div class="contact-title">Contact Justin:</div>
<div class="contact-list">
<a title="desktop" href="mailto:[email protected]?subject=[CS1371]" class="contact-item email" data-email="[email protected]"></a>
<a href="https://mail.google.com/mail/?view=cm&fs=1&[email protected]&su=[CS1371]" class="contact-item gmail"></a>
<a href="http://mail.live.com/default.aspx?page=Compose&[email protected]&subject=[CS1371]" class="contact-item outlook"></a>
</div>
</div>
</div>
*/
$tas = json_decode($tmp);
// For each TA, print example above
foreach ($tas as $ta) {
echo "<div class=\"ta-block\"><a class=\"see-more-link\">See More</a><div class=\"ta-picture\"><div class=\"circle-pic-container\" id=\"";
if (file_exists("./images/TA_Pics/" . $ta->gtUsername . ".jpg")) {
echo $ta->gtUsername . "Pic\" style=\"background-image: url('./images/TA_Pics/" . $ta->gtUsername . ".jpg');\"></div>";
} else {
echo $ta->gtUsername . "Pic\" style=\"background-image: url('./images/TA_Pics/default.jpg');\"></div>";
}
if (file_exists("./images/TAHorizontalPics/" . $ta->gtUsername . ".jpg")) {
echo "<div class=\"TA-back-exists\" data-back-exists=\"true\"> </div>";
} else {
echo "<div class=\"TA-back-exists\" data-back-exists=\"false\"> </div>";
}
if (strlen($ta->title)) {
echo "<div class=\"position-badge\">" . htmlspecialchars($ta->title) . "</div>";
}
echo "</div><div class=\"ta-info\" data-gt-username=\"" . $ta->gtUsername . "\"><div class=\"ta-name\" data-classInfo=\"";
echo htmlspecialchars($ta->major) . "\">" . htmlspecialchars($ta->name) . "</div><div class=\"ta-section\" data-recitationLocation=\"";
echo htmlspecialchars($ta->section->location) . "\" data-recitationTime=\"" . htmlspecialchars($ta->section->time) . "\">" . htmlspecialchars($ta->section->name) . "</div>";
echo "<div class=\"ta-help-desk\">";
// for each Help Desk, print:
foreach ($ta->helpDesk as $help) {
echo "<div data-helpdesk-day=\"" . htmlspecialchars($help->day) . "\" data-helpdesk-time=\"" . htmlspecialchars($help->time) . "\"></div>";
}
echo "</div><div class=\"TAFunFacts\">";
// for each Fun Fact, print:
foreach ($ta->funFacts as $fun) {
echo "<div data-fun-question=\"" . htmlspecialchars($fun->question) . "\" data-fun-answer=\"" . htmlspecialchars($fun->answer) . "\"></div>";
}
echo "</div></div>";
$shortName = htmlspecialchars(strtok($ta->name, " "));
echo "<div class=\"contact-section\"><div class=\"contact-title\">Contact " . $shortName . ":</div><div class=\"contact-list\">";
echo "<a title=\"desktop\" href=\"mailto:" . $ta->gtUsername . "@gatech.edu?subject=[CS1371]\" class=\"contact-item email\" data-email=\"" . $ta->gtUsername . "@gatech.edu\"></a>";
echo "<a href=\"https://mail.google.com/mail/?view=cm&fs=1&to=" . $ta->gtUsername . "@gatech.edu&su=[CS1371]\" class=\"contact-item gmail\"></a>";
echo "<a href=\"http://mail.live.com/default.aspx?page=Compose&to=" . $ta->gtUsername . "@gatech.edu&subject=[CS1371]\" class=\"contact-item outlook\"></a>";
echo "</div></div></div>";
}
?>
</div>
<script>
var harambeExists = false;
$(document).ready(function(){
hoverTimeout = null;
$("#funFactButtons").on('mouseover','.fun-fact-button',function(e){
clearTimeout(hoverTimeout);
$("#funFactInnerText").html($(this).data('answer'));
$("#funFactTitle").html($(this).data('question'));
$(".fun-fact-container").addClass('fun-fact-container-show');
});
$("#funFactButtons").on('mouseleave','.fun-fact-button',function(e){
hoverTimeout = setTimeout(function() {
$(".fun-fact-container").removeClass('fun-fact-container-show');
}, 500);
});
function getRandomSubarray(arr, size) {
const shuffled = arr.slice(0);
let i = arr.length;
while (i--) {
const index = Math.floor((i + 1) * Math.random());
const temp = shuffled[index];
shuffled[index] = shuffled[i];
shuffled[i] = temp;
}
return shuffled.slice(0, size);
}
var switchPopupText = true;
$(".grid").on('click','.ta-block .see-more-link',function(e){
var name = $(this).siblings('.ta-info').children('.ta-name').html();
var username = $(this).siblings('.ta-info').attr('data-gt-username');
var classInfo = $(this).siblings('.ta-info').children('.ta-name').attr('data-classInfo');
var email = $(this).siblings('.contact-section').children('.contact-list').children('.email').data('email');
var section = $(this).siblings('.ta-info').children('.ta-section').html();
var recLocation = $(this).siblings('.ta-info').children('.ta-section').attr('data-recitationLocation');
var recTime = $(this).siblings('.ta-info').children('.ta-section').attr('data-recitationTime');
var positionBadge = $(this).siblings('.ta-picture').children('.position-badge');
var helpdesk = $(this).siblings('.ta-info').children('.ta-help-desk').children();
var helpdeskTimes = [];
helpdesk.each(function(index) {
var time = $(this).attr('data-helpdesk-time');
var date = $(this).attr('data-helpdesk-day');
helpdeskTimes.push([date, time]);
});
var facts = $(this).siblings('.ta-info').children('.TAFunFacts').children();
var funFacts = [];
facts.each(function(index) {
var question = $(this).attr('data-fun-question');
var answer = $(this).attr('data-fun-answer');
funFacts.push([question, answer]);
});
if (funFacts.length > 5) {
var tmp = [];
var inds = [];
for (var i = 0; i < 5; i++) {
var ind;
var isUnique = false;
while (!isUnique) {
// Generate new random number
ind = Math.floor(Math.random() * funFacts.length);
// check if exists
isUnique = true;
for (var j = 0; j < inds.length; j++) {
if (inds[j] === ind) {
isUnique = false;
break;
}
}
}
tmp.push(funFacts[ind]);
inds.push(ind);
}
funFacts = tmp;
}
var allHelpDeskTimes = '';
for(var i = 0; i<helpdeskTimes.length; i++){
allHelpDeskTimes += getHelpdeskDiv(helpdeskTimes[i]);
}
funFactSubArray = getRandomSubarray(funFacts,5);
var allFunFacts = '';
for(var i = 0; i < funFactSubArray.length; i++){
allFunFacts += getFunFactDiv(funFactSubArray[i],i+1);
}
allFunFacts += '<div class="fun-fact-button grad-button" data-question="Class and Major" data-answer="' +
classInfo + '"></div>';
$("#PopupPicDiv").removeClass();
var imageUrl = null;
if($(this).siblings('.ta-picture').children('.TA-back-exists').attr('data-back-exists')==='true'){
imageUrl = './images/TAHorizontalPics/' + username + '.jpg';
}else{
imageUrl = './images/TAHorizontalPics/default.jpg';
}
$('#PopupPicDiv').css('background-image', 'url(' + imageUrl + ')');
$("#PopupPicDiv").addClass(name.replace(/ /g,'').replace("'","").toLowerCase() + 'horizontal');
$("#helpdeskInfo .info-section-wrap").html(allHelpDeskTimes);
$("#funFactButtons").html(allFunFacts);
$("#popupTAName").html(name + '<a href="mailto:' + email + '" id="TAEmail">' + email + '</a>');
$("#popupSection").html(section);
$("#popupLocation").html(recLocation);
$("#popupTime").html(recTime);
if(positionBadge.length && positionBadge.html().charAt(0)==='I'){
$("#recitationTitle").html("Lecture");
$("#helpDeskTitle").html("Office Hours");
$("#helpdeskInfo").hide();
$("#recitationInfo").addClass("instructor");
} else {
$("#recitationTitle").html("Recitation");
$("#helpDeskTitle").html("Help Desk");
$("#helpdeskInfo").show();
$("#recitationInfo").removeClass("instructor");
}
$("#popupCover").show();
$("#TAInfoPopup").show();
});
function getFunFactDiv(funFactArr,number){
return '<div class="fun-fact-button" ' +
'data-question=\"' + funFactArr[0] + '\" ' +
'data-answer=\"' + funFactArr[1].replace(/"/g, "'") + '\">' + number + '</div>';
}
function getHelpdeskDiv(helpDeskTimeArr){
return '<div class="rec-info-section clearfix">' +
'<div class="rec-info-icon ' + helpDeskTimeArr[0] + '"></div>' +
'<div class="rec-info-data">'+ helpDeskTimeArr[1] + '</div></div>';
}
$("#closePopup").click(function(e){
$("#popupCover").hide();
$("#TAInfoPopup").hide();
});
$(".fun-fact-label").click(function(e){
$(".fun-fact-data").addClass('fun-fact-data-show');
});
var $grid = $('.grid').isotope({
itemSelector: '.ta-block',
layoutMode: 'cellsByRow',
getSortData: {
name: '.ta-name',
section: '.ta-section',
position: function( itemElem ) {
let name = $(itemElem).find('.ta-name').text();
var weight = $( itemElem ).find('.position-badge').text();
if(weight.length){
if (weight === "CS 1371 Swag") {
return 0;
} else if (weight === "Instructor") {
if (name === "David Smith") {
return 1;
} else if (name === "Kantwon Rogers") {
return 2;
} else {
return 3;
}
} else if (weight === "Head TA") {
return 4;
} else if (weight === "Course Manager") {
return 5;
} else if (weight === "Homework Team STA") {
return 6;
} else if (weight === "Test Team STA") {
return 7;
} else if (weight === "Software Dev STA") {
return 8;
}
} else {
return 99;
}
}
}
});
$("#sortByName").click(function(e){
$grid.isotope({ sortBy : 'name' });
});
$("#sortBySection").click(function(e){
$grid.isotope({ sortBy : 'section' });
});
$("#sortByPosition").click(function(e){
$grid.isotope({ sortBy : 'position' });
});
$("#sortByRandom").click(function(e){
$grid.isotope('shuffle');
});
$(".sort-button").on('click',function(e){
$("#sortByText").html("'" + $(this).attr('id').substr(6) + "'");
});
$("#sortCode").on('click',function(e){
$('#sortByText').replaceWith("<select id='sortSelect'><option>'Name'</option><option>'Section'</option><option>'Position'</option><option>'I'm Feeling Lucky'</option><option>'Waldo'</option><select>");
});
$("#sortCode").on('change',"#sortSelect",function(e){
choice = $(this).find(':selected').html();
if(choice=="'Adam'"){
adamBlock = $('.ta-name:contains("Adam Silverman")').parent().parent();
$('.ta-info').each(function(){
$(this).replaceWith(adamBlock.find('.ta-info').prop('outerHTML'));
});
$('.contact-section').each(function(){
$(this).replaceWith(adamBlock.find('.contact-section').prop('outerHTML'));
});
$('.ta-picture').each(function(){
$(this).replaceWith(adamBlock.find('.ta-picture').prop('outerHTML'));
});
harambeExists = false;
}else if(choice=="'Waldo'"){
if(!harambeExists){
waldoHTML = $('<div class="ta-block" style="position: absolute; left: 184px; top: 2094px;"><a class="see-more-link">See More</a><div class="ta-picture"><div class="circle-pic-container" style="background-image: url(\'./images/TA_Pics/waldo.jpg\');"></div><div class="position-badge">CS 1371 Swag</div></div><div class="ta-info" data-gt-username="waldo"><div class="ta-name" data-classinfo="20th year Hide and Seek Major">Waldo</div><div class="ta-section" data-recitationlocation="CoC 109" data-recitationtime="1:00 am - 3:00 am">TA</div><div class="ta-help-desk"><div data-helpdesk-day="monday" data-helpdesk-time="2am-3am"></div><div data-helpdesk-day="friday" data-helpdesk-time="1am-3am"></div></div><div class="TAFunFacts"><div data-fun-question="Favorite Matlab Function" data-fun-answer="why"></div><div data-fun-question="Favorite Hashtag" data-fun-answer="#wheresWaldo"></div><div data-fun-question="Favorite Homework Problem" data-fun-answer="sixDegreesOfWaldo"></div><div data-fun-question="Hobbies" data-fun-answer="Hide and Go Seek"></div><div data-fun-question="Most embarrassing story from middle school" data-fun-answer="The other kids made fun of me so I vowed to go into hiding forever"></div><div data-fun-question="Favorite quote" data-fun-answer="I\'ve never liked the recognition, the questions, the publicity. I have often felt like running away and hiding. - Al Pacino"></div><div data-fun-question="Advice to your 5th grade self" data-fun-answer="Do not listen to your friends when they say \'bet you can\'t beat me at hide and seek!\'"></div><div data-fun-question="Favorite Song" data-fun-answer="What does Waldo say"></div><div data-fun-question="I am the best in the world at:" data-fun-answer="Hide and Seek"></div><div data-fun-question="When I was 5 years old, I wanted to be a..." data-fun-answer="CS 1371 TA"></div><div data-fun-question="Best Joke" data-fun-answer="Why did Waldo go to therapy? To find himself"></div></div></div><div class="contact-section"><div class="contact-title">Contact Waldo:</div><div class="contact-list"><a title="desktop" href="mailto:[email protected]?subject=[CS1371]" class="contact-item email" data-email="[email protected]"></a><a href="https://mail.google.com/mail/?view=cm&fs=1&[email protected]&su=[CS1371]" class="contact-item gmail"></a><a href="http://mail.live.com/default.aspx?page=Compose&[email protected]&subject=[CS1371]" class="contact-item outlook"></a></div></div></div>');
$('.grid').append( waldoHTML ).isotope( 'addItems', waldoHTML );
$grid.isotope({ sortBy : 'position' });
harambeExists = true;
}
}else if(choice=="'Name'"){
$grid.isotope({ sortBy : 'name' });
}else if(choice=="'Section'"){
$grid.isotope({ sortBy : 'section' });
}else if(choice=="'Position'"){
$grid.isotope({ sortBy : 'position' });
}else{
$grid.isotope('shuffle');
}
$('#sortSelect').replaceWith('<span id="sortByText">' + choice + '</span>');
});
$grid.isotope({ sortBy : 'section' });
});
</script>
</body>
</html>