-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
181 lines (128 loc) · 4.82 KB
/
script.js
File metadata and controls
181 lines (128 loc) · 4.82 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
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
175
176
177
178
179
180
181
let menuIcon = document.querySelector('#menu-icon');
let navbar = document.querySelector('.navbar');
menuIcon.onclick = () => {
menuIcon.classList.toggle('bx-x');
navbar.classList.toggle('active');
};
const firebaseConfig = {
apiKey: "AIzaSyCQsm0OkhOvI0COdLHbEb2JNWHMUJZq7Kk",
authDomain: "portfoliocontact-8e0e8.firebaseapp.com",
databaseURL: "https://portfoliocontact-8e0e8-default-rtdb.asia-southeast1.firebasedatabase.app",
projectId: "portfoliocontact-8e0e8",
storageBucket: "portfoliocontact-8e0e8.appspot.com",
messagingSenderId: "307110053762",
appId: "1:307110053762:web:6c41177e6fae7832c4719b",
measurementId: "G-SP6NSYE1YK"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const database = firebase.database();
const ref = database.ref('Messages');
const form = document.getElementById('contactForm');
form.addEventListener('submit', function (e) {
e.preventDefault();
// Get form data
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const mob = document.getElementById('mobile').value;
const sub = document.getElementById('emailSub').value;
const desc = document.getElementById('desc').value;
// Save data to Firestore
ref.push({
name: name,
email: email,
mobile: mob,
subject: sub,
description: desc
}).then(() => {
// Display alert
// Show custom alert
var customAlert = document.getElementById('customAlertSuccess');
customAlert.style.display = 'block';
// Set a timer to hide the custom alert after 5 seconds
setTimeout(function () {
// Code to hide the custom alert
customAlert.style.display = 'none';
}, 5000);
})
.catch((error) => {
var customAlert = document.getElementById('customAlertFailed');
customAlert.style.display = 'block';
// Set a timer to hide the custom alert after 5 seconds
setTimeout(function () {
// Code to hide the custom alert
customAlert.style.display = 'none';
}, 5000);
});;
// Optionally, you can reset the form
form.reset();
});
let sections = document.querySelectorAll('section');
let navLinks = document.querySelectorAll('header nav a');
window.onscroll = () => {
sections.forEach(sec => {
let top = window.scrollY;
let offset = sec.offsetTop - 150;
let height = sec.offsetHeight;
let id = sec.getAttribute('id');
if (top >= offset && top < offset + height) {
navLinks.forEach(links => {
links.classList.remove('active');
document.querySelector('header nav a[href*=' + id + ']').classList.add('active');
})
};
});
let header = document.querySelector('header');
header.classList.toggle('sticky', window.scrollY > 100);
menuIcon.classList.remove('bx-x');
navbar.classList.remove('active');
};
ScrollReveal({ reset: false, distance: '80px', duration: 2000, delay: 200 });
ScrollReveal().reveal('.home-content, .heading', { origin: 'top' });
ScrollReveal().reveal('.home-img, .services-container,.portfolio-box,.contact form', { origin: 'bottom' });
ScrollReveal().reveal('.home-content h1, .about-img', { origin: 'left' });
ScrollReveal().reveal('.home-content p, .about-content', { origin: 'right' });
const typed = new Typed('.multiple-text', {
strings: ['Web Developer', 'UI/UX Designer', 'Graphic Designer'],
typeSpeed: 100,
backSpeed: 100,
backDelay: 1000,
loop: true,
});
function openModal() {
document.getElementById('myModal').style.display = 'block';
}
// Close the modal
function closeModal() {
document.getElementById('myModal').style.display = 'none';
}
function openModal1() {
document.getElementById('myModal1').style.display = 'block';
}
// Close the modal
function closeModal1() {
document.getElementById('myModal1').style.display = 'none';
}
function openModal2() {
document.getElementById('myModal2').style.display = 'block';
}
// Close the modal
function closeModal2() {
document.getElementById('myModal2').style.display = 'none';
}
function openser1() {
console.log('open modal');
document.getElementById('ser1').style.display = 'block';
}
// Close the modal
function closeser1() {
document.getElementById('ser1').style.display = 'none';
}
function openser2() {
console.log('open modal');
document.getElementById('ser2').style.display = 'block';
}
// Close the modal
function closeser2() {
document.getElementById('ser2').style.display = 'none';
}