tuhbooh commited on
Commit
d5814df
·
verified ·
1 Parent(s): 6c21271

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +220 -251
index.html CHANGED
@@ -3,296 +3,265 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>HuggingSearch - Thông tin bao quát & Multimedia Results</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
  <style>
10
  :root {
11
- --bg-dark: #0f172a;
12
- --surface-dark: #1e293b;
13
- --accent: #fcd34d;
14
- --text-main: #f8fafc;
15
- --text-muted: #94a3b8;
16
- --border: #334155;
17
- --link-color: #38bdf8;
18
- --url-color: #4ade80;
19
  }
 
20
  body {
21
- background-color: var(--bg-dark);
22
- color: var(--text-main);
23
- font-family: 'Inter', system-ui, sans-serif;
 
 
 
 
 
 
 
 
 
24
  }
25
- .search-input:focus { box-shadow: 0 0 0 2px var(--accent); }
26
- .result-card:hover .result-title { text-decoration: underline; }
27
- ::-webkit-scrollbar { width: 8px; }
28
- ::-webkit-scrollbar-track { background: var(--bg-dark); }
29
- ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
30
-
31
- .line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
32
- .tab-btn.active { border-bottom: 2px solid var(--accent); color: var(--accent); }
33
-
34
- .animate-fadeIn { animation: fadeIn 0.4s ease-out forwards; }
35
- @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
36
-
37
- .ai-summary-box {
38
- background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
39
- border: 1px solid #fbbf2433;
40
  }
41
 
42
- .image-grid {
43
- display: grid;
44
- grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
45
- gap: 12px;
 
 
 
 
46
  }
47
- .image-item {
48
- aspect-ratio: 1/1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  position: relative;
50
- overflow: hidden;
51
- border-radius: 12px;
52
- background: var(--surface-dark);
53
- border: 1px solid var(--border);
54
- transition: transform 0.2s;
 
 
 
 
 
55
  }
