raphael0202 commited on
Commit
f2d8977
·
verified ·
1 Parent(s): ce9b766

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +514 -19
index.html CHANGED
@@ -1,19 +1,514 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Open Prices - Proof Visualizer</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></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
+ --primary-color: #4CAF50;
12
+ --secondary-color: #45a049;
13
+ --accent-color: #ff9800;
14
+ --background-color: #f5f5f5;
15
+ --card-bg: #ffffff;
16
+ --text-color: #333333;
17
+ --border-radius: 12px;
18
+ --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
19
+ --transition: all 0.3s ease;
20
+ }
21
+
22
+ * {
23
+ margin: 0;
24
+ padding: 0;
25
+ box-sizing: border-box;
26
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
27
+ }
28
+
29
+ body {
30
+ background-color: var(--background-color);
31
+ color: var(--text-color);
32
+ line-height: 1.6;
33
+ padding: 20px;
34
+ min-height: 100vh;
35
+ display: flex;
36
+ flex-direction: column;
37
+ align-items: center;
38
+ }
39
+
40
+ header {
41
+ width: 100%;
42
+ max-width: 1200px;
43
+ margin-bottom: 30px;
44
+ display: flex;
45
+ justify-content: space-between;
46
+ align-items: center;
47
+ flex-wrap: wrap;
48
+ gap: 15px;
49
+ }
50
+
51
+ .logo-container {
52
+ display: flex;
53
+ align-items: center;
54
+ gap: 10px;
55
+ }
56
+
57
+ .logo {
58
+ width: 50px;
59
+ height: 50px;
60
+ background-color: var(--primary-color);
61
+ border-radius: 50%;
62
+ display: flex;
63
+ justify-content: center;
64
+ align-items: center;
65
+ color: white;
66
+ font-weight: bold;
67
+ font-size: 18px;
68
+ }
69
+
70
+ h1 {
71
+ font-size: 1.8rem;
72
+ color: var(--primary-color);
73
+ }
74
+
75
+ .anycoder-link {
76
+ color: var(--primary-color);
77
+ text-decoration: none;
78
+ font-size: 0.9rem;
79
+ display: flex;
80
+ align-items: center;
81
+ gap: 5px;
82
+ }
83
+
84
+ .anycoder-link:hover {
85
+ text-decoration: underline;
86
+ }
87
+
88
+ .input-container {
89
+ width: 100%;
90
+ max-width: 600px;
91
+ margin-bottom: 30px;
92
+ display: flex;
93
+ flex-direction: column;
94
+ gap: 15px;
95
+ }
96
+
97
+ .input-group {
98
+ display: flex;
99
+ gap: 10px;
100
+ }
101
+
102
+ input {
103
+ flex: 1;
104
+ padding: 12px 15px;
105
+ border: 2px solid #ddd;
106
+ border-radius: var(--border-radius);
107
+ font-size: 1rem;
108
+ transition: var(--transition);
109
+ }
110
+
111
+ input:focus {
112
+ outline: none;
113
+ border-color: var(--primary-color);
114
+ box-shadow: var(--box-shadow);
115
+ }
116
+
117
+ button {
118
+ padding: 12px 20px;
119
+ background-color: var(--primary-color);
120
+ color: white;
121
+ border: none;
122
+ border-radius: var(--border-radius);
123
+ font-size: 1rem;
124
+ cursor: pointer;
125
+ transition: var(--transition);
126
+ display: flex;
127
+ align-items: center;
128
+ gap: 8px;
129
+ }
130
+
131
+ button:hover {
132
+ background-color: var(--secondary-color);
133
+ transform: translateY(-2px);
134
+ }
135
+
136
+ button:disabled {
137
+ background-color: #cccccc;
138
+ cursor: not-allowed;
139
+ transform: none;
140
+ }
141
+
142
+ .loading {
143
+ display: none;
144
+ text-align: center;
145
+ margin: 20px 0;
146
+ }
147
+
148
+ .loading.active {
149
+ display: block;
150
+ }
151
+
152
+ .spinner {
153
+ border: 4px solid rgba(0, 0, 0, 0.1);
154
+ border-radius: 50%;
155
+ border-top: 4px solid var(--primary-color);
156
+ width: 40px;
157
+ height: 40px;
158
+ animation: spin 1s linear infinite;
159
+ margin: 0 auto 10px;
160
+ }
161
+
162
+ @keyframes spin {
163
+ 0% { transform: rotate(0deg); }
164
+ 100% { transform: rotate(360deg); }
165
+ }
166
+
167
+ .error-message {
168
+ color: #e74c3c;
169
+ background-color: #fadbd8;
170
+ padding: 15px;
171
+ border-radius: var(--border-radius);
172
+ margin-bottom: 20px;
173
+ display: none;
174
+ }
175
+
176
+ .error-message.active {
177
+ display: block;
178
+ }
179
+
180
+ .proof-container {
181
+ width: 100%;
182
+ max-width: 1200px;
183
+ margin-bottom: 40px;
184
+ display: none;
185
+ }
186
+
187
+ .proof-container.active {
188
+ display: block;
189
+ }
190
+
191
+ .proof-header {
192
+ display: flex;
193
+ justify-content: space-between;
194
+ align-items: center;
195
+ margin-bottom: 20px;
196
+ flex-wrap: wrap;
197
+ gap: 15px;
198
+ }
199
+
200
+ .proof-title {
201
+ font-size: 1.5rem;
202
+ color: var(--primary-color);
203
+ }
204
+
205
+ .proof-id {
206
+ font-size: 1.2rem;
207
+ color: var(--accent-color);
208
+ font-weight: bold;
209
+ }
210
+
211
+ .proof-image-container {
212
+ background-color: var(--card-bg);
213
+ border-radius: var(--border-radius);
214
+ box-shadow: var(--box-shadow);
215
+ padding: 20px;
216
+ margin-bottom: 30px;
217
+ text-align: center;
218
+ }
219
+
220
+ .proof-image {
221
+ max-width: 100%;
222
+ height: auto;
223
+ border-radius: 8px;
224
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
225
+ }
226
+
227
+ .price-tags-container {
228
+ display: grid;
229
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
230
+ gap: 20px;
231
+ }
232
+
233
+ .price-tag-card {
234
+ background-color: var(--card-bg);
235
+ border-radius: var(--border-radius);
236
+ box-shadow: var(--box-shadow);
237
+ overflow: hidden;
238
+ transition: var(--transition);
239
+ }
240
+
241
+ .price-tag-card:hover {
242
+ transform: translateY(-5px);
243
+ box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
244
+ }
245
+
246
+ .price-tag-image {
247
+ width: 100%;
248
+ height: 200px;
249
+ object-fit: contain;
250
+ background-color: #f9f9f9;
251
+ padding: 10px;
252
+ }
253
+
254
+ .price-tag-info {
255
+ padding: 15px;
256
+ }
257
+
258
+ .price-tag-id {
259
+ font-size: 0.9rem;
260
+ color: #777;
261
+ margin-bottom: 5px;
262
+ }
263
+
264
+ .price-tag-details {
265
+ display: flex;
266
+ flex-direction: column;
267
+ gap: 8px;
268
+ }
269
+
270
+ .detail-row {
271
+ display: flex;
272
+ justify-content: space-between;
273
+ font-size: 0.9rem;
274
+ }
275
+
276
+ .detail-label {
277
+ font-weight: bold;
278
+ color: var(--primary-color);
279
+ }
280
+
281
+ .detail-value {
282
+ color: var(--text-color);
283
+ }
284
+
285
+ .no-price-tags {
286
+ text-align: center;
287
+ padding: 40px;
288
+ color: #777;
289
+ font-style: italic;
290
+ }
291
+
292
+ @media (max-width: 768px) {
293
+ .input-group {
294
+ flex-direction: column;
295
+ }
296
+
297
+ button {
298
+ width: 100%;
299
+ justify-content: center;
300
+ }
301
+
302
+ .price-tags-container {
303
+ grid-template-columns: 1fr;
304
+ }
305
+
306
+ .proof-header {
307
+ flex-direction: column;
308
+ align-items: flex-start;
309
+ }
310
+ }
311
+
312
+ @media (max-width: 480px) {
313
+ h1 {
314
+ font-size: 1.5rem;
315
+ }
316
+
317
+ .proof-title {
318
+ font-size: 1.2rem;
319
+ }
320
+
321
+ .proof-id {
322
+ font-size: 1rem;
323
+ }
324
+ }
325
+ </style>
326
+ </head>
327
+ <body>
328
+ <header>
329
+ <div class="logo-container">
330
+ <div class="logo">OP</div>
331
+ <h1>Open Prices - Proof Visualizer</h1>
332
+ </div>
333
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link" target="_blank">
334
+ <i class="fas fa-code"></i> Built with anycoder
335
+ </a>
336
+ </header>
337
+
338
+ <div class="input-container">
339
+ <div class="input-group">
340
+ <input type="number" id="proofIdInput" placeholder="Enter proof ID (integer)" min="1">
341
+ <button id="fetchProofBtn">
342
+ <i class="fas fa-search"></i> Fetch Proof
343
+ </button>
344
+ </div>
345
+ </div>
346
+
347
+ <div class="loading" id="loading">
348
+ <div class="spinner"></div>
349
+ <p>Loading data...</p>
350
+ </div>
351
+
352
+ <div class="error-message" id="errorMessage"></div>
353
+
354
+ <div class="proof-container" id="proofContainer">
355
+ <div class="proof-header">
356
+ <h2 class="proof-title">Proof Image</h2>
357
+ <div class="proof-id" id="proofIdDisplay"></div>
358
+ </div>
359
+
360
+ <div class="proof-image-container">
361
+ <img id="proofImage" class="proof-image" alt="Proof image">
362
+ </div>
363
+
364
+ <h2 class="proof-title">Associated Price Tags</h2>
365
+
366
+ <div class="price-tags-container" id="priceTagsContainer">
367
+ <!-- Price tags will be inserted here -->
368
+ </div>
369
+ </div>
370
+
371
+ <script>
372
+ document.addEventListener('DOMContentLoaded', function() {
373
+ const proofIdInput = document.getElementById('proofIdInput');
374
+ const fetchProofBtn = document.getElementById('fetchProofBtn');
375
+ const loading = document.getElementById('loading');
376
+ const errorMessage = document.getElementById('errorMessage');
377
+ const proofContainer = document.getElementById('proofContainer');
378
+ const proofImage = document.getElementById('proofImage');
379
+ const proofIdDisplay = document.getElementById('proofIdDisplay');
380
+ const priceTagsContainer = document.getElementById('priceTagsContainer');
381
+
382
+ fetchProofBtn.addEventListener('click', fetchProofData);
383
+
384
+ proofIdInput.addEventListener('keypress', function(e) {
385
+ if (e.key === 'Enter') {
386
+ fetchProofData();
387
+ }
388
+ });
389
+
390
+ async function fetchProofData() {
391
+ const proofId = proofIdInput.value.trim();
392
+
393
+ // Validate input
394
+ if (!proofId || isNaN(proofId) || proofId <= 0) {
395
+ showError('Please enter a valid positive integer for the proof ID.');
396
+ return;
397
+ }
398
+
399
+ // Clear previous results and errors
400
+ clearResults();
401
+ hideError();
402
+
403
+ // Show loading
404
+ showLoading();
405
+
406
+ try {
407
+ // Fetch proof data
408
+ const proofResponse = await axios.get(`https://prices.openfoodfacts.org/api/v1/proofs/${proofId}`);
409
+
410
+ // Check if the proof type is PRICE_TAG
411
+ if (proofResponse.data.type !== 'PRICE_TAG') {
412
+ showError('The provided proof is not a price tag.');
413
+ return;
414
+ }
415
+
416
+ // Display proof information
417
+ displayProof(proofResponse.data);
418
+
419
+ // Fetch price tags
420
+ const priceTagsResponse = await axios.get(`https://prices.openfoodfacts.org/api/v1/price_tags?proof_id=${proofId}`);
421
+
422
+ // Display price tags
423
+ displayPriceTags(priceTagsResponse.data.items);
424
+
425
+ } catch (error) {
426
+ console.error('Error fetching data:', error);
427
+ showError('Failed to fetch data. Please check the proof ID and try again.');
428
+ } finally {
429
+ hideLoading();
430
+ }
431
+ }
432
+
433
+ function displayProof(proofData) {
434
+ // Set proof ID
435
+ proofIdDisplay.textContent = `Proof ID: ${proofData.id}`;
436
+
437
+ // Set proof image
438
+ if (proofData.image_thumb_path) {
439
+ proofImage.src = `https://prices.openfoodfacts.org/img/${proofData.image_thumb_path}`;
440
+ proofImage.alt = `Proof ${proofData.id} image`;
441
+ } else {
442
+ proofImage.src = '';
443
+ proofImage.alt = 'No proof image available';
444
+ }
445
+
446
+ // Show proof container
447
+ proofContainer.classList.add('active');
448
+ }
449
+
450
+ function displayPriceTags(priceTags) {
451
+ if (!priceTags || priceTags.length === 0) {
452
+ priceTagsContainer.innerHTML = '<div class="no-price-tags">No price tags found for this proof.</div>';
453
+ return;
454
+ }
455
+
456
+ priceTagsContainer.innerHTML = '';
457
+
458
+ priceTags.forEach(tag => {
459
+ const tagCard = document.createElement('div');
460
+ tagCard.className = 'price-tag-card';
461
+
462
+ let imageUrl = '';
463
+ if (tag.image_path) {
464
+ imageUrl = `https://prices.openfoodfacts.org/img/${tag.image_path}`;
465
+ }
466
+
467
+ tagCard.innerHTML = `
468
+ <div class="price-tag-image-container">
469
+ ${imageUrl ? `<img src="${imageUrl}" class="price-tag-image" alt="Price tag ${tag.id}">` : '<div class="price-tag-image" style="display: flex; justify-content: center; align-items: center; color: #999;">No image</div>'}
470
+ </div>
471
+ <div class="price-tag-info">
472
+ <div class="price-tag-id">Price Tag ID: ${tag.id}</div>
473
+ <div class="price-tag-details">
474
+ ${tag.barcode ? `<div class="detail-row"><span class="detail-label">Barcode:</span><span class="detail-value">${tag.barcode}</span></div>` : ''}
475
+ ${tag.price ? `<div class="detail-row"><span class="detail-label">Price:</span><span class="detail-value">${tag.price}</span></div>` : ''}
476
+ ${tag.currency ? `<div class="detail-row"><span class="detail-label">Currency:</span><span class="detail-value">${tag.currency}</span></div>` : ''}
477
+ ${tag.product_name ? `<div class="detail-row"><span class="detail-label">Product:</span><span class="detail-value">${tag.product_name}</span></div>` : ''}
478
+ </div>
479
+ </div>
480
+ `;
481
+
482
+ priceTagsContainer.appendChild(tagCard);
483
+ });
484
+ }
485
+
486
+ function showLoading() {
487
+ loading.classList.add('active');
488
+ fetchProofBtn.disabled = true;
489
+ }
490
+
491
+ function hideLoading() {
492
+ loading.classList.remove('active');
493
+ fetchProofBtn.disabled = false;
494
+ }
495
+
496
+ function showError(message) {
497
+ errorMessage.textContent = message;
498
+ errorMessage.classList.add('active');
499
+ }
500
+
501
+ function hideError() {
502
+ errorMessage.classList.remove('active');
503
+ }
504
+
505
+ function clearResults() {
506
+ proofContainer.classList.remove('active');
507
+ proofImage.src = '';
508
+ proofIdDisplay.textContent = '';
509
+ priceTagsContainer.innerHTML = '';
510
+ }
511
+ });
512
+ </script>
513
+ </body>
514
+ </html>