hisaruki commited on
Commit
9a2861e
·
1 Parent(s): bcccbd1

要約削除機能実装

Browse files
Files changed (1) hide show
  1. gemini.js +25 -4
gemini.js CHANGED
@@ -933,18 +933,25 @@ function addTextarea(ul, content) {
933
  summaryInput.className = 'form-control mt-2 summery-text';
934
  summaryInput.placeholder = '要約';
935
  summaryInput.rows = 3;
 
 
 
 
 
 
 
936
 
937
  // 要約取得ボタンの作成
938
  const summaryButton = document.createElement('button');
939
  summaryButton.textContent = '要約を取得';
940
- summaryButton.className = 'btn btn-secondary mt-2';
941
  summaryButton.onclick = async () => {
942
  summaryButton.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...';
943
  summaryButton.disabled = true;
944
  try {
945
- const summary = await summerize(textarea.value);
946
  summaryInput.value = summary;
947
- summeries[textarea.value] = summary;
948
  updateTokenCount(true);
949
  } finally {
950
  summaryButton.innerHTML = '要約を取得';
@@ -952,10 +959,24 @@ function addTextarea(ul, content) {
952
  }
953
  };
954
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
955
  // 要素の追加
956
  li.appendChild(textarea);
957
  li.appendChild(summaryInput);
958
- li.appendChild(summaryButton);
959
  ul.appendChild(li);
960
  }
961
 
 
933
  summaryInput.className = 'form-control mt-2 summery-text';
934
  summaryInput.placeholder = '要約';
935
  summaryInput.rows = 3;
936
+ if(summeries[content]) {
937
+ summaryInput.value = summeries[content];
938
+ }
939
+
940
+ // ボタン用のコンテナ作成
941
+ const buttonContainer = document.createElement('div');
942
+ buttonContainer.className = 'mt-2';
943
 
944
  // 要約取得ボタンの作成
945
  const summaryButton = document.createElement('button');
946
  summaryButton.textContent = '要約を取得';
947
+ summaryButton.className = 'btn btn-secondary me-2';
948
  summaryButton.onclick = async () => {
949
  summaryButton.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...';
950
  summaryButton.disabled = true;
951
  try {
952
+ const summary = await summerize(content);
953
  summaryInput.value = summary;
954
+ summeries[content] = summary;
955
  updateTokenCount(true);
956
  } finally {
957
  summaryButton.innerHTML = '要約を取得';
 
959
  }
960
  };
961
 
962
+ // 要約削除ボタンの作成
963
+ const deleteSummaryButton = document.createElement('button');
964
+ deleteSummaryButton.textContent = '要約を削除';
965
+ deleteSummaryButton.className = 'btn btn-danger';
966
+ deleteSummaryButton.onclick = () => {
967
+ summaryInput.value = '';
968
+ delete summeries[content];
969
+ updateTokenCount(true);
970
+ };
971
+
972
+ // ボタンをコンテナに追加
973
+ buttonContainer.appendChild(summaryButton);
974
+ buttonContainer.appendChild(deleteSummaryButton);
975
+
976
  // 要素の追加
977
  li.appendChild(textarea);
978
  li.appendChild(summaryInput);
979
+ li.appendChild(buttonContainer);
980
  ul.appendChild(li);
981
  }
982