-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
111 lines (86 loc) · 2.87 KB
/
main.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
// Loaded ******************************************************
const isNotFirstKey = "isNotFirst";
$(window).on("load", () => {
const isNotFirst = sessionStorage.getItem(isNotFirstKey);
$("#preloader").css({
opacity: 0,
visibility: "hidden",
transitionDelay: isNotFirst ? "0s" : "4s",
});
isNotFirst
? $("section#notice_banner").removeClass("active")
: setTimeout(() => {
$("section#notice_banner").addClass("active");
}, 4200);
sessionStorage.setItem(isNotFirstKey, true);
});
// Scrolled *******************************************************
$(window).scroll(() => {
$("header").toggleClass("scrolled", window.scrollY > 1000);
});
// let scrollPos = 0;
// window.addEventListener("scroll", () => {
// let scrollPosNow = window.pageYOffset || document.pageYOffset;
// if (scrollPosNow > scrollPos) {
// $("header").addClass("active");
// } else {
// $("header").removeClass("active");
// }
// scrollPos = scrollPosNow;
// });
// Navbar Toggle ***************************************************
$("div.menu_btn, a.nav_links").click(() => {
$("div.menu_btn").toggleClass("active");
});
// #Id Url, Page Scroll *********************************************
$('a[href^="#"]').click(function (e) {
e.preventDefault();
$("html, body").animate(
{
scrollTop: $($(this).attr("href")).offset().top,
},
500,
);
});
// Accordion Slide Toggle *********************************************
$("div.faq_card").click(function () {
$(this).toggleClass("active");
$(this).find("span p").slideToggle(200);
});
// Go Back Function *********************************************
$(".goBack").click(function () {
window.history.back();
});
// Count Down Function *********************************************
function countTimer() {
const getDate = $("div.timer").attr("data-date");
const finalDate = new Date(getDate).getTime();
const intDate = new Date().getTime();
let seconds = 1000;
let minutes = seconds * 60;
let hours = minutes * 60;
let days = hours * 24;
let d = Math.floor((finalDate - intDate) / days);
let h = Math.floor(((finalDate - intDate) % days) / hours);
let m = Math.floor(((finalDate - intDate) % hours) / minutes);
let s = Math.floor(((finalDate - intDate) % minutes) / seconds);
d = d < 10 ? `0${d}` : d;
h = h < 10 ? `0${h}` : h;
m = m < 10 ? `0${m}` : m;
s = s < 10 ? `0${s}` : s;
$("#day").text(d);
$("#hour").text(h);
$("#minute").text(m);
$("#second").text(s);
}
setInterval(function () {
countTimer();
}, 1000);
// Discord Modal CLose *********************************************
$("div#form_modal i#modal_close").click(function () {
$("div#form_modal").removeClass("active");
});
// Notice Modal CLose *********************************************
$("section#notice_banner i#notice_close").click(function () {
$("section#notice_banner").removeClass("active");
});