-
-
Notifications
You must be signed in to change notification settings - Fork 73
/
index.js
175 lines (159 loc) · 5.65 KB
/
index.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
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
function darkMode() {
document.body.classList.toggle("dark");
// Added if/else condiditon to change the color of past event heading, faq heading and header wave
if (
(document.getElementById("p-heading").style.color === "white" &&
document.getElementById("f-heading").style.color === "white") ||
document.getElementById("h-wave").style.fill === "#292c35"
) {
document.getElementById("p-heading").style.color = "black";
document.getElementById("f-heading").style.color = "black";
document.getElementById("achievement-heading").style.color = "black";
document.getElementById("h-wave").style.fill = "#ffffff";
document.getElementById("h1-aboutus-section-1").style.color = "black";
document.getElementById("p-aboutus-section-1").style.color = "black";
document.getElementById("h1-aboutus-section-2").style.color = "black";
document.getElementById("p-aboutus-section-2").style.color = "black";
document.querySelector(".big-circle").style.setProperty("---primary-contactus-circle-after-bg", "white");
const cardList = document.querySelectorAll(".card");
for(const element of cardList){
element.style.backgroundColor = "white";
element.style.color = "black";
element.style.borderTop = "2px solid black";
element.style.borderRight = "2px solid black";
}
} else {
document.getElementById("p-heading").style.color = "white";
document.getElementById("f-heading").style.color = "white";
document.getElementById("achievement-heading").style.color = "white";
document.getElementById("h-wave").style.fill = "#242425";
document.getElementById("h1-aboutus-section-1").style.color = "white";
document.getElementById("p-aboutus-section-1").style.color = "white";
document.getElementById("h1-aboutus-section-2").style.color = "white";
document.getElementById("p-aboutus-section-2").style.color = "white";
document.querySelector(".big-circle").style.setProperty("---primary-contactus-circle-after-bg", "#212529");
const cardList = document.querySelectorAll(".card");
for(const element of cardList){
element.style.backgroundColor = "black";
element.style.color = "white";
element.style.borderTop = "2px solid white";
element.style.borderRight = "2px solid white";
}
}
const toggleButton = document.getElementById("dark-mode-enable");
if(toggleButton.classList.contains("fa-moon")){
toggleButton.classList.remove("fa-moon");
toggleButton.classList.add("fa-lightbulb");
}
else{
toggleButton.classList.remove("fa-lightbulb");
toggleButton.classList.add("fa-moon");
}
}
const toggles = document.querySelectorAll(".faq-toggle");
toggles.forEach((toggle) => {
toggle.addEventListener("click", () => {
toggle.parentNode.classList.toggle("active");
});
});
//Cursor
const cursor = document.querySelector(".cursor");
document.addEventListener("mousemove", (e) => {
cursor.setAttribute("style", "top: " + (e.pageY - 10) + "px; left: " + (e.pageX - 10) + "px;");
});
document.addEventListener("click", () => {
cursor.classList.add("expand");
setTimeout(() => {
cursor.classList.remove("expand");
}, 500);
});
//Scroll-to -top
let mybutton = document.getElementById("myBtn");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
//Contact-Us-Send-Buttom
function sendMail() {
var link = "mailto:[email protected]"
+ "?subject=" + encodeURIComponent("Contact Us: From " + document.getElementById('contactName').value)
+ encodeURIComponent(" <" + document.getElementById('contactEmail').value + ">")
+ "&body=" + encodeURIComponent(document.getElementById('contactText').value);
window.location.href = link;
}
async function postFormDataAsJson({ url, formData }) {
const plainFormData = Object.fromEntries(formData.entries());
const formDataJsonString = JSON.stringify(plainFormData);
//console.log(formDataJsonString);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: formDataJsonString,
mode: "cors",
});
if (!response.ok) {
const errorMessage = await response.text();
throw new Error(errorMessage);
}
return response.json();
}
async function handleFormSubmit() {
const username = prompt("Enter your Discord username");
//console.log(username);
const form = document.getElementById("discord-form");
//console.log(form);
try {
const formData = new FormData(form);
formData.append("Discord", username);
//console.log(formData);
const url = "http://localhost:3000/cweb/contactus";
const responseData = await postFormDataAsJson({ url, formData });
} catch (err) {
console.log(err);
}
}
// for Swiper used in past events
var swiper = new Swiper(".past-events-slide-content", {
slidesPerView: 3,
spaceBetween: 30,
slidesPerGroup: 1,
loop: true,
centerSlide: true,
fade: true,
grabCursor: true,
pagination: {
el: ".swiper-pagination",
clickable: true,
dynamicBullets: true,
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
// for Typed JS functionality
var typed = new Typed('.typed-animation', {
strings: [
'Education',
'Learning',
'Awareness',
'Opportunity',
'Awesomeness'
],
typeSpeed: 100,
backSpeed: 75,
loop: true,
loopCount: Infinity,
// smartBackspace: true,
});