forked from rekhansh99/kanvas19Deploy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
script.js
155 lines (133 loc) · 4.38 KB
/
script.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
const Rellax = window.Rellax;
var rellax = new Rellax(".rellax", {
speed: -2,
center: true,
wrapper: null,
round: true,
vertical: true,
horizontal: false,
breakpoints: [576, 768, 1201],
});
const slack = document.querySelector(".slack");
console.log(window.scrollY);
window.addEventListener("scroll", (e) => {
if (window.scrollY > 2000) {
slack.style.display = "none";
} else {
slack.style.display = "block";
}
});
//conditional rendering event data
const gawds_button = document.querySelector("#gawds-logo");
const wd_button = document.querySelector(".wd");
const main = document.querySelector(".flex");
const WD = document.querySelector(".flex-1");
const GD = document.querySelector(".flex-2");
const SUB = document.querySelector(".flex-3");
const gd_button = document.querySelector(".gd");
// const SUB_button = document.querySelectorAll(".org-button");
const events_heading = document.querySelector(".evt");
window.scrollTo(0, 0);
// SUB_button.forEach(element => {
// element.addEventListener('click', () => {
// const form = document.querySelector('.form')
// form.reset();
// main.style.display = 'none';
// GD.style.display = 'none';
// WD.style.display = 'none';
// SUB.style.display = 'block';
// events_heading.style.display = 'none'
// if (window.screen.width * window.devicePixelRatio < 800) {
// window.scrollTo(1500, 1500);
// } else {
// window.scrollTo(1700, 1700);
// }
// })
// })
wd_button.addEventListener("click", () => {
main.style.display = "none";
WD.style.display = "block";
});
gd_button.addEventListener("click", () => {
main.style.display = "none";
GD.style.display = "block";
window.scrollTo(1700, 1700);
});
const back = () => {
main.style.display = "flex";
WD.style.display = "none";
events_heading.style.display = "block";
GD.style.display = "none";
SUB.style.display = "none";
};
// var countDownDate = new Date("Apr 22, 2020 23:59:00").getTime();
// var x = setInterval(function() {
// var now = new Date().getTime();
// var distance = countDownDate - now;
// var days = Math.floor(distance / (1000 * 60 * 60 * 24));
// var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
// var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
// var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// document.getElementById("timer").innerHTML =
// days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
// if (distance < 0) {
// clearInterval(x);
// document.getElementById("timer").innerHTML = "EXPIRED";
// }
// }, 1000);
//firebaseconfig
var firebaseConfig = {
apiKey: "AIzaSyDxZrjUTyrIJqONYJZ71_i6wIr6UKtdD6A",
authDomain: "kanvas-862ce.firebaseapp.com",
databaseURL: "https://kanvas-862ce.firebaseio.com",
projectId: "kanvas-862ce",
storageBucket: "kanvas-862ce.appspot.com",
messagingSenderId: "534176018661",
appId: "1:534176018661:web:5b40267b2a0f00c6dee40c",
measurementId: "G-J7BS9KG8YC",
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();
const db = firebase.firestore();
// form submit
const handleSubmit = () => {
const form = document.querySelector(".form");
const name = document.querySelector("#name").value;
const email = document.querySelector("#email").value;
const phone = document.querySelector("#phone").value;
const slack = document.querySelector("#slack").value;
const college = document.querySelector("#college").value;
const category = document.querySelector("#category").value;
const url = document.querySelector("#url").value;
const message = document.querySelector(".message");
if (
!phone.match(/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im)
) {
message.innerHTML = "Invalid phone number.";
return;
}
if (name && email && category && phone && college && url) {
console.log("All");
db.collection(`${category}`)
.doc()
.set({
name,
email,
slack,
phone,
college,
url,
})
.then((s) => {
console.log(s);
message.innerHTML = "Submitted";
})
.catch((e) => {
console.log(e);
message.innerHTML = "Submission failed. Please try again.";
});
} else {
message.innerHTML = "Form is not completely filled.";
}
form.reset();
};