-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
109 lines (94 loc) · 3.91 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
var tablinks = document.getElementsByClassName("tab-links");
var tabcontents = document.getElementsByClassName("tab-contents");
function opentab(tabname) {
for (let tablink of tablinks) {
tablink.classList.remove("active-link");
}
for (let tabcontent of tabcontents) {
tabcontent.classList.remove("active-tab");
}
event.currentTarget.classList.add("active-link");
document.getElementById(tabname).classList.add("active-tab"); x
}
var sidemeu = document.getElementById("sidemenu");
function openmenu() {
sidemeu.style.right = "0";
} function closemenu() {
sidemeu.style.right = "-200px";
}
const scriptURL = 'https://script.google.com/macros/s/AKfycbwxN4hgvCZonBz7maRlCT4dgttcMqx5KhTVYjXKJmWlgM7KyufVrNv0S9e0VqMimhu9/exec'
const form = document.forms['submit-to-google-sheet']
const msg = document.getElementById("msg");
form.addEventListener('submit', e => {
e.preventDefault()
fetch(scriptURL, { method: 'POST', body: new FormData(form) })
.then(response => {
msg.innerHTML = "Message sent successfully."
setTimeout(function () {
msg.innerHTML = ""
}, 5000)
form.reset()
})
.catch(error => console.error('Error!', error.message))
})
// function smoothScroll(targetId) {
// const targetElement = document.getElementById(targetId);
// targetElement.scrollIntoView({ behavior: 'smooth' });
// }
// // Attach smooth scrolling to links or buttons
// document.getElementById('d1').addEventListener('click', function() {
// smoothScroll('header');
// });
// document.getElementById('d2').addEventListener('click', function() {
// smoothScroll('about');
// });
// document.getElementById('d3').addEventListener('click', function() {
// smoothScroll('portfolio');
// });
// document.getElementById('d4').addEventListener('click', function() {
// smoothScroll('contact');
// });
// Smoodh scrolling animation
document.addEventListener('DOMContentLoaded', function() {
const allLinks = document.querySelectorAll("nav ul li a");
allLinks.forEach(target => {
target.onclick = function(e) {
e.preventDefault();
let hrefValue = target.getAttribute('href');
let targetElement = document.querySelector(hrefValue);
if (targetElement) {
console.log(targetElement);
let offsetTop = targetElement.offsetTop;
window.scroll({
top: offsetTop,
behavior: "smooth"
});
}
};
});
});
// document.addEventListener('DOMContentLoaded', function() {
// // Get all links with the class 'smooth-scroll'
// var smoothScrollLinks = document.querySelectorAll('nav ul li a');
// console.log(smoothScrollLinks);
// // Loop through each link and add a click event listener
// smoothScrollLinks.forEach(function(link) {
// link.addEventListener('click', function(e) {
// e.preventDefault(); // Prevent the default behavior of the anchor tag
// // Get the target element's ID from the href attribute
// var targetId = this.getAttribute('href').substring(1);
// var targetElement = document.getElementById(targetId);
// // Scroll to the target element smoothly
// if (targetElement) {
// targetElement.classList.add('smooth-scroll');
// targetElement.scrollIntoView({
// behavior: "smooth",
// });
// // Remove smooth-scroll class after the animation is complete
// setTimeout(() => {
// targetElement.classList.remove('smooth-scroll');
// }, 500); // Adjust the timeout value to match the transition duration
// }
// });
// });
// });