-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
597 lines (541 loc) · 27.2 KB
/
index.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
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
<!DOCTYPE html>
<html>
<head>
<title>Tidbits: A not-so boring website</title>
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="./node_modules/@fortawesome/fontawesome-free/css/all.css">
</head>
<body>
<div class="body">
<div id="scroll">
<div id="first" class="scroll_item"> </div>
<div id="second" class="scroll_item"> </div>
<div id="third" class="scroll_item"> </div>
<div id="fourth" class="scroll_item"> </div>
<div id="fifth" class="scroll_item"> </div>
</div>
<section class="section1" id="first1">
<div class="left">
<h1>welcome to tidbits</h1>
<h3 class="firsth3">Tidbits is an online gamified community for the sharing of student resources. In this community, earn points from studying to make and trade snacks and share study materials with each other.</h3>
</div>
</section>
<section class="section1" id="second1">
<div class="right">
<h1>what we do</h1>
<h3 class="rightText secondh3">We are a team of JC friends hoping to reignite the fun in learning. Having worked together on countless notes and materials, and having the interest in game development, we hope to further this project. </h3>
</div>
</section>
<section class="section1" id="third1">
<div class="left">
<h1>future plans</h1>
<h3 class="thirdh3">We are currently using ReactJS to launch an alpha version of the website with limited gamification. Afterwards, we will expand towards creating an interactive town-like game likely using 3js. Our long term plan is to establish an international
community of students.</h3>
</div>
</section>
<section class="section1" id="fourth1">
<h1>timeline</h1>
<h6>Press on the circular buttons to move through the timeline!<br>Press on each date to view details.
</h6>
<section class="cd-horizontal-timeline">
<div class="timeline">
<div class="events-wrapper">
<div class="events">
<ol>
<li><a href="#0" data-date="01/01/2022" class="selected">1 Jan</a></li>
<li><a href="#0" data-date="15/01/2022">15 Jan</a></li>
<li><a href="#0" data-date="26/01/2022">26 Jan</a></li>
<li><a href="#0" data-date="01/02/2022">1 Feb</a></li>
<li><a href="#0" data-date="01/05/2022">May</a></li>
</ol>
<span class="filling-line" aria-hidden="true"></span>
</div>
<!-- .events -->
</div>
<!-- .events-wrapper -->
<ul class="cd-timeline-navigation">
<li><a href="#0" class="prev inactive">Prev</a></li>
<li><a href="#0" class="next">Next</a></li>
</ul>
<!-- .cd-timeline-navigation -->
</div>
<!-- .timeline -->
<div class="events-content">
<ol>
<li class="selected" data-date="01/01/2022">
<h2>Public Release of Tidbits</h2>
<em>January 1, 2022</em>
<p>The landing page of Tidbits is launched.</p>
</li>
<li data-date="15/01/2022">
<h2>Developer Update #1</h2>
<em>January 15, 2022</em>
<p>After half a month of progress, a sneak peek of the alpha website will be shown.</p>
</li>
<li data-date="26/01/2022">
<h2>Release of alpha website</h2>
<em>January 26, 2022</em>
<p>
The alpha website is aimed to be up and running by then.
</p>
</li>
<li data-date="01/02/2022">
<h2>Monthly developer updates</h2>
<em>February, 2022 to August, 2022</em>
<p>Every month, the team will review targets and track the progress of the app.</p>
</li>
<li data-date="01/05/2022">
<h2>Release of beta website</h2>
<em>May 2022</em>
<p>The beta website will be gamified and coded with 3js.</p>
</li>
</ol>
</div>
<!-- .events-content -->
</section>
</section>
<section class="section1" id="fifth1">
<div class="left">
<h1>thank you!</h1>
<h3>Tidbits is still under development, so we hope to see you soon!</h3>
<div class="vertical-center">
<button src="https://forms.gle/zY3DRadHWY3WGAh49" class="custom-btn btn-16">join the candy enthusiasts!</button>
<button src="https://www.instagram.com/dhs22y5d_lam_yikting/" class="custom-btn btn-16">follow our progress!</button>
</div>
</div>
</section>
</div>
<!-- jquery stuff -->
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
jQuery(document).ready(function($) {
var timelines = $(".cd-horizontal-timeline"),
eventsMinDistance = 60;
timelines.length > 0 && initTimeline(timelines);
function initTimeline(timelines) {
timelines.each(function() {
var timeline = $(this),
timelineComponents = {};
//cache timeline components
timelineComponents["timelineWrapper"] = timeline.find(".events-wrapper");
timelineComponents["eventsWrapper"] = timelineComponents[
"timelineWrapper"
].children(".events");
timelineComponents["fillingLine"] = timelineComponents[
"eventsWrapper"
].children(".filling-line");
timelineComponents["timelineEvents"] = timelineComponents[
"eventsWrapper"
].find("a");
timelineComponents["timelineDates"] = parseDate(
timelineComponents["timelineEvents"]
);
timelineComponents["eventsMinLapse"] = minLapse(
timelineComponents["timelineDates"]
);
timelineComponents["timelineNavigation"] = timeline.find(
".cd-timeline-navigation"
);
timelineComponents["eventsContent"] = timeline.children(
".events-content"
);
//assign a left postion to the single events along the timeline
setDatePosition(timelineComponents, eventsMinDistance);
//assign a width to the timeline
var timelineTotWidth = setTimelineWidth(
timelineComponents,
eventsMinDistance
);
//the timeline has been initialize - show it
timeline.addClass("loaded");
//detect click on the next arrow
timelineComponents["timelineNavigation"].on(
"click",
".next",
function(event) {
event.preventDefault();
updateSlide(timelineComponents, timelineTotWidth, "next");
}
);
//detect click on the prev arrow
timelineComponents["timelineNavigation"].on(
"click",
".prev",
function(event) {
event.preventDefault();
updateSlide(timelineComponents, timelineTotWidth, "prev");
}
);
//detect click on the a single event - show new event content
timelineComponents["eventsWrapper"].on("click", "a", function(event) {
event.preventDefault();
timelineComponents["timelineEvents"].removeClass("selected");
$(this).addClass("selected");
updateOlderEvents($(this));
updateFilling(
$(this),
timelineComponents["fillingLine"],
timelineTotWidth
);
updateVisibleContent($(this), timelineComponents["eventsContent"]);
});
//on swipe, show next/prev event content
timelineComponents["eventsContent"].on("swipeleft", function() {
var mq = checkMQ();
mq == "mobile" &&
showNewContent(timelineComponents, timelineTotWidth, "next");
});
timelineComponents["eventsContent"].on("swiperight", function() {
var mq = checkMQ();
mq == "mobile" &&
showNewContent(timelineComponents, timelineTotWidth, "prev");
});
//keyboard navigation
$(document).keyup(function(event) {
if (event.which == "37" && elementInViewport(timeline.get(0))) {
showNewContent(timelineComponents, timelineTotWidth, "prev");
} else if (event.which == "39" && elementInViewport(timeline.get(0))) {
showNewContent(timelineComponents, timelineTotWidth, "next");
}
});
});
}
function updateSlide(timelineComponents, timelineTotWidth, string) {
//retrieve translateX value of timelineComponents['eventsWrapper']
var translateValue = getTranslateValue(timelineComponents["eventsWrapper"]),
wrapperWidth = Number(
timelineComponents["timelineWrapper"].css("width").replace("px", "")
);
//translate the timeline to the left('next')/right('prev')
string == "next" ?
translateTimeline(
timelineComponents,
translateValue - wrapperWidth + eventsMinDistance,
wrapperWidth - timelineTotWidth
) :
translateTimeline(
timelineComponents,
translateValue + wrapperWidth - eventsMinDistance
);
}
function showNewContent(timelineComponents, timelineTotWidth, string) {
//go from one event to the next/previous one
var visibleContent = timelineComponents["eventsContent"].find(".selected"),
newContent =
string == "next" ? visibleContent.next() : visibleContent.prev();
if (newContent.length > 0) {
//if there's a next/prev event - show it
var selectedDate = timelineComponents["eventsWrapper"].find(".selected"),
newEvent =
string == "next" ?
selectedDate.parent("li").next("li").children("a") :
selectedDate.parent("li").prev("li").children("a");
updateFilling(
newEvent,
timelineComponents["fillingLine"],
timelineTotWidth
);
updateVisibleContent(newEvent, timelineComponents["eventsContent"]);
newEvent.addClass("selected");
selectedDate.removeClass("selected");
updateOlderEvents(newEvent);
updateTimelinePosition(
string,
newEvent,
timelineComponents,
timelineTotWidth
);
}
}
function updateTimelinePosition(
string,
event,
timelineComponents,
timelineTotWidth
) {
//translate timeline to the left/right according to the position of the selected event
var eventStyle = window.getComputedStyle(event.get(0), null),
eventLeft = Number(eventStyle.getPropertyValue("left").replace("px", "")),
timelineWidth = Number(
timelineComponents["timelineWrapper"].css("width").replace("px", "")
),
timelineTotWidth = Number(
timelineComponents["eventsWrapper"].css("width").replace("px", "")
);
var timelineTranslate = getTranslateValue(
timelineComponents["eventsWrapper"]
);
if (
(string == "next" && eventLeft > timelineWidth - timelineTranslate) ||
(string == "prev" && eventLeft < -timelineTranslate)
) {
translateTimeline(
timelineComponents, -eventLeft + timelineWidth / 2,
timelineWidth - timelineTotWidth
);
}
}
function translateTimeline(timelineComponents, value, totWidth) {
var eventsWrapper = timelineComponents["eventsWrapper"].get(0);
value = value > 0 ? 0 : value; //only negative translate value
value = !(typeof totWidth === "undefined") && value < totWidth ? totWidth : value; //do not translate more than timeline width
setTransformValue(eventsWrapper, "translateX", value + "px");
//update navigation arrows visibility
value == 0 ?
timelineComponents["timelineNavigation"]
.find(".prev")
.addClass("inactive") :
timelineComponents["timelineNavigation"]
.find(".prev")
.removeClass("inactive");
value == totWidth ?
timelineComponents["timelineNavigation"]
.find(".next")
.addClass("inactive") :
timelineComponents["timelineNavigation"]
.find(".next")
.removeClass("inactive");
}
function updateFilling(selectedEvent, filling, totWidth) {
//change .filling-line length according to the selected event
var eventStyle = window.getComputedStyle(selectedEvent.get(0), null),
eventLeft = eventStyle.getPropertyValue("left"),
eventWidth = eventStyle.getPropertyValue("width");
eventLeft =
Number(eventLeft.replace("px", "")) +
Number(eventWidth.replace("px", "")) / 2;
var scaleValue = eventLeft / totWidth;
setTransformValue(filling.get(0), "scaleX", scaleValue);
}
function setDatePosition(timelineComponents, min) {
for (i = 0; i < timelineComponents["timelineDates"].length; i++) {
var distance = daydiff(
timelineComponents["timelineDates"][0],
timelineComponents["timelineDates"][i]
),
distanceNorm =
Math.round(distance / timelineComponents["eventsMinLapse"]) + 2;
timelineComponents["timelineEvents"]
.eq(i)
.css("left", distanceNorm * min + "px");
}
}
function setTimelineWidth(timelineComponents, width) {
var timeSpan = daydiff(
timelineComponents["timelineDates"][0],
timelineComponents["timelineDates"][
timelineComponents["timelineDates"].length - 1
]
),
timeSpanNorm = timeSpan / timelineComponents["eventsMinLapse"],
timeSpanNorm = Math.round(timeSpanNorm) + 4,
totalWidth = timeSpanNorm * width;
timelineComponents["eventsWrapper"].css("width", totalWidth + "px");
updateFilling(
timelineComponents["timelineEvents"].eq(0),
timelineComponents["fillingLine"],
totalWidth
);
return totalWidth;
}
function updateVisibleContent(event, eventsContent) {
var eventDate = event.data("date"),
visibleContent = eventsContent.find(".selected"),
selectedContent = eventsContent.find('[data-date="' + eventDate + '"]'),
selectedContentHeight = selectedContent.height() * 1.3;
// !!!IMPT TO NOTE I CHANGED THIS TO ALLOW HEIGHT
if (selectedContent.index() > visibleContent.index()) {
var classEnetering = "selected enter-right",
classLeaving = "leave-left";
} else {
var classEnetering = "selected enter-left",
classLeaving = "leave-right";
}
selectedContent.attr("class", classEnetering);
visibleContent
.attr("class", classLeaving)
.one(
"webkitAnimationEnd oanimationend msAnimationEnd animationend",
function() {
visibleContent.removeClass("leave-right leave-left");
selectedContent.removeClass("enter-left enter-right");
}
);
eventsContent.css("height", selectedContentHeight + "px");
}
function updateOlderEvents(event) {
event
.parent("li")
.prevAll("li")
.children("a")
.addClass("older-event")
.end()
.end()
.nextAll("li")
.children("a")
.removeClass("older-event");
}
function getTranslateValue(timeline) {
var timelineStyle = window.getComputedStyle(timeline.get(0), null),
timelineTranslate =
timelineStyle.getPropertyValue("-webkit-transform") ||
timelineStyle.getPropertyValue("-moz-transform") ||
timelineStyle.getPropertyValue("-ms-transform") ||
timelineStyle.getPropertyValue("-o-transform") ||
timelineStyle.getPropertyValue("transform");
if (timelineTranslate.indexOf("(") >= 0) {
var timelineTranslate = timelineTranslate.split("(")[1];
timelineTranslate = timelineTranslate.split(")")[0];
timelineTranslate = timelineTranslate.split(",");
var translateValue = timelineTranslate[4];
} else {
var translateValue = 0;
}
return Number(translateValue);
}
function setTransformValue(element, property, value) {
element.style["-webkit-transform"] = property + "(" + value + ")";
element.style["-moz-transform"] = property + "(" + value + ")";
element.style["-ms-transform"] = property + "(" + value + ")";
element.style["-o-transform"] = property + "(" + value + ")";
element.style["transform"] = property + "(" + value + ")";
}
//based on http://stackoverflow.com/questions/542938/how-do-i-get-the-number-of-days-between-two-dates-in-javascript
function parseDate(events) {
var dateArrays = [];
events.each(function() {
var dateComp = $(this).data("date").split("/"),
newDate = new Date(dateComp[2], dateComp[1] - 1, dateComp[0]);
dateArrays.push(newDate);
});
return dateArrays;
}
function parseDate2(events) {
var dateArrays = [];
events.each(function() {
var singleDate = $(this),
dateComp = singleDate.data("date").split("T");
if (dateComp.length > 1) {
//both DD/MM/YEAR and time are provided
var dayComp = dateComp[0].split("/"),
timeComp = dateComp[1].split(":");
} else if (dateComp[0].indexOf(":") >= 0) {
//only time is provide
var dayComp = ["2000", "0", "0"],
timeComp = dateComp[0].split(":");
} else {
//only DD/MM/YEAR
var dayComp = dateComp[0].split("/"),
timeComp = ["0", "0"];
}
var newDate = new Date(
dayComp[2],
dayComp[1] - 1,
dayComp[0],
timeComp[0],
timeComp[1]
);
dateArrays.push(newDate);
});
return dateArrays;
}
function daydiff(first, second) {
return Math.round(second - first);
}
function minLapse(dates) {
//determine the minimum distance among events
var dateDistances = [];
for (i = 1; i < dates.length; i++) {
var distance = daydiff(dates[i - 1], dates[i]);
dateDistances.push(distance);
}
return Math.min.apply(null, dateDistances);
}
/*
How to tell if a DOM element is visible in the current viewport?
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function elementInViewport(el) {
var top = el.offsetTop;
var left = el.offsetLeft;
var width = el.offsetWidth;
var height = el.offsetHeight;
while (el.offsetParent) {
el = el.offsetParent;
top += el.offsetTop;
left += el.offsetLeft;
}
return (
top < window.pageYOffset + window.innerHeight &&
left < window.pageXOffset + window.innerWidth &&
top + height > window.pageYOffset &&
left + width > window.pageXOffset
);
}
function checkMQ() {
//check if mobile or desktop device
return window
.getComputedStyle(
document.querySelector(".cd-horizontal-timeline"),
"::before"
)
.getPropertyValue("content")
.replace(/'/g, "")
.replace(/"/g, "");
}
});
// scroll function
$(document).ready(function() {
$("#first").addClass('scroll_item_active');
var main = main = $('#scroll');
$('.scroll_item').click(function(event) {
event.preventDefault();
var trgt = $(this).attr('id') + "1";
target_offset = $('#' + trgt).offset(),
target_top = target_offset.top;
$('html, body').animate({
scrollTop: target_top
}, 500);
main.children().removeClass('scroll_item_active');
$(this).addClass('scroll_item_active');
});
$(window).scroll(function(event) {
if ($("#first1").offset().top < $(window).scrollTop() + $(window).outerHeight()) {
$("#first").addClass('scroll_item_active');
$("#second").removeClass('scroll_item_active');
$("#third").removeClass('scroll_item_active');
$("#fourth").removeClass('scroll_item_active');
$("#fifth").removeClass('scroll_item_active');
}
if ($("#second1").offset().top < $(window).scrollTop() + $(window).outerHeight()) {
$("#second").addClass('scroll_item_active');
$("#first").removeClass('scroll_item_active');
$("#third").removeClass('scroll_item_active');
$("#fourth").removeClass('scroll_item_active');
$("#fifth").removeClass('scroll_item_active');
}
if ($("#third1").offset().top < $(window).scrollTop() + $(window).outerHeight()) {
$("#third").addClass('scroll_item_active');
$("#first").removeClass('scroll_item_active');
$("#second").removeClass('scroll_item_active');
$("#fourth").removeClass('scroll_item_active');
$("#fifth").removeClass('scroll_item_active');
}
if ($("#fourth1").offset().top < $(window).scrollTop() + $(window).outerHeight()) {
$("#fourth").addClass('scroll_item_active');
$("#first").removeClass('scroll_item_active');
$("#second").removeClass('scroll_item_active');
$("#third").removeClass('scroll_item_active');
$("#fifth").removeClass('scroll_item_active');
}
if ($("#fifth1").offset().top < $(window).scrollTop() + $(window).outerHeight()) {
$("#fourth").removeClass('scroll_item_active');
$("#first").removeClass('scroll_item_active');
$("#second").removeClass('scroll_item_active');
$("#third").removeClass('scroll_item_active');
$("#fifth").addClass('scroll_item_active');
}
});
});
</script>
</body>