KennyOry commited on
Commit
e5f4ac5
·
verified ·
1 Parent(s): aef6603

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +76 -37
templates/index.html CHANGED
@@ -525,7 +525,27 @@
525
  .step-loader .dot:nth-child(2) {
526
  animation-delay: -0.16s;
527
  }
528
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  @keyframes loader-bounce {
530
  0%, 80%, 100% {
531
  transform: scale(0);
@@ -799,25 +819,43 @@
799
  `;
800
  chatContainer.appendChild(messageDiv);
801
  chatContainer.scrollTop = chatContainer.scrollHeight;
 
 
802
  return messageDiv;
803
  }
804
  // Форматирование контента
805
  function formatContent(content) {
806
- // Заменяем разделы на стилизованные блоки
807
- content = content.replace(/\*\*Проблема:\*\*/g,
808
- '<div class="problem-text">Проблема:</div>');
809
- content = content.replace(/\*\*Решение:\*\*/g,
810
- '<div class="solution-text">Решение:</div>');
811
- content = content.replace(/\*\*Примечания:\*\*/g,
812
- '<div class="notes-text">Примечания:</div>');
813
- content = content.replace(/\*\*Источники:\*\*/g,
814
- '<div class="sources-title">Источники:</div>');
815
- content = content.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
816
- // Обработка ссылок на источники
817
- content = content.replace(/\[([^\]]+)\]\(([^)]+)\)/g,
818
- '<a href="$2" target="_blank" class="source-link">$1</a>');
819
- return content;
 
 
 
 
 
 
 
 
 
 
 
 
820
  }
 
 
 
 
821
  // Добавление ссылок на источники
822
  function addSourceLinks() {
823
  if (!currentBotMessage || currentSources.length === 0) return;
@@ -849,30 +887,31 @@
849
  }
850
  // Показ деталей источника
851
  function showSourceDetails(sourceIndex) {
852
- const source = currentSources[sourceIndex];
853
- if (!source) return;
854
- // Создаем модальное окно
855
- const modal = document.createElement('div');
856
- modal.className = 'source-modal';
857
- modal.innerHTML = `
858
- <div class="source-modal-content">
859
- <div class="source-modal-header">
860
- <h3>${source.title || 'Источник информации'}</h3>
861
- <button class="source-close">&times;</button>
862
- </div>
863
- <div class="source-modal-body">
864
- <p><strong>URL:</strong> <a href="${source.url}" target="_blank">${source.url}</a></p>
865
- <div class="mt-3">
866
- <h4>Содержимое:</h4>
867
- <div class="source-content">${source.content ? escapeHtml(source.content) : 'Содержимое недоступно'}</div>
868
- </div>
869
- </div>
870
- <div class="source-modal-footer">
871
- <button id="open-source" class="btn btn-primary">Откры��ь источник</button>
872
- <button id="close-modal" class="btn btn-secondary">Закрыть</button>
873
  </div>
874
  </div>
875
- `;
 
 
 
 
 
 
876
  document.body.appendChild(modal);
877
  // Обработчики событий
878
  modal.querySelector('.source-close').addEventListener('click', () => modal.remove());
 
525
  .step-loader .dot:nth-child(2) {
526
  animation-delay: -0.16s;
527
  }
528
+
529
+ .source-ref {
530
+ display: inline-block;
531
+ background: rgba(67, 97, 238, 0.15);
532
+ color: var(--primary);
533
+ width: 24px;
534
+ height: 24px;
535
+ border-radius: 50%;
536
+ text-align: center;
537
+ line-height: 24px;
538
+ font-size: 12px;
539
+ cursor: pointer;
540
+ margin: 0 2px;
541
+ vertical-align: super;
542
+ transition: var(--transition);
543
+ }
544
+ .source-ref:hover {
545
+ background: rgba(67, 97, 238, 0.25);
546
+ transform: scale(1.1);
547
+ }
548
+
549
  @keyframes loader-bounce {
550
  0%, 80%, 100% {
551
  transform: scale(0);
 
819
  `;
820
  chatContainer.appendChild(messageDiv);
821
  chatContainer.scrollTop = chatContainer.scrollHeight;
822
+ setupSourceReferences(); // Добавьте эту строку
823
+
824
  return messageDiv;
825
  }
826
  // Форматирование контента
827
  function formatContent(content) {
828
+ // Заменяем разделы на стилизованные блоки
829
+ content = content.replace(/\*\*Проблема:\*\*/g,
830
+ '<div class="problem-text">Проблема:</div>');
831
+ content = content.replace(/\*\*Решение:\*\*/g,
832
+ '<div class="solution-text">Решение:</div>');
833
+ content = content.replace(/\*\*Примечания:\*\*/g,
834
+ '<div class="notes-text">Примечания:</div>');
835
+ content = content.replace(/\*\*Источники:\*\*/g,
836
+ '<div class="sources-title">Источники:</div>');
837
+ content = content.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
838
+
839
+ // Обработка ссылок на источники в тексте [1]
840
+ content = content.replace(/\[(\d+)\]/g,
841
+ '<sup class="source-ref" data-source="$1">[$1]</sup>');
842
+
843
+ return content;
844
+ }
845
+
846
+ // Добавьте этот код после функции formatContent
847
+ function setupSourceReferences() {
848
+ document.querySelectorAll('.source-ref').forEach(ref => {
849
+ ref.addEventListener('click', function(e) {
850
+ e.preventDefault();
851
+ const sourceIndex = parseInt(this.dataset.source) - 1;
852
+ if (currentSources[sourceIndex]) {
853
+ showSourceDetails(sourceIndex);
854
  }
855
+ });
856
+ ref.title = "Нажмите для просмотра источника";
857
+ });
858
+ }
859
  // Добавление ссылок на источники
860
  function addSourceLinks() {
861
  if (!currentBotMessage || currentSources.length === 0) return;
 
887
  }
888
  // Показ деталей источника
889
  function showSourceDetails(sourceIndex) {
890
+ const source = currentSources[sourceIndex];
891
+ if (!source) return;
892
+
893
+ const modal = document.createElement('div');
894
+ modal.className = 'source-modal';
895
+ modal.innerHTML = `
896
+ <div class="source-modal-content">
897
+ <div class="source-modal-header">
898
+ <h3>${source.title || 'Источник информации'}</h3>
899
+ <button class="source-close">&times;</button>
900
+ </div>
901
+ <div class="source-modal-body">
902
+ <p><strong>URL:</strong> <a href="${source.url}" target="_blank">${source.url}</a></p>
903
+ <div class="mt-3">
904
+ <h4>Содержимое:</h4>
905
+ <div class="source-content">${source.content ? escapeHtml(source.content) : 'Содержимое недоступно'}</div>
 
 
 
 
 
906
  </div>
907
  </div>
908
+ <div class="source-modal-footer">
909
+ <button id="open-source" class="btn btn-primary">Открыть источник</button>
910
+ <button id="close-modal" class="btn btn-secondary">Закрыть</button>
911
+ </div>
912
+ </div>
913
+ `;
914
+
915
  document.body.appendChild(modal);
916
  // Обработчики событий
917
  modal.querySelector('.source-close').addEventListener('click', () => modal.remove());