-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.js
More file actions
466 lines (435 loc) · 17.1 KB
/
Copy pathsearch.js
File metadata and controls
466 lines (435 loc) · 17.1 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
// ========== GET ALL ELEMENTS ==========
const searchBtn = document.getElementById('searchBtn');
const searchClose = document.getElementById('searchClose');
const searchInput = document.getElementById('searchInput');
const nav = document.querySelector('nav');
// ========== SEARCH DATABASE ==========
const searchDatabase = [
// PAGES
{
id: 1,
title: "Home - Uyeh Tech",
url: "index.html",
category: "Page",
description: "Welcome to Uyeh Tech. Full Stack Developer creating modern websites and applications.",
keywords: ["home", "welcome", "portfolio", "developer", "bassey okon", "uyeh tech"]
},
{
id: 2,
title: "About - Bassey Okon",
url: "about.html",
category: "Page",
description: "Learn more about Bassey Okon, a passionate Full Stack Developer from Nigeria with 5+ years experience.",
keywords: ["about", "biography", "skills", "experience", "education", "bassey", "okon", "developer"]
},
{
id: 3,
title: "Services & Pricing",
url: "services.html",
category: "Page",
description: "Web development, mobile apps, UI/UX design, e-commerce, and maintenance services with transparent pricing.",
keywords: ["services", "pricing", "web development", "mobile apps", "ui ux design", "ecommerce", "maintenance", "seo"]
},
{
id: 4,
title: "Projects Portfolio",
url: "projects.html",
category: "Page",
description: "View my portfolio of completed projects including web applications, mobile apps, and websites.",
keywords: ["projects", "portfolio", "work", "case studies", "examples", "demos"]
},
{
id: 5,
title: "Blog & Articles",
url: "blogs.html",
category: "Page",
description: "Read articles about web development, JavaScript, React, and modern development practices.",
keywords: ["blog", "articles", "tutorials", "web development", "javascript", "react", "css"]
},
{
id: 6,
title: "Contact Us",
url: "contact.html",
category: "Page",
description: "Get in touch via email, WhatsApp, or social media. Free consultation available.",
keywords: ["contact", "email", "phone", "whatsapp", "consultation", "hire", "get in touch"]
},
{
id: 7,
title: "Web Development",
url: "services.html#web-development",
category: "Service",
description: "Custom responsive websites built with modern technologies. Starting from $299.",
keywords: ["web development", "website", "html", "css", "javascript", "react", "responsive"]
},
{
id: 8,
title: "Mobile App Development",
url: "services.html#mobile-apps",
category: "Service",
description: "Native and hybrid mobile applications for iOS and Android.",
keywords: ["mobile apps", "android", "ios", "react native", "flutter", "app development"]
},
{
id: 9,
title: "UI/UX Design",
url: "services.html#ui-ux-design",
category: "Service",
description: "Beautiful, user-friendly interfaces. Starting from $199.",
keywords: ["ui design", "ux design", "user interface", "user experience", "figma", "design"]
},
{
id: 10,
title: "E-commerce Solutions",
url: "services.html#ecommerce",
category: "Service",
description: "Online stores with payment gateway integration. Starting from $799.",
keywords: ["ecommerce", "online store", "shopping cart", "payment gateway", "shop", "store"]
},
{
id: 11,
title: "Website Maintenance",
url: "services.html#maintenance",
category: "Service",
description: "Updates, support, and ongoing optimization. $50/month.",
keywords: ["maintenance", "support", "updates", "hosting", "optimization"]
},
{
id: 12,
title: "SEO & Marketing",
url: "services.html#seo",
category: "Service",
description: "Get found on Google and grow your online presence. Starting from $150.",
keywords: ["seo", "marketing", "google", "optimization", "traffic", "ranking"]
},
{
id: 13,
title: "Uyeh Subscription Platform",
url: "projects.html#uyeh-subscription",
category: "Project",
description: "Virtual top-up platform for data, airtime, cable TV, and electricity bills.",
keywords: ["subscription", "bills", "payment", "react", "nodejs", "mongodb"]
},
{
id: 14,
title: "Oxygen Hotel",
url: "projects.html#oxygen-hotel",
category: "Project",
description: "Hotel booking website with payment gateway integration.",
keywords: ["hotel", "booking", "reservation", "payment", "php", "javascript"]
},
{
id: 15,
title: "5 Tips for Modern Web Design",
url: "blogs.html#modern-web-design",
category: "Blog",
description: "Learn how to create responsive, stunning websites that engage users.",
keywords: ["web design", "responsive", "tips", "modern", "ui", "ux"]
},
{
id: 16,
title: "Understanding JavaScript ES6",
url: "blogs.html#javascript-es6",
category: "Blog",
description: "Essential JavaScript features every developer should know.",
keywords: ["javascript", "es6", "programming", "development", "tutorial"]
},
{
id: 17,
title: "CSS Grid vs Flexbox",
url: "blogs.html#css-grid-flexbox",
category: "Blog",
description: "Understanding when to use CSS Grid and Flexbox for layouts.",
keywords: ["css", "grid", "flexbox", "layout", "responsive", "design"]
},
// EXTERNAL LINKS
{
title: "GitHub",
description: "View our code repositories",
keywords: ["github", "code", "repository"],
url: "https://github.com",
category: "external",
external: true
},
{
title: "LinkedIn",
description: "Connect with us professionally",
keywords: ["linkedin", "professional", "network"],
url: "https://linkedin.com",
category: "external",
external: true
}
];
// ========== SEARCH FUNCTION ==========
function performSearch(query) {
const searchTerm = query.toLowerCase().trim();
if (!searchTerm) return [];
return searchDatabase.filter(item => {
const titleMatch = item.title.toLowerCase().includes(searchTerm);
const descMatch = item.description.toLowerCase().includes(searchTerm);
const keywordMatch = item.keywords.some(k => k.toLowerCase().includes(searchTerm));
return titleMatch || descMatch || keywordMatch;
});
}
// ========== DISPLAY RESULTS ==========
function displayResults(results, query) {
// Remove existing modal
const existing = document.getElementById('searchModal');
if (existing) existing.remove();
// Create modal
const modal = document.createElement('div');
modal.id = 'searchModal';
modal.className = 'search-modal';
modal.innerHTML = `
<div class="search-overlay" onclick="closeSearchModal()"></div>
<div class="search-results-box">
<div class="search-header">
<h2>Results for "${query}"</h2>
<button class="close-modal" onclick="closeSearchModal()">✕</button>
</div>
<div class="search-results">
${results.length > 0 ? results.map(item => `
<div class="result-item">
<div class="result-icon">${getIcon(item.category)}</div>
<div class="result-content">
<h3>${item.title}</h3>
<p>${item.description}</p>
<span class="badge">${item.category}</span>
</div>
<a href="${item.url}" class="result-btn" ${item.external ? 'target="_blank"' : ''}>
${item.external ? '↗' : '→'}
</a>
</div>
`).join('') : `
<div class="no-results">
<div class="no-results-icon">🔍</div>
<h3>No results found</h3>
<p>Try different keywords</p>
</div>
`}
</div>
</div>
`;
document.body.appendChild(modal);
setTimeout(() => modal.classList.add('active'), 10);
// Add styles
addModalStyles();
}
// ========== GET CATEGORY ICON ==========
function getIcon(category) {
const icons = {
'page': '📄',
'service': '⚙️',
'external': '🔗'
};
return icons[category] || '📌';
}
// ========== CLOSE MODAL ==========
window.closeSearchModal = function() {
const modal = document.getElementById('searchModal');
if (modal) {
modal.classList.remove('active');
setTimeout(() => modal.remove(), 300);
}
};
// ========== ADD MODAL STYLES ==========
function addModalStyles() {
if (document.getElementById('searchModalStyles')) return;
const style = document.createElement('style');
style.id = 'searchModalStyles';
style.textContent = `
.search-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 10000;
opacity: 0;
transition: opacity 0.3s ease;
}
.search-modal.active { opacity: 1; }
.search-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.9);
backdrop-filter: blur(10px);
}
.search-results-box {
position: relative;
width: 90%;
max-width: 700px;
max-height: 80vh;
margin: 5vh auto;
background: #0a0a0a;
border: 2px solid #00ff88;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 20px 60px rgba(0, 255, 136, 0.4);
}
.search-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 25px;
background: rgba(0, 255, 136, 0.1);
border-bottom: 1px solid #00ff88;
}
.search-header h2 {
color: #00ff88;
font-size: 1.3em;
margin: 0;
}
.close-modal {
background: rgba(255, 68, 68, 0.2);
border: 1px solid #ff4444;
color: #ff4444;
font-size: 1.5em;
width: 40px;
height: 40px;
border-radius: 50%;
cursor: pointer;
transition: all 0.3s ease;
}
.close-modal:hover {
background: rgba(255, 68, 68, 0.3);
transform: rotate(90deg);
}
.search-results {
padding: 20px;
max-height: calc(80vh - 80px);
overflow-y: auto;
}
.result-item {
display: flex;
align-items: center;
gap: 15px;
padding: 15px;
background: rgba(0, 255, 136, 0.05);
border: 1px solid rgba(0, 255, 136, 0.2);
border-radius: 12px;
margin-bottom: 12px;
transition: all 0.3s ease;
}
.result-item:hover {
background: rgba(0, 255, 136, 0.1);
border-color: #00ff88;
transform: translateX(5px);
}
.result-icon {
font-size: 2em;
flex-shrink: 0;
}
.result-content {
flex: 1;
}
.result-content h3 {
color: #00ff88;
margin: 0 0 5px 0;
font-size: 1.1em;
}
.result-content p {
color: #d1d5db;
margin: 0 0 8px 0;
font-size: 0.9em;
}
.badge {
display: inline-block;
padding: 3px 10px;
background: rgba(0, 255, 136, 0.2);
border-radius: 12px;
color: #00ff88;
font-size: 0.75em;
text-transform: uppercase;
}
.result-btn {
padding: 10px 15px;
background: linear-gradient(135deg, #00b359, #00ff88);
color: #fff;
text-decoration: none;
border-radius: 8px;
font-weight: bold;
font-size: 1.2em;
transition: all 0.3s ease;
}
.result-btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 255, 136, 0.5);
}
.no-results {
text-align: center;
padding: 60px 20px;
}
.no-results-icon {
font-size: 4em;
margin-bottom: 15px;
}
.no-results h3 {
color: #00ff88;
font-size: 1.5em;
margin-bottom: 10px;
}
.no-results p {
color: #d1d5db;
font-size: 1em;
}
@media (max-width: 768px) {
.search-results-box {
width: 95%;
margin: 2vh auto;
}
.result-item {
flex-direction: column;
align-items: flex-start;
}
.result-btn {
width: 100%;
text-align: center;
}
}
`;
document.head.appendChild(style);
}
// ========== SEARCH BAR TOGGLE ==========
searchBtn.addEventListener('click', (e) => {
e.stopPropagation();
searchInput.classList.add('active');
searchClose.classList.add('active');
setTimeout(() => searchInput.focus(), 100);
console.log('🔍 Search opened');
});
searchClose.addEventListener('click', (e) => {
e.stopPropagation();
searchInput.classList.remove('active');
searchClose.classList.remove('active');
searchInput.value = '';
console.log('❌ Search closed');
});
// ========== SEARCH SUBMIT ==========
searchInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
const query = searchInput.value.trim();
if (query) {
console.log('🔍 Searching for:', query);
const results = performSearch(query);
displayResults(results, query);
// Close search bar
searchInput.classList.remove('active');
searchClose.classList.remove('active');
searchInput.value = '';
}
}
});
// ========== CLICK OUTSIDE TO CLOSE ==========
document.addEventListener('click', (e) => {
if (!e.target.closest('.search-container')) {
searchInput.classList.remove('active');
searchClose.classList.remove('active');
}
});
searchInput.addEventListener('click', (e) => {
e.stopPropagation();
});