-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
376 lines (331 loc) · 10.2 KB
/
script.js
File metadata and controls
376 lines (331 loc) · 10.2 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
// DOM Elements
const navToggle = document.getElementById("nav-toggle");
const navMenu = document.getElementById("nav-menu");
const navLinks = document.querySelectorAll(".nav-link");
const backToTopBtn = document.getElementById("back-to-top");
// Mobile Navigation Toggle
navToggle.addEventListener("click", () => {
navMenu.classList.toggle("active");
navToggle.classList.toggle("active");
});
// Close mobile menu when clicking on a link
navLinks.forEach((link) => {
link.addEventListener("click", () => {
navMenu.classList.remove("active");
navToggle.classList.remove("active");
});
});
// Smooth scrolling for navigation links
navLinks.forEach((link) => {
link.addEventListener("click", (e) => {
e.preventDefault();
const targetId = link.getAttribute("href");
const targetSection = document.querySelector(targetId);
if (targetSection) {
const offsetTop = targetSection.offsetTop - 70; // Account for fixed navbar
window.scrollTo({
top: offsetTop,
behavior: "smooth",
});
}
});
});
// Back to Top Button
window.addEventListener("scroll", () => {
if (window.pageYOffset > 300) {
backToTopBtn.classList.add("show");
} else {
backToTopBtn.classList.remove("show");
}
});
backToTopBtn.addEventListener("click", () => {
window.scrollTo({
top: 0,
behavior: "smooth",
});
});
// Navbar background on scroll
window.addEventListener("scroll", () => {
const navbar = document.querySelector(".navbar");
if (window.scrollY > 50) {
navbar.style.background = "rgba(255, 255, 255, 0.98)";
navbar.style.boxShadow = "0 2px 20px rgba(0, 0, 0, 0.1)";
} else {
navbar.style.background = "rgba(255, 255, 255, 0.95)";
navbar.style.boxShadow = "none";
}
});
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: "0px 0px -50px 0px",
};
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("visible");
}
});
}, observerOptions);
// Observe elements for animation
document.addEventListener("DOMContentLoaded", () => {
const animatedElements = document.querySelectorAll(
".feature-card, .screenshot-item, .advanced-feature-card"
);
animatedElements.forEach((el) => {
el.classList.add("fade-in");
observer.observe(el);
});
});
// Advanced feature card hover effects
document.addEventListener("DOMContentLoaded", () => {
const advancedFeatureCards = document.querySelectorAll(
".advanced-feature-card"
);
advancedFeatureCards.forEach((card) => {
card.addEventListener("mouseenter", function () {
this.style.transform = "translateY(-15px) scale(1.02)";
});
card.addEventListener("mouseleave", function () {
this.style.transform = "translateY(0) scale(1)";
});
});
});
// Email validation
function isValidEmail(email) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}
// Notification system
function showNotification(message, type = "info") {
// Remove existing notifications
const existingNotifications = document.querySelectorAll(".notification");
existingNotifications.forEach((notification) => notification.remove());
// Create notification element
const notification = document.createElement("div");
notification.className = `notification notification-${type}`;
notification.innerHTML = `
<div class="notification-content">
<i class="fas ${getNotificationIcon(type)}"></i>
<span>${message}</span>
<button class="notification-close">×</button>
</div>
`;
// Add styles
notification.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background: ${getNotificationColor(type)};
color: white;
padding: 16px 20px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
z-index: 10000;
max-width: 400px;
transform: translateX(100%);
transition: transform 0.3s ease;
`;
// Add to DOM
document.body.appendChild(notification);
// Animate in
setTimeout(() => {
notification.style.transform = "translateX(0)";
}, 100);
// Auto remove after 5 seconds
setTimeout(() => {
notification.style.transform = "translateX(100%)";
setTimeout(() => {
notification.remove();
}, 300);
}, 5000);
// Close button functionality
const closeBtn = notification.querySelector(".notification-close");
closeBtn.addEventListener("click", () => {
notification.style.transform = "translateX(100%)";
setTimeout(() => {
notification.remove();
}, 300);
});
}
function getNotificationIcon(type) {
switch (type) {
case "success":
return "fa-check-circle";
case "error":
return "fa-exclamation-circle";
case "warning":
return "fa-exclamation-triangle";
default:
return "fa-info-circle";
}
}
function getNotificationColor(type) {
switch (type) {
case "success":
return "linear-gradient(135deg, #4CAF50, #45a049)";
case "error":
return "linear-gradient(135deg, #f44336, #d32f2f)";
case "warning":
return "linear-gradient(135deg, #ff9800, #f57c00)";
default:
return "linear-gradient(135deg, #2196F3, #1976D2)";
}
}
// Parallax effect for hero background elements
window.addEventListener("scroll", () => {
const scrolled = window.pageYOffset;
const parallaxElements = document.querySelectorAll(".bg-circle");
parallaxElements.forEach((element, index) => {
const speed = 0.5 + index * 0.1;
const yPos = -(scrolled * speed);
element.style.transform = `translateY(${yPos}px)`;
});
});
// Counter animation for stats
function animateCounters() {
const counters = document.querySelectorAll(".stat-number");
counters.forEach((counter) => {
const target = counter.textContent;
const isNumeric = !isNaN(parseFloat(target));
if (isNumeric) {
const finalNumber = parseFloat(target);
const increment = finalNumber / 100;
let current = 0;
const timer = setInterval(() => {
current += increment;
if (current >= finalNumber) {
counter.textContent = target;
clearInterval(timer);
} else {
counter.textContent = Math.floor(current).toString();
}
}, 20);
}
});
}
// Trigger counter animation when stats section is visible
const statsObserver = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
animateCounters();
statsObserver.unobserve(entry.target);
}
});
},
{ threshold: 0.5 }
);
const heroStats = document.querySelector(".hero-stats");
if (heroStats) {
statsObserver.observe(heroStats);
}
// Lazy loading for images
const imageObserver = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
img.classList.remove("lazy");
imageObserver.unobserve(img);
}
});
});
document.addEventListener("DOMContentLoaded", () => {
const lazyImages = document.querySelectorAll("img[data-src]");
lazyImages.forEach((img) => {
imageObserver.observe(img);
});
});
// Download button click tracking
document.querySelectorAll(".download-btn").forEach((btn) => {
btn.addEventListener("click", (e) => {
// Allow the download to proceed - don't prevent default
// The app-config.js will handle the actual download
});
});
// Keyboard navigation support
document.addEventListener("keydown", (e) => {
// ESC key closes mobile menu
if (e.key === "Escape") {
navMenu.classList.remove("active");
navToggle.classList.remove("active");
}
// Enter key on download buttons
if (e.key === "Enter" && e.target.classList.contains("download-btn")) {
e.target.click();
}
});
// Performance optimization: Debounce scroll events
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Apply debouncing to scroll events
const debouncedScrollHandler = debounce(() => {
// Navbar background change
const navbar = document.querySelector(".navbar");
if (window.scrollY > 50) {
navbar.style.background = "rgba(255, 255, 255, 0.98)";
navbar.style.boxShadow = "0 2px 20px rgba(0, 0, 0, 0.1)";
} else {
navbar.style.background = "rgba(255, 255, 255, 0.95)";
navbar.style.boxShadow = "none";
}
// Back to top button
if (window.pageYOffset > 300) {
backToTopBtn.classList.add("show");
} else {
backToTopBtn.classList.remove("show");
}
}, 10);
window.addEventListener("scroll", debouncedScrollHandler);
// Initialize app when DOM is loaded
document.addEventListener("DOMContentLoaded", () => {
console.log("DESCO BD Website loaded successfully!");
// Set dynamic current year in footer
const yearEl = document.getElementById("current-year");
if (yearEl) yearEl.textContent = new Date().getFullYear();
// Add loading animation to buttons
const buttons = document.querySelectorAll(".btn");
buttons.forEach((btn) => {
btn.addEventListener("click", function () {
if (!this.classList.contains("form-submit")) {
this.style.transform = "scale(0.95)";
setTimeout(() => {
this.style.transform = "scale(1)";
}, 150);
}
});
});
// Add hover effects to cards
const cards = document.querySelectorAll(".feature-card, .screenshot-card");
cards.forEach((card) => {
card.addEventListener("mouseenter", function () {
this.style.transform = "translateY(-10px) scale(1.02)";
});
card.addEventListener("mouseleave", function () {
this.style.transform = "translateY(0) scale(1)";
});
});
});
// Service Worker registration (for PWA features)
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker
.register("/sw.js")
.then((registration) => {
// Service worker registered successfully
})
.catch((registrationError) => {
// Service worker registration failed - not critical
});
});
}