-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
96 lines (83 loc) · 3.36 KB
/
Copy pathscript.js
File metadata and controls
96 lines (83 loc) · 3.36 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
const form = document.querySelector("#form")
const input = document.querySelector("#email")
const submitButton = document.querySelector("#submit")
const scriptURL = 'https://script.google.com/macros/s/AKfycbxzKPZET7DIsqWAQLohCNeGHPHOEfI57Ea-NVp3AkXKTNJ3s9Nz8ZNh3a4aFQkvkrlc/exec'
const width = document.body.clientWidth;
const mobile = 600
// Script to collect email list
form.addEventListener('submit', e => {
const inputValue = input.value
submitButton.disabled = true
submitButton.innerHTML = "Submitting..."
e.preventDefault()
if(!inputValue.endsWith("galgotiacollege.edu")){
submitButton.disabled = false
if(width<mobile){
Toastify({
text: "Please use only your college email ID",
duration: 3000,
gravity: "bottom",
className: "toastify-center",
style: {
background: "linear-gradient(to right, #4D041B, #940432)",
},
}).showToast();
}
else{
Toastify({
text: "Please use only your college email ID",
duration: 3000,
gravity: "bottom",
style: {
background: "linear-gradient(to right, #4D041B, #940432)",
},
}).showToast();
}
submitButton.innerHTML = `
Get notified about the launch
<svg width="18" height="15" viewBox="0 0 18 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 7.5L17 7.5M17 7.5L11 14M17 7.5L11 0.999999" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`
form.reset();
return;
}
let requestBody = new FormData(form)
fetch(scriptURL, { method: 'POST', body: requestBody})
.then(response => {
submitButton.innerHTML = `
Get notified about the launch
<svg width="18" height="15" viewBox="0 0 18 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 7.5L17 7.5M17 7.5L11 14M17 7.5L11 0.999999" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`
if(width<mobile){
Toastify({
text: "Congrats! You will be notified soon!",
duration: 3000,
className: "toastify-center",
gravity: "bottom",
style: {
background: "linear-gradient(to right, #00b09b, #96c93d)",
},
}).showToast();
}
else{
Toastify({
text: "Congrats! You will be notified soon!",
duration: 3000,
gravity: "bottom",
style: {
background: "linear-gradient(to right, #00b09b, #96c93d)",
},
}).showToast();
}
submitButton.disabled = false
form.reset();
})
.catch(error => {
alert('Error!', error.message)
submitButton.disabled = false
form.reset();
})
})