-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
678 lines (564 loc) · 20.4 KB
/
index.html
File metadata and controls
678 lines (564 loc) · 20.4 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
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Maker Hub EntrySwipe System</title>
<meta name="Resource-type" content="Document" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.5/jquery.fullpage.min.css" />
<style>
/* Sections
* --------------------------------------- */
#section0 img,
#section1 img{
margin: 20px 0 0 0;
}
#section2 img{
margin: 20px 0 0 52px;
}
#section3 img{
bottom: 0px;
position: absolute;
margin-left: -420px;
}
.intro p{
width: 50%;
margin: 0 auto;
font-size: 1.5em;
}
.twitter-share-button{
position: absolute;
z-index: 99;
right: 149px;
top: 9px;
}
</style>
<!--[if IE]>
<script type="text/javascript">
var console = { log: function() {} };
</script>
<![endif]-->
<?!= include("STYLESHEET"); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.5/jquery.fullpage.min.js"></script>
<script src="https://cdn.rawgit.com/thanashyam/2309671/raw/5168575d69cd84588c52aa183dbfb3d932b9d4f9/jquery.md5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.1/moment-with-locales.min.js" crossorigin="anonymous"></script>
</head>
<body>
<div id="fullpage">
<div class="section welcomesection" id="welcomeScreen">
<div class="slide active">
<h1>Welcome to the MakerHub</h1>
<input type="hidden" name="id" value="1" />
<p>Swipe to sign in!</p>
<input style="" id="swipeenter"/>
<img style="width: 300px; height:300px;" src="https://drive.google.com/uc?export=download&id=1mmQbk3GkOeNzRkOSs66CqO_az5njdod3RA" id="swipeimg" alt="swipe" class="rotate270" />
</div>
<div class="slide" id="unknownScreen">
<div class="unknownUser" tabindex="-1">
<h1>Looks like you're not in our system!</h1>
<p>Find a Staff Person to set you up</p>
<div class="staffOnShiftList"></div>
</div>
<div class="backdiv">
<button class="backtostart solo">Back to Start</button>
</div>
</div>
</div>
<div class="section">
<p>Welcome <span class="namedisplay"></span></p>
<h1>Today I'm here for:</h1>
<div class="entryReasonsButtons">
</div>
<BR>
<div class="navbuttons">
<div class="backdiv">
<button class="backtostart">Back to Start</button>
</div>
<div class="entryContinueButton niceoval nextbutton">Next</div>
</div>
</div>
<div class="section">
<h1>I'm probably working with:</h1>
<div class="workingOnButtons">
</div>
<BR>
<div class="navbuttons">
<div class="backdiv">
<button class="backtostart">Back to Start</button>
</div>
<div class="workingContinueButton niceoval nextbutton">Next</div>
</div>
</div>
<div class="section" id="userDisplayScreen">
<div id="output" class="intro">
<div id="project-wrapper">
<div id="project-container">
<div id="hero">
<div id="overlay"></div>
<div id="overlay2"></div>
<div id="hero-content">
<h2> <span id="username">User</span>!</h2>
<div id="tasks">
<br> Help Us Out!
<img src="https://i.pinimg.com/originals/4c/32/82/4c3282033866e22b7ceab02b84899b2a.gif" alt="Smiley face" height="60" width="67">
</div>
<div id="tasksList">
Find Something To do!
</div>
<div id="taskmessage">
<br><br>Look at the Maker Hub App or Trello for more details!
</div>
<!--
<ul>
<li>
<h3>Visits</h3>
<p id="visitCount">118</p>
</li>
<li>
<h3>Skills</h3>
<p id="skillCount">20</p>
</li>
</ul>
-->
<button class="backtostart solo">Back to start</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Swipe is %[numbers and letters]? - gets md5 encrypted before testing
// secret testing guid is 123
var meritBadges = [];
function populateMeritBadges(callback){
google.script.run.withSuccessHandler(function(data){
meritBadges = data;
if(callback){callback();}
}).getMeritBadges();
}
var entryReasons = [];
function populateEntryReasons(callback){
google.script.run.withSuccessHandler(function(data){
entryReasons = data;
if(callback){callback();}
}).getEntryReasons();
}
var workingOn = [];
function populateWorkingOn(callback){
google.script.run.withSuccessHandler(function(data){
workingOn = data;
if(callback){callback();}
}).getWorkingOn();
}
function populateMetadata(callback){
populateMeritBadges(callback);
populateEntryReasons(callback);
populateWorkingOn(callback);
}
/*
var imageUrls = {};
function placeImageAt(imagename, selector){
google.script.run.withSuccessHandler(function(url){
if(url){
imageUrls[imagename] = url;
$(selector).attr("src",url);
}
}).getImageUrl(imagename);
}
*/
var imageUrls = {"swipe.png":"https://drive.google.com/uc?export=download&id=1mmQbk3GkOeNzRkOSs66CqO_az5njdod3RA",
"loading.gif": "https://drive.google.com/uc?export=download&id=1Lc8vsUQkbb_xdr-urZ10aKevMloQvrTB9w"};
var blobTexts = {};
function placeImageAt(imagename, selector){
if(imageUrls[imagename]){
$(selector).attr("src", imageUrls[imagename]);
}
}
/*
function placeImageAt(imagename, selector){
console.log("placing image");
google.script.run
.withFailureHandler(function(msg){
console.log("Error");
console.log(msg);
})
.withSuccessHandler(function(data){
console.log("got data " + data);
if(data){
var bytes = new Uint8Array(data.blob);
var blobtext = URL.createObjectURL(new Blob([bytes], {type: data.contentType}));
blobTexts[imagename] = blobtext;
// placeItem(blobtext, _item.description, _item.timestamp);
//$("#testimg").attr("src",blobtext);
$(selector).attr("src", blobtext);
}
})
.getFileBlob(imagename);
return;
}
*/
function getUserDataFromSwipe(swipemd5, callback){
google.script.run.withSuccessHandler(function(data){
console.log(data);
if(callback){
callback(data);
}
}).getUserTableDataFromSwipe(swipemd5);
}
var sessionRand = 0;
var prevRand = 0;
function loadSwipePage(silent){
currentUser = false;
sessionRand = Math.random(); // a random identifier for each swipe session, to help us make sure we're not duplicating data entry
clearTimeout(currentTimeout);
$(".namedisplay").text("");
$("#swipeenter").focus();
$("#swipeenter").hide();
if(imageUrls["swipe.png"]){
console.log("setting swing.png");
$("#swipeimg").attr("src", imageUrls["swipe.png"]);
$("#swipeimg").addClass("rotate270");
}
if(silent){
$.fn.fullpage.silentMoveTo('firstPage', 0);
}else{
$.fn.fullpage.moveTo('firstPage', 0);
}
var payload = ""; //where the userID is stored
var recording = false;//whether or not the page is recording keystrokes
// alert("Press 'a1234b' and 'a5678b' to simulate the cardswiper. Card swiper values are in comments")
$(document).off("keydown"); // make sure we're not duplicating any event listeners, remove them first
$(document).keydown(function( event ) {
event.preventDefault();//prevents default actions
console.log(event.key);
if (event.key == "%" /*53*/) { //when a is pressed, start recording and move to second page
// note: this will change when we use a real card.
recording = true;
console.log("start recording");
loadLoadingPage();
clearTimeout(currentTimeout); // make sure there aren't any other timeouts current in operation
currentTimeout = setTimeout(function(){
if(recording){
recording = false;
payload = "";
currentUser= false;
loadSwipePage(false);
}
},9000) //wait nine seconds on this page: should probs be changed to wait for data
} else if (recording && event.key == "?" /*191*/){ //when b is pressed, stop recording, update card, reset
console.log("stop recording");
console.log(payload);
$(document).off("keydown");
recording = false;
getUserDataFromSwipe($.md5(payload), function(data){
console.log("got data");
console.log(data);
if(!data){
$(document).off("keydown");
clearTimeout(currentTimeout); // make sure there aren't any other timeouts current in operation
loadUnknownUserPage();
}else{
currentUser= data;
$(".namedisplay").text(currentUser.name);
clearTimeout(currentTimeout); // make sure there aren't any other timeouts current in operation
$(document).off("keydown");
loadEntryReasonPage();
}
});
payload = "";
clearTimeout(currentTimeout);
currentTimeout = setTimeout(function(){
loadSwipePage(false);
}, 30000); //wait 9 seconds on this page then go back to the beginning
} else if (recording){
payload += event.key; //add the keys that are pressed between "%" and "?"
} else {
console.log("nope");
return false;
}
});
return;
}
function loadLoadingPage(){
console.log("loading page");
$("#swipeimg").removeClass("rotate270");
$("#swipeimg").attr("src", imageUrls["loading.gif"]);
/*
$.fn.fullpage.moveTo('secondPage', 0);
$(".loadingsection").attr("tabindex",-1).focus();
*/
}
function loadUnknownUserPage(){
console.log("unknown user");
showStaffOnShift();
console.log("moving");
clearTimeout(currentTimeout);
// window.location.href = "#secondPage/1";
$.fn.fullpage.moveTo('firstPage', 1);
// $(".unknownUser").attr("tabindex",-1).focus();
// TODO: Show current staff on shift here.
currentTimeout = setTimeout(function(){
loadSwipePage(true);
// window.location.href = "#firstPage"
}, 15000); //wait 15 seconds on this page then go back to the beginning
}
function loadEntryReasonPage(){
$(".entryReasonRadio").prop("checked", false); // uncheck previous values
clearTimeout(currentTimeout);
$.fn.fullpage.moveTo('secondPage', 0);
$(".entryContinueButton").click(function(){
console.log("click");
entryReason = "";
$(".entryReasonsButtons input:checked").each(function(key, value){
entryReason = entryReasons[this.value]
});
$(".entryContinueButton").off("click");
loadWorkingOnPage();
});
if(currentUser.role == "Visitor")
{
console.log("CURRENT ROLE: "+currentUser.role);
visitorDisplay();
}
else {
findUser();
}
clearTimeout(currentTimeout);
currentTimeout = setTimeout(function(){
loadSwipePage(true);
// window.location.href = "#firstPage"
}, 15000); //wait 15 seconds on this page then go back to the beginning
}
var submitting = false;
function loadWorkingOnPage(){
console.log("working on page");
clearTimeout(currentTimeout);
$.fn.fullpage.moveTo('3rdPage', 0);
$(".workingOnCheckbox").prop("checked", false); // uncheck previous values
$(".workingContinueButton").off("click");
$(".workingContinueButton").click(function(){
if(submitting){
return false;
}
submitting = true;
console.log("recordingEntry");
$(".workingContinueButton").off("click");
var hereToWorkOn = [];
$(".workingOnButtons input:checked").each(function(key, value){
hereToWorkOn.push(workingOn[this.value]);
});
// save to db
// make sure we haven't already submitted this, by using the sessionRand value
if(prevRand != sessionRand){
prevRand == sessionRand;
google.script.run.withSuccessHandler(function(){
submitting = false;
loadWelcomePage();
}).recordEntry(currentUser.name, currentUser.netid, entryReason, "No", currentUser.mailinglist, hereToWorkOn.join(","), currentUser.status);
}
});
clearTimeout(currentTimeout);
currentTimeout = setTimeout(function(){
loadSwipePage(true);
// window.location.href = "#firstPage"
}, 30000); //wait 15 seconds on this page then go back to the beginning
}
function loadWelcomePage(){
//this page then resets back to the original after a couple seconds
$("#hero").css("background", "url('"+ currentUser.ImageUrl +"')"); //update the contact picture
$("#username").text("Welcome " + currentUser.name); //update the nam
// $("#visitCount").text(data.visitCount);//update the visit count if that exists
// $("#skillCount").text(netID.skillCount);//update the skill count if that exists
// TODO: update with more interesting data,
// TODO: show current staff on this page?
clearTimeout(currentTimeout);
$.fn.fullpage.moveTo('4thPage', 0);
currentTimeout= setTimeout(function(){
loadSwipePage(true);
},30000);
}
var tasknum=0;
function findUser()
{
google.script.run.withFailureHandler(function(message){
console.log("error" + message);
})
.withSuccessHandler(function(data){
$("#tasksList").empty();
$("#tasks").empty();
$("#taskmessage").empty();
tasknum=0;
$("#taskmessage").html("<br><br> Look at the Maker Hub App or Trello for more details!");
$("#tasks").html("<br>Help Us Out!");
$("#tasks").append("<img src='https://i.pinimg.com/originals/4c/32/82/4c3282033866e22b7ceab02b84899b2a.gif' alt='Smiley face' height='60' width='67'>");
getCards("makerhub4");
var trello=data.checklistData.data["Trello ID"];
getCards(trello);
})
.getStaffData(currentUser.netid);
}
function getCards(trelloID){
google.script.run
.withFailureHandler(function(e){
console.log("ERROR in getCards ");
console.log(e)
$(".getTrelloCardError").text("Doh! there was a problem submitting: " + e);
submitting = false;
})
.withSuccessHandler(function(data){
console.log("Got Trello Cards for "+trelloID);
console.log(data);
displayTrelloCards(data);
submitting = false;
})
.getTrelloCards(trelloID);
}
function displayTrelloCards(data)
{
$.each(data.cards,function(index,card){
tasknum++;
if(tasknum<8){
if(tasknum%2==0)
$("#tasksList").append("<div style='background-color:#2a8c73'class=task"+tasknum+">"+card.name+"<br/></div>");
else
$("#tasksList").append("<div style='background-color:#34aa8c'class=task"+tasknum+">"+card.name+"<br/></div>");
}
});
}
function visitorDisplay()
{
var messages = ["Have Fun!", "Learn Something New!", "Explore!"];
$("#tasks").empty();
$("#taskmessage").empty();
$("#tasksList").empty();
var choice= Math.floor(Math.random() * 2);
console.log("CHOICE: " + choice);
$("#tasks").append("<br>"+messages[choice]);
}
function placeImages(){
// set up images, from the "forWebsites" folder in dhu3's google photos.
placeImageAt("swipe.png", "#swipeimg");
placeImageAt("loading.gif", "#loadingimg");
}
function renderMetadata(){
$.each(entryReasons, function(key, value){
var check = $('<input class="entryReasonRadio" id="entryReasons['+key+']" type="radio" name="entryReasons" value="'+key+'" /> <label class="niceoval" for="entryReasons['+key+']">'+value+'</label>');
$(".entryReasonsButtons").append(check);
});
$.each(workingOn, function(key, value){
var check = $('<input class="workingOnCheckbox" id="workingOn['+key+']" type="checkbox" name="workingOn[]" value="'+key+'" /> <label class="niceoval" for="workingOn['+key+']">'+value+'</label>');
$(".workingOnButtons").append(check);
});
}
function allStaffRenderDataReady(callback){
if(staffChecklist && staffOnShift){
callback();
}
}
var staffChecklist = false;
function getStaffChecklist(checkCallback, doCallback){
google.script.run
.withFailureHandler(function(error){console.log(error);})
.withSuccessHandler(function(data){
staffChecklist = data;
console.log(staffChecklist);
if(checkCallback){checkCallback(doCallback);}
}).getStaffChecklist();
}
function renderStaffOnShift(){
$(".staffOnShiftList").empty(); // clear what's already there.
console.log(staffOnShift);
var staff = Object.keys(staffOnShift);
if(staff.length == 0){
var staffdiv = $("<div class='grid-item noone refreshable staffDiv'></div>");
$(".staffOnShiftList").append("<div class='name'>No One On Staff</div><div clas='time'>Come back later</div>");
}
$.each(staff, function(key, email){
console.log("staff");
var checklist = staffChecklist.checklistData.data.filter(function(s){
return (s.NetId + "@georgetown.edu").toLowerCase() == email.toLowerCase();
})[0];
var sched = staffOnShift[email];
console.log("Checklist");
console.log(checklist);
var img = checklist["Pic on Website"];
var name = checklist["Name"];
var shiftStart = moment(sched[0].startTime);
var shiftEnd = moment(sched[0].endTime);
var time = shiftStart.format("h:mm") + " - " + shiftEnd.format("h:mm a");
var staffdiv = $("<div class='grid-item refreshable staffDiv'></div>");
if(img.trim().match(/http/)){
$(staffdiv).append("<img src='"+img+"' />");
}
$(staffdiv).append("<div class='name'>"+name+"</div>");
$(staffdiv).append("<div class='time'>"+time+"</div>");
$(".staffOnShiftList").append(staffdiv);//.masonry("appended", staffdiv);
});
var clickGo = $("<div class='grid-item noone refreshable staffDiv'></div>");
var clickGoToSwipe = $("<div class='name'>Got It!</div><div class='time'>Back to Swipe-in</div>").appendTo(clickGo);
$(".staffOnShiftList").append(clickGo);
$(clickGo).click(function(){
clearTimeout(currentTimeout);
$.fn.fullpage.silentMoveTo('secondPage', 0); // go back to leftmost part of this section, to reset it back to the original position
loadSwipePage(true);
// window.location.href = "#firstPage"
});
setTimeout(function(){
// $(".grid").masonry("layout");
}, 500);
}
var staffOnShift = false;
function getStaffOnShift(startTime, endTime, currentTime, checkCallback, doCallback){
google.script.run
.withFailureHandler(function(error){console.log(error);})
.withSuccessHandler(function(data){
staffOnShift = data;
console.log(staffOnShift);
if(checkCallback){checkCallback(doCallback);}
}).getStaffOnShift(startTime, endTime, currentTime);
}
function showStaffOnShift(){
// var now = moment("2017-11-21 18:30", "YYYY-MM-DD HH:mm");
var now = moment();
var startTime = moment(now).add(-5, "minutes");
var endTime = moment(now).add(5, "minutes");
staffChecklist = staffOnShift = false;
getStaffChecklist(allStaffRenderDataReady, renderStaffOnShift);
getStaffOnShift(startTime.toString(), endTime.toString(), now.toString(), allStaffRenderDataReady, renderStaffOnShift);
}
var entryReason = "";
var ready = false;
var currentUser= false;
var currentTimeout= false;
$(document).ready(function(){
if(ready){
return;
}
ready = true;
$('#fullpage').fullpage({
sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', 'whitesmoke', '#ccddff'],
anchors: ['firstPage', 'secondPage', '3rdPage', '4thPage', '5thPage'],
// menu: '#menu',
controlArrows: false,
scrollingSpeed: 1000,
afterLoad: function (anchor, index) {
console.log("afterLoad " + index + " anchor " + anchor);
}
});
// populate the metadata we store server-side
populateMetadata(function(){
if(meritBadges.length > 0 && entryReasons.length > 0 && workingOn.length > 0){
renderMetadata();
}
});
$(".backtostart").click(function(){
loadSwipePage();
});
placeImages();
loadSwipePage();
});
</script>
</body>
</html>