Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
129 lines (104 loc) · 3.58 KB
/
Copy pathmain.js
File metadata and controls
129 lines (104 loc) · 3.58 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
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
document.addEventListener('DOMContentLoaded', function() {
const textElement = document.getElementById('typing');
const words = ["Web Developer", "Programmer", "Student"];
let wordIndex = 0;
let charIndex = 0;
let isDeleting = false;
let typingSpeed = 150;
let pauseBetweenWords = 2000;
function type() {
const currentWord = words[wordIndex];
const displayText = isDeleting ?
currentWord.substring(0, charIndex - 1) :
currentWord.substring(0, charIndex + 1);
textElement.textContent = `I am a ${displayText}`;
if (!isDeleting) {
charIndex++;
if (charIndex === currentWord.length) {
isDeleting = true;
setTimeout(type, pauseBetweenWords);
return;
}
} else {
charIndex--;
if (charIndex === 0) {
isDeleting = false;
wordIndex = (wordIndex + 1) % words.length;
}
}
setTimeout(type, isDeleting ? typingSpeed / 2 : typingSpeed);
}
type();
});
// document.addEventListener('scroll', function() {
// const scrolledHeight = document.documentElement.scrollTop || document.body.scrollTop;
// const maxHeight = (document.documentElement.scrollHeight - window.innerHeight)*0.3;
// const scrollFraction = scrolledHeight / maxHeight;
// // Calculate a new color based on the scroll fraction
// const red = Math.min(29, 29 * (scrollFraction));
// const green = Math.min(35, 35 * (scrollFraction));
// const blue = Math.min(42, 42 * (scrollFraction));
// const newColor = `rgb(${red}, ${green}, ${blue})`;
// const colorChangeDiv = document.getElementById('about');
// colorChangeDiv.style.backgroundColor = newColor;
// });
document.addEventListener('DOMContentLoaded', function() {
const cards = document.querySelectorAll('.card');
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
else{
entry.target.classList.remove('visible');
}
});
}, {
threshold: 0.1
});
cards.forEach(card => {
observer.observe(card);
});
});
document.addEventListener('DOMContentLoaded', function() {
const heartBeatImage = document.getElementById('heartBeat');
let x = 50;
let up=1;
function updateBoxShadow() {
heartBeatImage.style.boxShadow = `0 0 ${x}px #00a1ff`;
if(x==300){up=0;}
if(x==100){up=1;}
if(up)
x++;
else
x--;
setTimeout(updateBoxShadow,3);
}
// Start the loop
updateBoxShadow();
})
// Add event listener to the form
// document.getElementById('dataForm').addEventListener('submit', (event)=> {
// event.preventDefault(); // Prevent the default form submission
// // Get form data
// const formData = new FormData(event.target);
// const data = Object.fromEntries(formData.entries());
// // Call the post method with form data
// console.log('Form Data:', data);
// });
function validateForm() {
// Check that all required fields are filled in
if (document.getElementById("name").value == "") {
alert("Please enter your name");
return false;
}
// Check that the email address is in a valid format
var email = document.getElementById("email").value;
var regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!regex.test(email)) {
alert("Please enter a valid email address");
return false;
}
// Submit the form if all validation checks pass
return true;
}