Docfile commited on
Commit
fb35fbe
·
verified ·
1 Parent(s): 1c19a65

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +84 -3
templates/index.html CHANGED
@@ -366,8 +366,7 @@
366
  // Process analysis
367
  const analysisText = data.analysis;
368
 
369
- // Split content based on language sections (this is a simplification)
370
- // In real implementation, you would need to parse properly based on your API response
371
  const [spanishPart, frenchPart] = splitAnalysis(analysisText);
372
 
373
  // Display preview based on file type
@@ -422,4 +421,86 @@
422
  tabContentFrench.classList.add('hidden');
423
  });
424
 
425
- tabFrench.addEventListener('click', ()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  // Process analysis
367
  const analysisText = data.analysis;
368
 
369
+ // Split content based on language sections
 
370
  const [spanishPart, frenchPart] = splitAnalysis(analysisText);
371
 
372
  // Display preview based on file type
 
421
  tabContentFrench.classList.add('hidden');
422
  });
423
 
424
+ tabFrench.addEventListener('click', () => {
425
+ tabFrench.classList.remove('bg-gray-200', 'text-gray-700');
426
+ tabFrench.classList.add('bg-indigo-600', 'text-white');
427
+ tabSpanish.classList.remove('bg-indigo-600', 'text-white');
428
+ tabSpanish.classList.add('bg-gray-200', 'text-gray-700');
429
+
430
+ tabContentFrench.classList.remove('hidden');
431
+ tabContentSpanish.classList.add('hidden');
432
+ });
433
+
434
+ // Download functionality
435
+ downloadBtn.addEventListener('click', () => {
436
+ const activeTab = document.querySelector('.tab-btn.bg-indigo-600');
437
+ let content, filename;
438
+
439
+ if (activeTab.id === 'tab-spanish') {
440
+ content = spanishContent.innerHTML;
441
+ filename = 'analysis_spanish.html';
442
+ } else {
443
+ content = frenchContent.innerHTML;
444
+ filename = 'analysis_french.html';
445
+ }
446
+
447
+ // Create a simple HTML document
448
+ const html = `
449
+ <!DOCTYPE html>
450
+ <html>
451
+ <head>
452
+ <meta charset="UTF-8">
453
+ <title>Analyse - Mariam Espagnol</title>
454
+ <style>
455
+ body { font-family: Arial, sans-serif; line-height: 1.6; max-width: 800px; margin: 0 auto; padding: 20px; }
456
+ h1, h2, h3 { color: #4338ca; }
457
+ </style>
458
+ </head>
459
+ <body>
460
+ <h1>Analyse de document - Mariam Espagnol</h1>
461
+ <div>${content}</div>
462
+ </body>
463
+ </html>
464
+ `;
465
+
466
+ const blob = new Blob([html], { type: 'text/html' });
467
+ const url = URL.createObjectURL(blob);
468
+ const a = document.createElement('a');
469
+ a.href = url;
470
+ a.download = filename;
471
+ document.body.appendChild(a);
472
+ a.click();
473
+ document.body.removeChild(a);
474
+ URL.revokeObjectURL(url);
475
+ });
476
+
477
+ // Helper functions
478
+ function splitAnalysis(text) {
479
+ // This is a simplified split - in real implementation,
480
+ // you would need to parse based on your specific response format
481
+
482
+ // For demonstration purposes, let's assume the text has a clear
483
+ // Spanish part first, then French part marked by "TRADUCCIÓN FRANCESA" or similar
484
+ const parts = text.split(/TRADUCCIÓN FRANCESA|TRADUCTION FRANÇAISE/i);
485
+
486
+ if (parts.length >= 2) {
487
+ return [parts[0].trim(), parts[1].trim()];
488
+ }
489
+
490
+ // If no clear separation, attempt a rough half-split (not ideal but fallback)
491
+ const midPoint = Math.floor(text.length / 2);
492
+ return [text.substring(0, midPoint).trim(), text.substring(midPoint).trim()];
493
+ }
494
+
495
+ function formatText(text) {
496
+ // Basic formatting for better display
497
+ return text
498
+ .replace(/\n\n/g, '</p><p>')
499
+ .replace(/\n/g, '<br>')
500
+ .replace(/^/, '<p>')
501
+ .replace(/$/, '</p>');
502
+ }
503
+ });
504
+ </script>
505
+ </body>
506
+ </html>