-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
61 lines (50 loc) · 1.63 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
/*=============== SHOW MENU ===============*/
const showMenu = (toggleId, navId) =>{
const toggle = document.getElementById(toggleId),
nav = document.getElementById(navId)
// Validate that variables exist
if(toggle && nav){
toggle.addEventListener('click', ()=>{
// We add the show-menu class to the div tag with the nav__menu class
nav.classList.toggle('show-menu')
})
}
}
showMenu('nav-toggle','nav-menu')
/*=============== REMOVE MENU MOBILE ===============*/
const navLink = document.querySelectorAll('.nav__link')
function linkAction(){
const navMenu = document.getElementById('nav-menu')
// When we click on each nav__link, we remove the show-menu class
navMenu.classList.remove('show-menu')
}
navLink.forEach(n => n.addEventListener('click', linkAction))
const scriptURL = 'https://script.google.com/macros/s/AKfycbywuLlAWki6S53SICEcFAUK328pHGTzV7aJ-PLT_dUdrejOKk8w022eeG98fkuKURz1ug/exec'
const form = document.forms['submit-to-google-sheet']
window.addEventListener("load", function() {
const form = document.getElementById('my-form');
form.addEventListener("submit", function(e) {
e.preventDefault();
const data = new FormData(form);
const action = e.target.action;
fetch(action, {
method: 'POST',
body: data,
})
.then(() => {
alert("Success!");
})
});
});
function myFunction() {
var x = document.getElementById("nav-menu");
if (x.className === "nav__menu") {
x.className += " show-menu";
} else {
x.className = "nav__menu";
}
}
AOS.init({
offset: 50,
duration: 800
});