Update index.html
Browse files- index.html +298 -92
index.html
CHANGED
@@ -3,152 +3,358 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8" />
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
-
<title>Smart Analyzer</title>
|
7 |
<style>
|
8 |
-
/* ⤵ unchanged styles */
|
9 |
:root {
|
10 |
-
--primary-color: #
|
11 |
-
--secondary-color: #
|
|
|
12 |
--text-color: #333;
|
13 |
-
--
|
14 |
-
--btn-
|
|
|
15 |
--card-bg: #fff;
|
16 |
-
--card-shadow: rgba(0, 0, 0, 0.
|
17 |
-
--border-radius:
|
18 |
--transition: 0.3s;
|
19 |
-
--max-width:
|
20 |
}
|
|
|
21 |
* { box-sizing: border-box; }
|
|
|
22 |
body {
|
23 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
24 |
color: var(--text-color);
|
25 |
background: var(--secondary-color);
|
26 |
margin: 0;
|
27 |
-
padding:
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
.section {
|
34 |
background: var(--card-bg);
|
35 |
-
padding:
|
36 |
-
margin-bottom: 30px;
|
37 |
border-radius: var(--border-radius);
|
38 |
-
box-shadow: 0
|
39 |
-
transition: transform var(--transition);
|
|
|
|
|
40 |
}
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
h2 {
|
43 |
margin-top: 0;
|
44 |
color: var(--primary-color);
|
|
|
|
|
45 |
border-bottom: 2px solid var(--secondary-color);
|
46 |
-
padding-bottom: 5px;
|
47 |
}
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
width: 100%;
|
51 |
-
padding:
|
52 |
-
margin-top:
|
53 |
-
border: 1px solid #
|
54 |
border-radius: var(--border-radius);
|
55 |
font-size: 1rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
-
|
|
|
58 |
background: var(--btn-color);
|
59 |
-
color:
|
60 |
border: none;
|
61 |
-
margin-top: 20px;
|
62 |
-
padding: 12px;
|
63 |
-
font-size: 1rem;
|
64 |
border-radius: var(--border-radius);
|
|
|
|
|
65 |
cursor: pointer;
|
66 |
-
transition:
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
.results {
|
70 |
-
margin-top:
|
71 |
-
padding:
|
72 |
background: var(--secondary-color);
|
73 |
border-radius: var(--border-radius);
|
74 |
border: 1px solid #ddd;
|
75 |
-
min-height:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
|
|
|
|
|
|
|
|
|
|
77 |
@media (min-width: 768px) {
|
78 |
-
.grid {
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
</style>
|
82 |
</head>
|
83 |
<body>
|
|
|
|
|
|
|
|
|
|
|
84 |
<div class="container">
|
85 |
-
<h1>Smart Analyzer</h1>
|
86 |
<div class="grid">
|
87 |
<div class="section">
|
88 |
-
<h2>Summarize
|
89 |
-
<
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
</div>
|
|
|
93 |
<div class="section">
|
94 |
-
<h2>Ask a Question</h2>
|
95 |
-
<
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
</div>
|
|
|
100 |
<div class="section">
|
101 |
-
<h2>
|
102 |
-
<
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
</div>
|
106 |
</div>
|
|
|
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 |
-
</div>
|
153 |
</body>
|
154 |
-
</html>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8" />
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>Smart Analyzer Pro</title>
|
7 |
<style>
|
|
|
8 |
:root {
|
9 |
+
--primary-color: #4361ee;
|
10 |
+
--secondary-color: #f1f5f9;
|
11 |
+
--accent-color: #3f37c9;
|
12 |
--text-color: #333;
|
13 |
+
--light-text: #666;
|
14 |
+
--btn-color: #4361ee;
|
15 |
+
--btn-hover: #3f37c9;
|
16 |
--card-bg: #fff;
|
17 |
+
--card-shadow: rgba(0, 0, 0, 0.08);
|
18 |
+
--border-radius: 10px;
|
19 |
--transition: 0.3s;
|
20 |
+
--max-width: 1200px;
|
21 |
}
|
22 |
+
|
23 |
* { box-sizing: border-box; }
|
24 |
+
|
25 |
body {
|
26 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
27 |
color: var(--text-color);
|
28 |
background: var(--secondary-color);
|
29 |
margin: 0;
|
30 |
+
padding: 0;
|
31 |
+
min-height: 100vh;
|
32 |
+
}
|
33 |
+
|
34 |
+
.app-header {
|
35 |
+
background: var(--primary-color);
|
36 |
+
color: white;
|
37 |
+
padding: 20px 0;
|
38 |
+
text-align: center;
|
39 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
40 |
+
margin-bottom: 40px;
|
41 |
+
}
|
42 |
+
|
43 |
+
.app-title {
|
44 |
+
margin: 0;
|
45 |
+
font-size: 2.5rem;
|
46 |
}
|
47 |
+
|
48 |
+
.app-subtitle {
|
49 |
+
margin: 10px 0 0;
|
50 |
+
font-weight: normal;
|
51 |
+
opacity: 0.9;
|
52 |
+
}
|
53 |
+
|
54 |
+
.container {
|
55 |
+
width: 92%;
|
56 |
+
max-width: var(--max-width);
|
57 |
+
margin: 0 auto;
|
58 |
+
padding: 0 20px 40px;
|
59 |
+
}
|
60 |
+
|
61 |
+
.grid {
|
62 |
+
display: grid;
|
63 |
+
grid-template-columns: 1fr;
|
64 |
+
gap: 30px;
|
65 |
+
}
|
66 |
+
|
67 |
.section {
|
68 |
background: var(--card-bg);
|
69 |
+
padding: 25px;
|
|
|
70 |
border-radius: var(--border-radius);
|
71 |
+
box-shadow: 0 5px 15px var(--card-shadow);
|
72 |
+
transition: transform var(--transition), box-shadow var(--transition);
|
73 |
+
position: relative;
|
74 |
+
overflow: hidden;
|
75 |
}
|
76 |
+
|
77 |
+
.section:hover {
|
78 |
+
transform: translateY(-5px);
|
79 |
+
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
|
80 |
+
}
|
81 |
+
|
82 |
+
.section::before {
|
83 |
+
content: '';
|
84 |
+
position: absolute;
|
85 |
+
top: 0;
|
86 |
+
left: 0;
|
87 |
+
width: 100%;
|
88 |
+
height: 5px;
|
89 |
+
background: var(--primary-color);
|
90 |
+
}
|
91 |
+
|
92 |
h2 {
|
93 |
margin-top: 0;
|
94 |
color: var(--primary-color);
|
95 |
+
font-size: 1.5rem;
|
96 |
+
padding-bottom: 10px;
|
97 |
border-bottom: 2px solid var(--secondary-color);
|
|
|
98 |
}
|
99 |
+
|
100 |
+
.icon {
|
101 |
+
display: inline-block;
|
102 |
+
margin-right: 8px;
|
103 |
+
vertical-align: middle;
|
104 |
+
}
|
105 |
+
|
106 |
+
.file-input-wrapper {
|
107 |
+
position: relative;
|
108 |
+
margin-top: 20px;
|
109 |
+
}
|
110 |
+
|
111 |
+
.file-input-label {
|
112 |
+
display: block;
|
113 |
+
background: var(--secondary-color);
|
114 |
+
border: 2px dashed #ccc;
|
115 |
+
border-radius: var(--border-radius);
|
116 |
+
padding: 25px 15px;
|
117 |
+
text-align: center;
|
118 |
+
cursor: pointer;
|
119 |
+
transition: all var(--transition);
|
120 |
+
}
|
121 |
+
|
122 |
+
.file-input-label:hover {
|
123 |
+
border-color: var(--primary-color);
|
124 |
+
background: #e8eeff;
|
125 |
+
}
|
126 |
+
|
127 |
+
.file-input {
|
128 |
+
position: absolute;
|
129 |
+
left: 0;
|
130 |
+
top: 0;
|
131 |
+
opacity: 0;
|
132 |
+
width: 100%;
|
133 |
+
height: 100%;
|
134 |
+
cursor: pointer;
|
135 |
+
}
|
136 |
+
|
137 |
+
.file-name {
|
138 |
+
margin-top: 10px;
|
139 |
+
font-size: 0.9rem;
|
140 |
+
color: var(--light-text);
|
141 |
+
min-height: 20px;
|
142 |
+
}
|
143 |
+
|
144 |
+
input[type="text"] {
|
145 |
width: 100%;
|
146 |
+
padding: 12px 15px;
|
147 |
+
margin-top: 15px;
|
148 |
+
border: 1px solid #ddd;
|
149 |
border-radius: var(--border-radius);
|
150 |
font-size: 1rem;
|
151 |
+
transition: border-color var(--transition);
|
152 |
+
}
|
153 |
+
|
154 |
+
input[type="text"]:focus {
|
155 |
+
outline: none;
|
156 |
+
border-color: var(--primary-color);
|
157 |
+
box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
|
158 |
}
|
159 |
+
|
160 |
+
.btn {
|
161 |
background: var(--btn-color);
|
162 |
+
color: white;
|
163 |
border: none;
|
|
|
|
|
|
|
164 |
border-radius: var(--border-radius);
|
165 |
+
padding: 12px 20px;
|
166 |
+
font-size: 1rem;
|
167 |
cursor: pointer;
|
168 |
+
transition: all var(--transition);
|
169 |
+
display: block;
|
170 |
+
width: 100%;
|
171 |
+
margin-top: 20px;
|
172 |
+
font-weight: 600;
|
173 |
}
|
174 |
+
|
175 |
+
.btn:hover {
|
176 |
+
background: var(--btn-hover);
|
177 |
+
transform: translateY(-2px);
|
178 |
+
}
|
179 |
+
|
180 |
+
.btn:active {
|
181 |
+
transform: translateY(0);
|
182 |
+
}
|
183 |
+
|
184 |
.results {
|
185 |
+
margin-top: 25px;
|
186 |
+
padding: 20px;
|
187 |
background: var(--secondary-color);
|
188 |
border-radius: var(--border-radius);
|
189 |
border: 1px solid #ddd;
|
190 |
+
min-height: 100px;
|
191 |
+
position: relative;
|
192 |
+
}
|
193 |
+
|
194 |
+
.loader {
|
195 |
+
display: none;
|
196 |
+
text-align: center;
|
197 |
+
padding: 20px 0;
|
198 |
+
}
|
199 |
+
|
200 |
+
.loader::after {
|
201 |
+
content: '';
|
202 |
+
display: inline-block;
|
203 |
+
width: 30px;
|
204 |
+
height: 30px;
|
205 |
+
border: 3px solid var(--secondary-color);
|
206 |
+
border-radius: 50%;
|
207 |
+
border-top-color: var(--primary-color);
|
208 |
+
animation: spin 1s linear infinite;
|
209 |
+
}
|
210 |
+
|
211 |
+
@keyframes spin {
|
212 |
+
to { transform: rotate(360deg); }
|
213 |
+
}
|
214 |
+
|
215 |
+
.processing .loader {
|
216 |
+
display: block;
|
217 |
}
|
218 |
+
|
219 |
+
.processing .result-content {
|
220 |
+
display: none;
|
221 |
+
}
|
222 |
+
|
223 |
@media (min-width: 768px) {
|
224 |
+
.grid {
|
225 |
+
grid-template-columns: repeat(2, 1fr);
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
@media (min-width: 1024px) {
|
230 |
+
.grid {
|
231 |
+
grid-template-columns: repeat(3, 1fr);
|
232 |
+
}
|
233 |
}
|
234 |
</style>
|
235 |
</head>
|
236 |
<body>
|
237 |
+
<header class="app-header">
|
238 |
+
<h1 class="app-title">Smart Analyzer Pro</h1>
|
239 |
+
<p class="app-subtitle">Analyze documents, answer questions, and interpret images with AI</p>
|
240 |
+
</header>
|
241 |
+
|
242 |
<div class="container">
|
|
|
243 |
<div class="grid">
|
244 |
<div class="section">
|
245 |
+
<h2><span class="icon">📄</span>Summarize Document</h2>
|
246 |
+
<div class="file-input-wrapper">
|
247 |
+
<label class="file-input-label">
|
248 |
+
<span>Drop your document here or click to browse</span>
|
249 |
+
<input type="file" id="summary-file" class="file-input" accept=".pdf,.docx,.txt">
|
250 |
+
</label>
|
251 |
+
<div id="summary-file-name" class="file-name"></div>
|
252 |
+
</div>
|
253 |
+
<button id="summarize-btn" class="btn">Generate Summary</button>
|
254 |
+
<div id="summary-result" class="results">
|
255 |
+
<div class="loader"></div>
|
256 |
+
<div class="result-content">Your summary will appear here.</div>
|
257 |
+
</div>
|
258 |
</div>
|
259 |
+
|
260 |
<div class="section">
|
261 |
+
<h2><span class="icon">❓</span>Ask a Question</h2>
|
262 |
+
<div class="file-input-wrapper">
|
263 |
+
<label class="file-input-label">
|
264 |
+
<span>Drop your file here or click to browse</span>
|
265 |
+
<input type="file" id="qa-file" class="file-input" accept=".pdf,.docx,.txt,image/*">
|
266 |
+
</label>
|
267 |
+
<div id="qa-file-name" class="file-name"></div>
|
268 |
+
</div>
|
269 |
+
<input type="text" id="qa-question" placeholder="Type your question about the document...">
|
270 |
+
<button id="qa-btn" class="btn">Get Answer</button>
|
271 |
+
<div id="qa-result" class="results">
|
272 |
+
<div class="loader"></div>
|
273 |
+
<div class="result-content">Answer will appear here.</div>
|
274 |
+
</div>
|
275 |
</div>
|
276 |
+
|
277 |
<div class="section">
|
278 |
+
<h2><span class="icon">🖼️</span>Analyze Image</h2>
|
279 |
+
<div class="file-input-wrapper">
|
280 |
+
<label class="file-input-label">
|
281 |
+
<span>Drop your image here or click to browse</span>
|
282 |
+
<input type="file" id="image-file" class="file-input" accept="image/*">
|
283 |
+
</label>
|
284 |
+
<div id="image-file-name" class="file-name"></div>
|
285 |
+
</div>
|
286 |
+
<button id="image-btn" class="btn">Generate Description</button>
|
287 |
+
<div id="image-result" class="results">
|
288 |
+
<div class="loader"></div>
|
289 |
+
<div class="result-content">Image description will appear here.</div>
|
290 |
+
</div>
|
291 |
</div>
|
292 |
</div>
|
293 |
+
</div>
|
294 |
|
295 |
+
<script>
|
296 |
+
// Show file name when selected
|
297 |
+
document.querySelectorAll('.file-input').forEach(input => {
|
298 |
+
input.addEventListener('change', function() {
|
299 |
+
const fileNameElement = document.getElementById(this.id + '-name');
|
300 |
+
fileNameElement.textContent = this.files[0] ? this.files[0].name : '';
|
301 |
+
});
|
302 |
+
});
|
303 |
+
|
304 |
+
async function sendData(url, fileInputId, extraData, resultId) {
|
305 |
+
const fileInput = document.getElementById(fileInputId);
|
306 |
+
const file = fileInput.files[0];
|
307 |
+
const resultElement = document.getElementById(resultId);
|
308 |
+
const resultContent = resultElement.querySelector('.result-content');
|
309 |
+
|
310 |
+
if (!file) {
|
311 |
+
resultContent.textContent = 'Please select a file.';
|
312 |
+
return;
|
313 |
+
}
|
314 |
+
|
315 |
+
const formData = new FormData();
|
316 |
+
formData.append(fileInputId.includes('image') ? 'image' : 'file', file);
|
317 |
+
|
318 |
+
if (extraData) {
|
319 |
+
for (const [key, value] of Object.entries(extraData)) {
|
320 |
+
formData.append(key, value);
|
321 |
}
|
322 |
}
|
323 |
+
|
324 |
+
// Show loading state
|
325 |
+
resultElement.classList.add('processing');
|
326 |
+
|
327 |
+
try {
|
328 |
+
const res = await fetch(url, { method: 'POST', body: formData });
|
329 |
+
const data = await res.json();
|
330 |
+
|
331 |
+
// Update result content
|
332 |
+
resultContent.textContent = data.result || data.summary || data.answer ||
|
333 |
+
data.description || data.error || JSON.stringify(data);
|
334 |
+
} catch (err) {
|
335 |
+
resultContent.textContent = 'Error: ' + err.message;
|
336 |
+
} finally {
|
337 |
+
// Hide loading state
|
338 |
+
resultElement.classList.remove('processing');
|
339 |
+
}
|
340 |
+
}
|
341 |
|
342 |
+
document.getElementById('summarize-btn').addEventListener('click', () => {
|
343 |
+
sendData('/api/summarize', 'summary-file', null, 'summary-result');
|
344 |
+
});
|
|
|
345 |
|
346 |
+
document.getElementById('qa-btn').addEventListener('click', () => {
|
347 |
+
const question = document.getElementById('qa-question').value.trim();
|
348 |
+
if (!question) {
|
349 |
+
document.getElementById('qa-result').querySelector('.result-content').textContent = 'Please enter a question.';
|
350 |
+
return;
|
351 |
+
}
|
352 |
+
sendData('/api/qa', 'qa-file', { question }, 'qa-result');
|
353 |
+
});
|
354 |
|
355 |
+
document.getElementById('image-btn').addEventListener('click', () => {
|
356 |
+
sendData('/api/caption', 'image-file', null, 'image-result');
|
357 |
+
});
|
358 |
+
</script>
|
|
|
359 |
</body>
|
360 |
+
</html>
|