56
- .image-item:hover { transform: scale(1.03); border-color: var(--accent); }
57
- .image-item img { width: 100%; height: 100%; object-fit: cover; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  </style>
59
  </head>
60
- <body class="flex flex-col h-screen overflow-hidden">
61
-
62
- <!-- Header -->
63
- <header class="border-b border-[var(--border)] bg-[var(--bg-dark)] px-4 py-3 flex items-center justify-between z-10">
64
- <div class="flex items-center gap-6 w-full max-w-6xl">
65
- <div class="flex items-center gap-2 cursor-pointer" onclick="window.location.reload()">
66
- <div class="text-3xl">🤗</div>
67
- <span class="font-bold text-xl hidden md:block tracking-tight text-white">Hugging<span class="text-[var(--accent)]">Search</span></span>
 
 
68
  </div>
69
 
70
- <div class="flex-1 max-w-3xl relative">
71
  <input
72
  type="text"
73
- id="searchInput"
74
- placeholder="Tìm ảnh, video hoặc tin tức..."
75
- class="w-full bg-[var(--surface-dark)] border border-[var(--border)] rounded-full py-2.5 px-6 pr-12 outline-none search-input text-sm transition-all text-white"
 
76
  >
77
- <button id="searchButton" class="absolute right-4 top-2.5 text-[var(--text-muted)] hover:text-[var(--accent)]">
78
- <i class="fas fa-search"></i>
 
 
 
79
  </button>
80
  </div>
81
- </div>
82
- <div class="flex items-center gap-4 ml-4 text-[var(--text-muted)]">
83
- <span class="text-[10px] font-bold uppercase tracking-widest bg-amber-900/40 text-amber-400 px-2 py-1 rounded border border-amber-800/50">Multimedia v3.1</span>
 
84
  </div>
85
  </header>
86
 
87
- <!-- Tabs -->
88
- <div class="border-b border-[var(--border)] px-4 md:px-32 bg-[var(--bg-dark)] flex items-center text-sm overflow-x-auto whitespace-nowrap">
89
- <div class="flex gap-6 h-12 items-center" id="tabContainer">
90
- <button class="tab-btn active h-full px-2" data-type="all">Tất cả</button>
91
- <button class="tab-btn text-[var(--text-muted)] hover:text-white h-full px-2" data-type="images">Hình ảnh</button>
92
- <button class="tab-btn text-[var(--text-muted)] hover:text-white h-full px-2" data-type="videos">Video</button>
93
- <button class="tab-btn text-[var(--text-muted)] hover:text-white h-full px-2" data-type="news">Tin tức</button>
94
  </div>
95
- </div>
96
 
97
- <!-- Main Content -->
98
- <div class="flex flex-1 overflow-hidden">
99
- <main class="flex-1 overflow-y-auto p-4 md:px-12 lg:px-32">
100
-
101
- <div id="loading" class="hidden py-20 text-center">
102
- <div class="inline-block animate-spin rounded-full h-8 w-8 border-t-2 border-[var(--accent)] border-r-2 border-transparent"></div>
103
- <p id="loadingText" class="mt-4 text-sm text-[var(--text-muted)] italic">Đang bóc tách dữ liệu tìm kiếm...</p>
104
  </div>
105
 
106
- <div id="resultsArea" class="max-w-4xl space-y-8 py-6">
107
- <!-- Welcome Screen -->
108
- <div id="welcome" class="py-20 text-center">
109
- <div class="text-6xl mb-6">🤗</div>
110
- <h2 class="text-3xl font-bold mb-2 text-white">HuggingSearch</h2>
111
- <p class="text-[var(--text-muted)] text-sm max-w-md mx-auto">Hệ thống tìm kiếm thông tin bao quát và kết quả đa phương tiện trực quan.</p>
 
 
 
 
 
 
 
112
  </div>
 
 
 
 
 
 
 
 
113
  </div>
114
- </main>
115
- </div>
 
 
 
 
 
 
 
116
 
117
  <script>
118
- (function() {
119
- const searchInput = document.getElementById('searchInput');
120
- const searchButton = document.getElementById('searchButton');
121
- const resultsArea = document.getElementById('resultsArea');
122
- const loading = document.getElementById('loading');
123
- const welcome = document.getElementById('welcome');
124
- const tabButtons = document.querySelectorAll('.tab-btn');
125
-
126
- let currentType = 'all';
127
-
128
- tabButtons.forEach(btn => {
129
- btn.addEventListener('click', () => {
130
- tabButtons.forEach(b => b.classList.remove('active', 'text-[var(--accent)]'));
131
- btn.classList.add('active', 'text-[var(--accent)]');
132
- currentType = btn.getAttribute('data-type');
133
- performSearch();
134
- });
135
- });
136
-
137
- searchInput.addEventListener('keypress', (e) => {
138
- if (e.key === 'Enter') performSearch();
139
- });
140
 
141
- searchButton.addEventListener('click', () => performSearch());
142
-
143
- function cleanDDGUrl(url) {
144
- try {
145
- if (!url) return "#";
146
- if (url.includes('duckduckgo.com/l/?')) {
147
- const urlObj = new URL('https:' + (url.startsWith('http') ? '' : 'https:') + url);
148
- const uddg = urlObj.searchParams.get('uddg');
149
- if (uddg) return decodeURIComponent(uddg);
150
- }
151
- if (url.startsWith('//')) return 'https:' + url;
152
- if (url.startsWith('/')) return 'https://duckduckgo.com' + url;
153
- return url;
154
- } catch (e) {
155
- return url;
156
- }
157
  }
 
158
 
159
- async function performSearch() {
160
- const query = searchInput.value.trim();
161
- if (!query) return;
162
-
163
- if (welcome) welcome.style.display = 'none';
164
- resultsArea.innerHTML = '';
165
- loading.classList.remove('hidden');
166
-
167
- let searchQuery = query;
168
- if (currentType === 'images') searchQuery += " site:pinterest.com OR site:unsplash.com OR site:pixabay.com";
169
- if (currentType === 'videos') searchQuery += " site:youtube.com OR site:vimeo.com";
170
-
171
- const targetUrl = "https://duckduckgo.com/html/?q=" + encodeURIComponent(searchQuery);
172
-
173
- try {
174
- const response = await fetch("https://api.allorigins.win/get?url=" + encodeURIComponent(targetUrl));
175
- const data = await response.json();
176
- const parser = new DOMParser();
177
- const doc = parser.parseFromString(data.contents, 'text/html');
178
- const results = Array.from(doc.querySelectorAll('.result'));
179
-
180
- if (results.length === 0) {
181
- resultsArea.innerHTML = '<p class="text-center py-10 text-zinc-500">Không tìm thấy dữ liệu phù hợp.</p>';
182
- } else {
183
- if (currentType === 'images') renderImages(results);
184
- else if (currentType === 'videos') renderVideos(results);
185
- else renderAll(results, query);
186
- }
187
- } catch (error) {
188
- resultsArea.innerHTML = '<p class="text-red-400 text-center py-10">Lỗi kết nối Proxy. Vui lòng kiểm tra lại đường truyền.</p>';
189
- } finally {
190
- loading.classList.add('hidden');
191
- }
192
- }
193
 
194
- function renderImages(results) {
195
- let html = '<div class="image-grid animate-fadeIn">';
196
- results.forEach((res) => {
197
- const aTag = res.querySelector('.result__a');
198
- if (!aTag) return;
199
- const link = cleanDDGUrl(aTag.getAttribute('href'));
200
- let domain = "web";
201
- try { domain = new URL(link).hostname; } catch(e) {}
202
-
203
- const screenshotUrl = "https://api.microlink.io/?url=" + encodeURIComponent(link) + "&screenshot=true&embed=screenshot.url";
204
-
205
- html += `
206
- <a href="${link}" target="_blank" class="image-item group">
207
- <img src="${screenshotUrl}"
208
- onerror="this.src='https://via.placeholder.com/300?text=${domain}'"
209
- loading="lazy">
210
- <div class="absolute bottom-0 left-0 right-0 p-2 bg-black/60 text-[10px] truncate opacity-0 group-hover:opacity-100 transition-opacity">
211
- ${domain}
212
- </div>
213
- </a>
214
- `;
215
- });
216
- html += '</div>';
217
- resultsArea.innerHTML = html;
218
- }
219
 
220
- function renderVideos(results) {
221
- let html = '<div class="space-y-6 animate-fadeIn">';
222
- results.forEach((res) => {
223
- const aTag = res.querySelector('.result__a');
224
- if (!aTag) return;
225
- const title = aTag.textContent;
226
- const link = cleanDDGUrl(aTag.getAttribute('href'));
227
- const snippetNode = res.querySelector('.result__snippet');
228
- const desc = snippetNode ? snippetNode.textContent : "";
229
- let domain = "web";
230
- try { domain = new URL(link).hostname; } catch(e) {}
231
-
232
- const screenshotUrl = "https://api.microlink.io/?url=" + encodeURIComponent(link) + "&screenshot=true&embed=screenshot.url";
233
-
234
- html += `
235
- <div class="flex flex-col md:flex-row gap-4 p-4 rounded-2xl bg-[var(--surface-dark)] border border-[var(--border)] hover:border-[var(--accent)] transition-all">
236
- <div class="w-full md:w-48 aspect-video rounded-lg overflow-hidden bg-black flex-shrink-0">
237
- <img src="${screenshotUrl}"
238
- class="w-full h-full object-cover"
239
- onerror="this.parentElement.innerHTML='<div class=\'w-full h-full flex items-center justify-center\'><i class=\'fas fa-play text-2xl text-zinc-700\'></i></div>'">
240
- </div>
241
- <div class="flex-1">
242
- <div class="text-[10px] text-[var(--url-color)] mb-1 uppercase font-bold tracking-widest">${domain}</div>
243
- <a href="${link}" target="_blank" class="block mb-2 text-lg font-bold text-[var(--link-color)] hover:underline line-clamp-1">${title}</a>
244
- <p class="text-sm text-[var(--text-muted)] line-clamp-2">${desc}</p>
245
- </div>
246
- </div>
247
- `;
248
- });
249
- html += '</div>';
250
- resultsArea.innerHTML = html;
251
- }
252
 
253
- function renderAll(results, query) {
254
- let html = '';
255
- const first = results[0];
256
- if (first) {
257
- const firstATag = first.querySelector('.result__a');
258
- const firstSnippet = first.querySelector('.result__snippet');
259
- html += `
260
- <div class="ai-summary-box p-6 rounded-2xl animate-fadeIn mb-8">
261
- <div class="text-[var(--accent)] text-[10px] font-bold uppercase mb-2 tracking-widest flex items-center gap-2">
262
- <i class="fas fa-magic"></i> Thông tin bao quát
263
- </div>
264
- <h2 class="text-xl font-bold mb-2">${firstATag ? firstATag.textContent : query}</h2>
265
- <p class="text-sm text-zinc-300 leading-relaxed">${firstSnippet ? firstSnippet.textContent : ""}</p>
266
- </div>
267
- `;
 
 
 
 
 
 
 
268
  }
269
 
270
- results.forEach((res, i) => {
271
- const titleNode = res.querySelector('.result__a');
272
- if (!titleNode) return;
273
- const title = titleNode.textContent;
274
- const link = cleanDDGUrl(titleNode.getAttribute('href'));
275
- const snippetNode = res.querySelector('.result__snippet');
276
- const desc = snippetNode ? snippetNode.textContent : "";
277
- let domain = "web";
278
- try { domain = new URL(link).hostname; } catch(e) {}
279
-
280
- html += `
281
- <div class="result-card group animate-fadeIn" style="animation-delay: ${i*0.05}s">
282
- <div class="flex items-center gap-2 mb-1">
283
- <img src="https://www.google.com/s2/favicons?domain=${domain}&sz=32" class="w-3.5 h-3.5" alt="icon">
284
- <span class="text-[11px] text-[var(--url-color)] font-medium">${domain}</span>
285
- </div>
286
- <a href="${link}" target="_blank" class="block group">
287
- <h3 class="result-title text-[18px] text-[var(--link-color)] mb-1 leading-tight font-semibold">${title}</h3>
288
- </a>
289
- <p class="text-[13px] text-[var(--text-muted)] leading-relaxed line-clamp-2">${desc}</p>
290
- </div>
291
- `;
292
- });
293
- resultsArea.innerHTML = html;
294
  }
295
- })();
296
  </script>
297
  </body>
298
- </html>
 
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Wiki Glass Dark Reader</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=Lora:ital,wght@0,400;0,700;1,400&display=swap" rel="stylesheet">
9
  <style>
10
  :root {
11
+ --glass-bg: rgba(25, 25, 25, 0.65);
12
+ --glass-border: rgba(255, 255, 255, 0.08);
13
+ --accent-blue: #3b82f6;
 
 
 
 
 
14
  }
15
+
16
  body {
17
+ background: radial-gradient(circle at top right, #1e293b, #0f172a, #020617);
18
+ color: #e2e8f0;
19
+ font-family: 'Inter', sans-serif;
20
+ min-height: 100vh;
21
+ overflow-x: hidden;
22
+ }
23
+
24
+ .glass {
25
+ background: var(--glass-bg);
26
+ backdrop-filter: blur(20px);
27
+ -webkit-backdrop-filter: blur(20px);
28
+ border: 1px solid var(--glass-border);
29
  }
30
+
31
+ .wiki-content-area {
32
+ line-height: 1.8;
33
+ font-size: 1.125rem;
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
+ .wiki-content-area h2 {
37
+ font-size: 1.75rem;
38
+ font-weight: 700;
39
+ margin-top: 2.5rem;
40
+ margin-bottom: 1.25rem;
41
+ color: #f8fafc;
42
+ border-bottom: 1px solid var(--glass-border);
43
+ padding-bottom: 0.5rem;
44
  }
45
+
46
+ .wiki-content-area p {
47
+ margin-bottom: 1.5rem;
48
+ color: #cbd5e1;
49
+ }
50
+
51
+ .wiki-content-area b, .wiki-content-area strong {
52
+ color: #f1f5f9;
53
+ font-weight: 600;
54
+ }
55
+
56
+ .wiki-content-area ul {
57
+ list-style-type: none;
58
+ padding-left: 1rem;
59
+ margin-bottom: 1.5rem;
60
+ }
61
+
62
+ .wiki-content-area li {
63
  position: relative;
64
+ padding-left: 1.5rem;
65
+ margin-bottom: 0.75rem;
66
+ }
67
+
68
+ .wiki-content-area li::before {
69
+ content: "•";
70
+ color: var(--accent-blue);
71
+ position: absolute;
72
+ left: 0;
73
+ font-weight: bold;
74
  }
75
+
76
+ .search-input {
77
+ background: rgba(255, 255, 255, 0.05);
78
+ border: 1px solid var(--glass-border);
79
+ transition: all 0.3s ease;
80
+ }
81
+
82
+ .search-input:focus {
83
+ background: rgba(255, 255, 255, 0.1);
84
+ border-color: var(--accent-blue);
85
+ box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
86
+ }
87
+
88
+ .font-serif { font-family: 'Lora', serif; }
89
+ .font-sans { font-family: 'Inter', sans-serif; }
90
+
91
+ .image-shimmer {
92
+ background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
93
+ background-size: 200% 100%;
94
+ animation: shimmer 2s infinite;
95
+ }
96
+
97
+ @keyframes shimmer {
98
+ 0% { background-position: 200% 0; }
99
+ 100% { background-position: -200% 0; }
100
+ }
101
+
102
+ .custom-scroll::-webkit-scrollbar { width: 8px; }
103
+ .custom-scroll::-webkit-scrollbar-track { background: transparent; }
104
+ .custom-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
105
+ .custom-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
106
  </style>
107
  </head>
108
+ <body class="custom-scroll">
109
+
110
+ <!-- Sticky Header -->
111
+ <header class="glass sticky top-0 z-50 px-6 py-4">
112
+ <div class="max-w-5xl mx-auto flex flex-col sm:flex-row items-center gap-6">
113
+ <div class="flex items-center gap-3">
114
+ <div class="w-10 h-10 bg-blue-600 rounded-xl flex items-center justify-center shadow-lg shadow-blue-900/20">
115
+ <svg class="text-white w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332-4.5-1.253"></path></svg>
116
+ </div>
117
+ <h1 class="text-xl font-extrabold tracking-tighter text-white">WIKI<span class="text-blue-500">GLASS</span></h1>
118
  </div>
119
 
120
+ <div class="relative flex-1 w-full max-w-2xl">
121
  <input
122
  type="text"
123
+ id="searchQuery"
124
+ placeholder="Tìm kiếm kiến thức..."
125
+ class="search-input w-full py-3 px-5 rounded-2xl outline-none text-white placeholder-gray-500"
126
+ onkeypress="if(event.key === 'Enter') performWikiFetch()"
127
  >
128
+ <button
129
+ onclick="performWikiFetch()"
130
+ class="absolute right-2 top-1.5 bottom-1.5 px-5 bg-blue-600 hover:bg-blue-500 text-white text-sm font-bold rounded-xl transition-all active:scale-95"
131
+ >
132
+ TRA CỨU
133
  </button>
134
  </div>
135
+
136
+ <div class="flex gap-2">
137
+ <button onclick="toggleFont()" id="fontBtn" class="p-2 rounded-lg bg-white/5 hover:bg-white/10 text-xs font-medium border border-white/10">SERIF</button>
138
+ </div>
139
  </div>
140
  </header>
141
 
142
+ <main class="max-w-4xl mx-auto px-6 py-12">
143
+ <!-- Loader -->
144
+ <div id="loader" class="hidden flex flex-col items-center justify-center py-20">
145
+ <div class="w-12 h-12 border-4 border-blue-500/30 border-t-blue-500 rounded-full animate-spin"></div>
146
+ <p class="mt-4 text-gray-400 font-medium">Đang xử dữ liệu Wiki...</p>
 
 
147
  </div>
 
148
 
149
+ <!-- Article Container -->
150
+ <article id="articleFrame" class="hidden">
151
+ <!-- Hero Image Section -->
152
+ <div id="heroBox" class="relative w-full h-[300px] md:h-[450px] rounded-[2rem] overflow-hidden mb-12 glass shadow-2xl hidden">
153
+ <img id="articleImage" src="" class="w-full h-full object-cover">
154
+ <div class="absolute inset-0 bg-gradient-to-t from-slate-950/80 to-transparent"></div>
 
155
  </div>
156
 
157
+ <div class="glass rounded-[2.5rem] p-8 md:p-16 relative overflow-hidden">
158
+ <div class="absolute top-0 left-0 w-32 h-32 bg-blue-600/10 blur-[80px] -z-10"></div>
159
+
160
+ <header class="mb-10">
161
+ <div class="flex items-center gap-3 mb-4">
162
+ <span class="px-3 py-1 bg-blue-500/10 text-blue-400 text-[10px] font-bold uppercase tracking-[0.2em] rounded-full border border-blue-500/20">Wikipedia Source</span>
163
+ <span id="langTag" class="text-gray-500 text-[10px] font-bold uppercase">VI_VN</span>
164
+ </div>
165
+ <h2 id="articleTitle" class="text-4xl md:text-6xl font-extrabold text-white leading-tight"></h2>
166
+ </header>
167
+
168
+ <div id="articleContent" class="wiki-content-area font-sans">
169
+ <!-- Wikipedia content injected here -->
170
  </div>
171
+
172
+ <footer class="mt-16 pt-8 border-t border-white/5 flex flex-col sm:flex-row justify-between items-center gap-6">
173
+ <p class="text-gray-500 text-sm italic">Nội dung được cung cấp theo giấy phép Creative Commons.</p>
174
+ <a id="sourceUrl" href="#" target="_blank" class="flex items-center gap-2 text-blue-400 font-bold hover:text-blue-300 transition-colors">
175
+ Mở liên kết gốc
176
+ <svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path></svg>
177
+ </a>
178
+ </footer>
179
  </div>
180
+ </article>
181
+
182
+ <!-- Initial Placeholder -->
183
+ <div id="emptyState" class="text-center py-20 opacity-40">
184
+ <div class="text-8xl mb-6">🔭</div>
185
+ <h3 class="text-2xl font-bold text-white mb-2">Trung tâm Tri thức Glass</h3>
186
+ <p class="max-w-xs mx-auto text-gray-400">Khám phá thế giới qua lăng kính trực quan và hiện đại.</p>
187
+ </div>
188
+ </main>
189
 
190
  <script>
191
+ let isSerif = false;
192
+
193
+ function toggleFont() {
194
+ const content = document.getElementById('articleContent');
195
+ const btn = document.getElementById('fontBtn');
196
+ isSerif = !isSerif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
 
198
+ if (isSerif) {
199
+ content.classList.remove('font-sans');
200
+ content.classList.add('font-serif');
201
+ btn.innerText = 'SANS';
202
+ } else {
203
+ content.classList.remove('font-serif');
204
+ content.classList.add('font-sans');
205
+ btn.innerText = 'SERIF';
 
 
 
 
 
 
 
 
206
  }
207
+ }
208
 
209
+ async function performWikiFetch() {
210
+ const query = document.getElementById('searchQuery').value.trim();
211
+ const loader = document.getElementById('loader');
212
+ const frame = document.getElementById('articleFrame');
213
+ const empty = document.getElementById('emptyState');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
+ if (!query) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
 
217
+ // UI Transitions
218
+ loader.classList.remove('hidden');
219
+ frame.classList.add('hidden');
220
+ empty.classList.add('hidden');
221
+
222
+ try {
223
+ // Search for the most relevant page
224
+ const sUrl = `https://vi.wikipedia.org/w/api.php?action=query&list=search&srsearch=${encodeURIComponent(query)}&format=json&origin=*`;
225
+ const sResp = await fetch(sUrl);
226
+ const sData = await sResp.json();
227
+
228
+ if (!sData.query.search.length) throw "Không tìm thấy dữ liệu phù hợp.";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
230
+ const bestMatch = sData.query.search[0].title;
231
+
232
+ // Fetch content and high-res image
233
+ const cUrl = `https://vi.wikipedia.org/w/api.php?action=query&prop=extracts|pageimages&titles=${encodeURIComponent(bestMatch)}&format=json&origin=*&pithumbsize=1200`;
234
+ const cResp = await fetch(cUrl);
235
+ const cData = await cResp.json();
236
+
237
+ const pages = cData.query.pages;
238
+ const pid = Object.keys(pages)[0];
239
+ const page = pages[pid];
240
+
241
+ // Update UI
242
+ document.getElementById('articleTitle').innerText = page.title;
243
+ document.getElementById('articleContent').innerHTML = page.extract;
244
+ document.getElementById('sourceUrl').href = `https://vi.wikipedia.org/wiki/${encodeURIComponent(page.title)}`;
245
+
246
+ const hero = document.getElementById('heroBox');
247
+ if (page.thumbnail) {
248
+ document.getElementById('articleImage').src = page.thumbnail.source;
249
+ hero.classList.remove('hidden');
250
+ } else {
251
+ hero.classList.add('hidden');
252
  }
253
 
254
+ loader.classList.add('hidden');
255
+ frame.classList.remove('hidden');
256
+ window.scrollTo({ top: 0, behavior: 'smooth' });
257
+
258
+ } catch (err) {
259
+ loader.classList.add('hidden');
260
+ empty.classList.remove('hidden');
261
+ alert(err);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  }
263
+ }
264
  </script>
265
  </body>
266
+ </html>
267
+