-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
560 lines (502 loc) Β· 19.4 KB
/
script.js
File metadata and controls
560 lines (502 loc) Β· 19.4 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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
// ===================================================
// TIKAWALA PRIME - MAIN SCRIPT.JS
// Complete JavaScript for Homepage Functionality
// ===================================================
// ===== SERVICE DATABASE =====
const serviceDatabase = {
'cleaning': {
name: 'Cleaning Services',
icon: 'π§Ή',
description: 'Professional home & office cleaning',
keywords: ['clean', 'cleaning', 'house', 'home', 'office', 'deep clean', 'sanitize']
},
'deep-clean': {
name: 'Deep Home Cleaning',
icon: 'π‘',
description: 'Comprehensive cleaning for your entire home, ensuring every corner is spotless and sanitized.',
keywords: ['deep', 'home', 'thorough', 'complete', 'full house', 'intensive']
},
'commercial': {
name: 'Commercial Cleaning',
icon: 'π’',
description: 'Professional cleaning services tailored for commercial spaces, maintaining a pristine and healthy work environment.',
keywords: ['commercial', 'office', 'business', 'workplace', 'retail']
},
'empty-home': {
name: 'Empty Home Cleaning',
icon: 'π ',
description: 'Thorough cleaning for empty homes, perfect for moving in or out, leaving the space fresh and ready.',
keywords: ['empty', 'move', 'moving', 'vacant']
},
'interior-clean': {
name: 'Interior Home Cleaning',
icon: 'β¨',
description: 'Detailed interior cleaning services, focusing on all surfaces, floors, and fixtures within your home.',
keywords: ['interior', 'inside', 'home', 'surfaces']
},
'bathroom': {
name: 'Bathroom Cleaning',
icon: 'οΏ½',
description: 'Experience pristine bathroom hygiene with our specialized cleaning techniques. We tackle tough stains, sanitize surfaces, and leave your bathroom fresh and gleaming.',
keywords: ['bathroom', 'washroom', 'toilet', 'shower', 'hygiene']
},
'kitchen': {
name: 'Kitchen Cleaning',
icon: 'οΏ½',
description: 'Transform your kitchen into a spotless culinary haven. Our comprehensive deep cleaning service covers every surface, appliance, and corner to ensure a hygienic and sparkling kitchen environment.',
keywords: ['kitchen', 'appliance', 'stove', 'utensil', 'cooking']
},
'sofa': {
name: 'Sofa Cleaning',
icon: 'ποΈ',
description: 'Revitalize your sofas with our professional cleaning, removing dirt, stains, and odors for a fresh look and feel.',
keywords: ['sofa', 'couch', 'furniture', 'upholstery']
},
'carpet': {
name: 'Carpet Cleaning',
icon: 'π ',
description: 'Deep cleaning for carpets, removing embedded dirt and allergens to restore their original vibrancy and hygiene.',
keywords: ['carpet', 'rug', 'floor', 'mat']
},
'chair': {
name: 'Chair Cleaning',
icon: 'πͺ',
description: 'Expert cleaning for various types of chairs, ensuring they are spotless and comfortable.',
keywords: ['chair', 'furniture', 'seating']
},
'mattress': {
name: 'Mattress Cleaning',
icon: 'ποΈ',
description: 'Sanitize and refresh your mattresses, eliminating dust mites and allergens for a healthier sleep environment.',
keywords: ['mattress', 'bed', 'sleep', 'hygiene']
},
'balcony': {
name: 'Balcony Cleaning',
icon: 'οΏ½',
description: 'Thorough cleaning of your balcony area, including railings, floors, and windows, to make it sparkling clean.',
keywords: ['balcony', 'terrace', 'outdoor', 'patio']
},
'windows': {
name: 'Windows And Door Cleaning',
icon: 'πͺ',
description: 'Professional cleaning for all your windows and doors, ensuring streak-free glass and sparkling frames.',
keywords: ['window', 'door', 'glass', 'frame']
},
'refrigerator': {
name: 'Refrigerator Cleaning',
icon: 'ποΈ',
description: 'Deep cleaning and sanitization of your refrigerator, inside and out, removing odors and food residues.',
keywords: ['refrigerator', 'fridge', 'kitchen', 'appliance']
},
'water-tank': {
name: 'Water Tank Cleaning',
icon: 'π',
description: 'Specialized cleaning for water tanks, ensuring clean and safe water supply for your household or business.',
keywords: ['water tank', 'tank', 'water', 'supply']
},
'bedroom': {
name: 'Bedroom Cleaning',
icon: 'οΏ½οΈ',
description: 'Comprehensive cleaning for bedrooms, including dusting, vacuuming, and tidying, for a serene sleeping space.',
keywords: ['bedroom', 'room', 'bed', 'sleep']
},
'hotel': {
name: 'Hotel Interior Cleaning',
icon: 'π¨',
description: 'High-standard interior cleaning services for hotels, ensuring guest satisfaction and a pristine environment.',
keywords: ['hotel', 'resort', 'hospitality', 'guest']
},
'microwave': {
name: 'Microwave Cleaning',
icon: 'π',
description: 'Thorough cleaning of your microwave oven, removing food splatters and odors for hygienic cooking.',
keywords: ['microwave', 'oven', 'kitchen', 'appliance']
},
'cabinet': {
name: 'Cabinet Cleaning',
icon: 'πͺ',
description: 'Detailed cleaning of kitchen and other cabinets, inside and out, for an organized and clean storage space.',
keywords: ['cabinet', 'storage', 'kitchen', 'organization']
},
'party': {
name: 'Party Cleaning',
icon: 'π',
description: 'Post-party cleanup services to take care of all the mess, leaving your space neat and tidy.',
keywords: ['party', 'event', 'cleanup', 'after']
},
'office': {
name: 'Office Cleaning',
icon: 'π’',
description: 'Reliable and efficient office cleaning services to maintain a clean, healthy, and productive workspace.',
keywords: ['office', 'workspace', 'work', 'professional']
},
'villa': {
name: 'Villa Cleaning',
icon: 'π ',
description: 'Exclusive cleaning services for villas, ensuring every part of your spacious home is impeccably clean.',
keywords: ['villa', 'mansion', 'large home', 'luxury']
},
'landscape': {
name: 'Landscape & Turf',
icon: 'πΏ',
description: 'Lawn care, trimming, and turf upkeep for beautiful outdoor spaces.',
keywords: ['landscape', 'lawn', 'garden', 'outdoor', 'turf', 'green']
}
};
// ===== DOM ELEMENTS =====
const mobileMenuBtn = document.getElementById('mobileMenuBtn');
const mobileNav = document.getElementById('mobileNav');
const menuIcon = document.getElementById('menuIcon');
const searchInput = document.getElementById('searchInput');
const searchBtn = document.getElementById('searchBtn');
const searchSuggestions = document.getElementById('searchSuggestions');
const suggestionsList = document.getElementById('suggestionsList');
const clearSearch = document.getElementById('clearSearch');
// ===== STATE MANAGEMENT =====
let mobileMenuOpen = false;
let activeDropdown = null;
let activeMobileDropdown = null;
// ===== SERVICE NAVIGATION FUNCTION =====
function openService(serviceName) {
// Navigate to service page with service name as parameter
window.location.href = `service.html?service=${encodeURIComponent(serviceName)}`;
}
// Make function globally accessible
window.openService = openService;
// ===== QUICK SEARCH FUNCTION =====
function quickSearch(serviceType) {
const service = serviceDatabase[serviceType];
if (service) {
openService(service.name);
}
}
// Make function globally accessible
window.quickSearch = quickSearch;
// ===== SEARCH INPUT HANDLING =====
if (searchInput && clearSearch) {
searchInput.addEventListener('input', (e) => {
const value = e.target.value.trim();
if (value) {
clearSearch.style.display = 'flex';
showSuggestions(value);
} else {
clearSearch.style.display = 'none';
hideSuggestions();
}
});
// Clear search button
clearSearch.addEventListener('click', () => {
searchInput.value = '';
clearSearch.style.display = 'none';
hideSuggestions();
searchInput.focus();
});
}
// ===== SEARCH BUTTON CLICK =====
if (searchBtn && searchInput) {
searchBtn.addEventListener('click', (e) => {
e.preventDefault();
performSearch();
});
// Enter key to search
searchInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
e.preventDefault();
performSearch();
}
});
}
// ===== SEARCH SUGGESTIONS =====
function showSuggestions(query) {
if (!query || query.length < 2) {
hideSuggestions();
return;
}
const matches = findMatches(query.toLowerCase());
if (matches.length === 0) {
hideSuggestions();
return;
}
// Clear previous suggestions
suggestionsList.innerHTML = '';
// Add matched services
matches.forEach(match => {
const item = document.createElement('div');
item.className = 'suggestion-item';
item.innerHTML = `
<div class="suggestion-icon">${match.icon}</div>
<div class="suggestion-content">
<div class="suggestion-title">${highlightMatch(match.name, query)}</div>
<div class="suggestion-description">${match.description}</div>
</div>
`;
// Click handler
item.addEventListener('click', () => {
searchInput.value = match.name;
hideSuggestions();
openService(match.name);
});
suggestionsList.appendChild(item);
});
searchSuggestions.style.display = 'block';
}
function hideSuggestions() {
if (searchSuggestions) {
searchSuggestions.style.display = 'none';
}
}
function findMatches(query) {
const matches = [];
for (const [key, service] of Object.entries(serviceDatabase)) {
const nameMatch = service.name.toLowerCase().includes(query);
const keywordMatch = service.keywords.some(keyword =>
keyword.toLowerCase().includes(query) || query.includes(keyword.toLowerCase())
);
if (nameMatch || keywordMatch) {
matches.push(service);
}
}
// Remove duplicates and limit to 5 results
return matches.slice(0, 5);
}
function highlightMatch(text, query) {
const regex = new RegExp(`(${query})`, 'gi');
return text.replace(regex, '<span style="font-weight: 700; color: var(--secondary);">$1</span>');
}
// ===== PERFORM SEARCH =====
function performSearch() {
const query = searchInput.value.trim().toLowerCase();
if (!query) {
// Show error animation
searchInput.style.border = '2px solid #f44336';
searchInput.placeholder = 'Please enter a service name';
setTimeout(() => {
searchInput.style.border = '';
searchInput.placeholder = 'Search services (Cleaning, Pest Control, Painting...)';
}, 2000);
return;
}
// Show loading state
const originalHTML = searchBtn.innerHTML;
searchBtn.disabled = true;
searchBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i><span>Searching...</span>';
// Simulate search (in real app, this would be an API call)
setTimeout(() => {
const matches = findMatches(query);
searchBtn.disabled = false;
searchBtn.innerHTML = originalHTML;
if (matches.length > 0) {
// Navigate to first match
openService(matches[0].name);
} else {
// No results found
alert(`We couldn't find "${query}" in Bokaro.\n\nAvailable services:\nβ’ Cleaning\nβ’ Pest Control\nβ’ Painting\nβ’ Salon & Spa`);
}
}, 500);
}
// ===== MOBILE MENU TOGGLE =====
if (mobileMenuBtn) {
mobileMenuBtn.addEventListener('click', () => {
mobileMenuOpen = !mobileMenuOpen;
if (mobileMenuOpen) {
mobileNav.classList.add('active');
menuIcon.className = 'fas fa-times';
document.body.style.overflow = 'hidden'; // Prevent scroll
} else {
mobileNav.classList.remove('active');
menuIcon.className = 'fas fa-bars';
document.body.style.overflow = '';
closeMobileDropdowns();
}
});
}
// ===== DESKTOP DROPDOWN NAVIGATION =====
document.querySelectorAll('.nav-item.dropdown').forEach(item => {
const dropdown = item.querySelector('.dropdown-menu');
if (dropdown) {
// Mouse enter
item.addEventListener('mouseenter', () => {
closeAllDropdowns();
activeDropdown = dropdown;
dropdown.style.opacity = '1';
dropdown.style.visibility = 'visible';
dropdown.style.transform = 'translateY(0)';
});
// Mouse leave
item.addEventListener('mouseleave', () => {
activeDropdown = null;
dropdown.style.opacity = '0';
dropdown.style.visibility = 'hidden';
dropdown.style.transform = 'translateY(-10px)';
});
}
});
// ===== MOBILE NAVIGATION DROPDOWNS =====
document.querySelectorAll('.mobile-nav-btn').forEach(btn => {
btn.addEventListener('click', () => {
const targetId = btn.getAttribute('data-target');
const dropdown = document.getElementById(targetId);
const icon = btn.querySelector('i.fa-chevron-down');
if (dropdown) {
// Close other dropdowns
if (activeMobileDropdown && activeMobileDropdown !== dropdown) {
activeMobileDropdown.classList.remove('active');
const prevIcon = activeMobileDropdown.parentElement.querySelector('.mobile-nav-btn i.fa-chevron-down');
if (prevIcon) prevIcon.style.transform = '';
}
// Toggle current dropdown
if (dropdown.classList.contains('active')) {
dropdown.classList.remove('active');
if (icon) icon.style.transform = '';
activeMobileDropdown = null;
} else {
dropdown.classList.add('active');
if (icon) icon.style.transform = 'rotate(180deg)';
activeMobileDropdown = dropdown;
}
}
});
});
// ===== FOOTER ACCORDION (Mobile) =====
document.querySelectorAll('.accordion-btn').forEach(btn => {
btn.addEventListener('click', () => {
const targetId = btn.getAttribute('data-target');
const content = document.getElementById(targetId);
const icon = btn.querySelector('i.fa-chevron-down');
if (content) {
const isActive = content.classList.contains('active');
// Close all accordions
document.querySelectorAll('.accordion-content.active').forEach(activeContent => {
activeContent.classList.remove('active');
const activeBtn = activeContent.parentElement.querySelector('.accordion-btn');
const activeIcon = activeBtn?.querySelector('i.fa-chevron-down');
if (activeIcon) activeIcon.style.transform = '';
});
// Open clicked accordion if it wasn't open
if (!isActive) {
content.classList.add('active');
if (icon) icon.style.transform = 'rotate(180deg)';
}
}
});
});
// ===== UTILITY FUNCTIONS =====
function closeAllDropdowns() {
document.querySelectorAll('.dropdown-menu').forEach(dropdown => {
dropdown.style.opacity = '0';
dropdown.style.visibility = 'hidden';
dropdown.style.transform = 'translateY(-10px)';
});
}
function closeMobileDropdowns() {
document.querySelectorAll('.mobile-dropdown.active').forEach(dropdown => {
dropdown.classList.remove('active');
const btn = dropdown.parentElement.querySelector('.mobile-nav-btn');
const icon = btn?.querySelector('i.fa-chevron-down');
if (icon) icon.style.transform = '';
});
activeMobileDropdown = null;
}
// ===== CLOSE ELEMENTS ON OUTSIDE CLICK =====
document.addEventListener('click', (e) => {
// Close mobile menu
if (mobileMenuOpen &&
!mobileNav?.contains(e.target) &&
!mobileMenuBtn?.contains(e.target)) {
mobileMenuOpen = false;
mobileNav.classList.remove('active');
menuIcon.className = 'fas fa-bars';
document.body.style.overflow = '';
closeMobileDropdowns();
}
// Close search suggestions
if (!searchSuggestions?.contains(e.target) &&
!searchInput?.contains(e.target)) {
hideSuggestions();
}
});
// ===== SMOOTH SCROLL FOR ANCHOR LINKS =====
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
const href = this.getAttribute('href');
if (href !== '#') {
e.preventDefault();
const target = document.querySelector(href);
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
});
});
// ===== HANDLE WINDOW RESIZE =====
let resizeTimer;
window.addEventListener('resize', () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
// Close mobile menu on desktop view
if (window.innerWidth >= 1024 && mobileMenuOpen) {
mobileMenuOpen = false;
mobileNav?.classList.remove('active');
if (menuIcon) menuIcon.className = 'fas fa-bars';
document.body.style.overflow = '';
closeMobileDropdowns();
}
}, 250);
});
// ===== KEYBOARD ACCESSIBILITY =====
document.addEventListener('keydown', (e) => {
// Escape key closes mobile menu and suggestions
if (e.key === 'Escape') {
if (mobileMenuOpen) {
mobileMenuOpen = false;
mobileNav?.classList.remove('active');
if (menuIcon) menuIcon.className = 'fas fa-bars';
document.body.style.overflow = '';
closeMobileDropdowns();
}
hideSuggestions();
}
});
// ===== SERVICE ITEM CLICKS =====
document.querySelectorAll('.service-item').forEach(item => {
// Add keyboard support
item.setAttribute('tabindex', '0');
item.setAttribute('role', 'button');
item.addEventListener('keypress', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
item.click();
}
});
});
// ===== INITIALIZATION =====
document.addEventListener('DOMContentLoaded', () => {
console.log('π Tikawala Prime - Bokaro Home Services Platform Loaded');
console.log('π Location: Bokaro, Jharkhand');
console.log('π WhatsApp: 8789772081');
// Add any initialization code here
// For example: Load user preferences, check location, etc.
});
// ===== ANALYTICS TRACKING (Optional) =====
function trackEvent(eventName, data) {
console.log(`π Event: ${eventName}`, data);
// Integrate with Google Analytics, Facebook Pixel, etc.
// Example: gtag('event', eventName, data);
}
// Track page view
trackEvent('page_view', {
page: 'homepage',
location: 'Bokaro',
timestamp: new Date().toISOString()
});
// ===== EXPORT FOR EXTERNAL USE =====
window.TikawalaServices = {
openService,
quickSearch,
trackEvent,
serviceDatabase
};
// ===== END OF SCRIPT.JS =====