-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
175 lines (151 loc) · 6.02 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
document.addEventListener('DOMContentLoaded', function() {
// Matrix effect
const canvas = document.getElementById('matrix-canvas');
if (canvas) {
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const binary = '0101010101010101010100000000111111';
const latin = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const nums = '0123456789';
const arabic = 'ا ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه و ي'
const alphabet = binary + latin + nums + arabic;
const fontSize = 16;
const columns = canvas.width/fontSize;
const rainDrops = [];
for( let x = 0; x < columns; x++ ) {
rainDrops[x] = 1;
}
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#0F0';
ctx.font = fontSize + 'px monospace';
for(let i = 0; i < rainDrops.length; i++) {
const text = alphabet.charAt(Math.floor(Math.random() * alphabet.length));
ctx.fillText(text, i*fontSize, rainDrops[i]*fontSize);
if(rainDrops[i]*fontSize > canvas.height && Math.random() > 0.975){
rainDrops[i] = 0;
}
rainDrops[i]++;
}
}
setInterval(draw, 30);
}
// Typing effect
const typingText = document.getElementById("typing-text");
if (typingText) {
const textToType = "Hi, I'm MOHAMMED UVEZ KHAN";
let i = 0;
function typeWriter() {
if (i < textToType.length) {
typingText.innerHTML += textToType.charAt(i);
i++;
setTimeout(typeWriter, 100);
}
}
typeWriter();
}
// Smooth scrolling
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Back to top button
const backToTopButton = document.getElementById('back-to-top');
if (backToTopButton) {
window.addEventListener('scroll', () => {
if (window.pageYOffset > 300) {
backToTopButton.classList.add('active');
} else {
backToTopButton.classList.remove('active');
}
});
backToTopButton.addEventListener('click', (e) => {
e.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
// Load skills
function loadSkills() {
const skills = [
{ name: "Python", logo: "Images/python.png" },
{ name: "Java", logo: "Images/java.png" },
{ name: "C", logo: "Images/c.png" },
{ name: "Flask", logo: "Images/flask.png" },
{ name: "GitHub", logo: "Images/github.png" },
{ name: "VS Code", logo: "Images/vscode.png" },
{ name: "OpenCV", logo: "Images/opencv.png" },
{ name: "HTML", logo: "Images/html.png" },
{ name: "CSS", logo: "Images/css.png" },
{ name: "JavaScript", logo: "Images/js.png" }
];
const container = document.querySelector('.skills-grid');
if (container) {
skills.forEach(skill => {
const skillElement = document.createElement('div');
skillElement.classList.add('skill');
skillElement.innerHTML = `
<img src="${skill.logo}" alt="${skill.name}" class="skill-logo">
<span class="skill-name">${skill.name}</span>
`;
container.appendChild(skillElement);
});
}
}
loadSkills();
// Contact form functionality
const contactForm = document.getElementById('contact-form');
const formStatus = document.getElementById('form-status');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
// Disable submit button and show loading state
const submitButton = contactForm.querySelector('button[type="submit"]');
submitButton.disabled = true;
submitButton.textContent = 'Sending...';
// Send form data to server
fetch('/submit-form', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ name, email, message }),
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log('Success:', data);
// Clear the form
contactForm.reset();
// Show a success message
formStatus.textContent = 'Thank you for your message! I will get back to you soon.';
formStatus.style.color = 'green';
})
.catch((error) => {
console.error('Error:', error);
formStatus.textContent = 'There was an error submitting your message. Please try again later.';
formStatus.style.color = 'red';
})
.finally(() => {
// Re-enable submit button and restore original text
submitButton.disabled = false;
submitButton.textContent = 'Send Message';
});
});
}
});