Lashtw commited on
Commit
72482ec
·
verified ·
1 Parent(s): 0a14af4

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +40 -36
index.html CHANGED
@@ -412,11 +412,7 @@
412
  </div>
413
  </div>
414
 
415
- <!-- 舊的提示功能區塊 (保留但預設隱藏,新版已整合到下方) -->
416
- <div id="hint-section" class="w-full max-w-md mt-4 text-center hidden">
417
- <!-- 已整合到下方 -->
418
- <p id="hint-display" class="mt-2 text-gray-600 font-semibold h-6"></p>
419
- </div>
420
 
421
  <!-- [第三步] 插入手寫板介面 (取代舊的 input form) -->
422
  <div id="quiz-container" class="w-full max-w-md mt-4">
@@ -451,9 +447,13 @@
451
 
452
  <button id="submit-answer-btn" class="w-full bg-indigo-500 text-white p-4 rounded-xl text-xl font-bold hover:bg-indigo-600 transition-colors">提交答案</button>
453
 
454
- <button id="hint-btn" class="w-full bg-yellow-500 text-white p-3 rounded-xl text-lg font-bold hover:bg-yellow-600 transition-colors hidden">顯示提示</button>
 
 
 
 
455
  </div>
456
- <div id="feedback-display" class="text-center mt-3 h-6 font-semibold"></div>
457
  </div>
458
 
459
  <!-- 答錯確認區塊 (間隔重複模式使用) -->
@@ -897,7 +897,7 @@
897
  if (part === '...') {
898
  // 插入省略號文字
899
  const ellipsis = document.createElement('div');
900
- ellipsis.className = 'text-3xl font-bold text-gray-400 mx-1 select-none';
901
  ellipsis.textContent = '...';
902
  wrapper.appendChild(ellipsis);
903
  // 省略號不佔用 hwInstances 索引
@@ -905,16 +905,11 @@
905
  // 建立 Canvas 容器
906
  const container = document.createElement('div');
907
  container.className = 'canvas-container relative';
908
- // 根據字數調整寬度,如果只有一個字就全寬,多個字則均分但有最小寬度
909
- const wordCount = structure.filter(s => s !== '...').length;
910
- if (wordCount === 1) {
911
- container.style.width = '100%';
912
- } else {
913
- // [修改] 調整最小寬度為 220px,以容納較長的單字
914
- container.style.flex = '1 1 220px'; // Flex grow, shrink, basis
915
- container.style.minWidth = '220px';
916
- }
917
  container.style.height = '250px';
 
918
 
919
  // 建立 Canvas
920
  const canvas = document.createElement('canvas');
@@ -1101,18 +1096,32 @@
1101
  };
1102
  }
1103
 
1104
- // [修改] 清空當前畫布
1105
- function clearCanvas() {
1106
- const inst = hwInstances[activeHwIndex];
1107
- if(!inst || !inst.ctx) return;
1108
-
1109
- inst.ctx.fillStyle = '#ffffff';
1110
- inst.ctx.fillRect(0, 0, inst.element.width, inst.element.height);
1111
-
1112
- inst.strokes = [];
1113
- // 如果只有一個畫布,也清空輸入框,多個畫布時不清空輸入框以免誤刪
1114
- if (hwInstances.length === 1) {
 
 
1115
  answerInput.value = '';
 
 
 
 
 
 
 
 
 
 
 
 
1116
  }
1117
  candidateBar.innerHTML = '';
1118
  candidateBar.classList.add('hidden');
@@ -1797,8 +1806,8 @@
1797
  feedbackDisplay.classList.add('text-green-600');
1798
  triggerConfetti();
1799
 
1800
- // [修正] 使用新的清空函式
1801
- clearCanvas();
1802
 
1803
  if (!flashcardContainer.classList.contains('flipped')) {
1804
  flashcardContainer.classList.add('flipped');
@@ -1900,7 +1909,7 @@
1900
  const reinsertIndex = Math.min(quizQueue.length, 3);
1901
  quizQueue.splice(reinsertIndex, 0, wrongCard);
1902
  // [修正] 清空手寫板
1903
- clearCanvas();
1904
  displayCard();
1905
  });
1906
 
@@ -1934,11 +1943,6 @@
1934
  endSpeedChallenge();
1935
  }
1936
  };
1937
-
1938
- // ... (rest of the code remains the same)
1939
- // 為了節省篇幅,後續程式碼保持不變
1940
- // 包括 speakWord, initializeApp 等
1941
- // ...
1942
 
1943
  const endSpeedChallenge = () => {
1944
  clearInterval(timerInterval);
 
412
  </div>
413
  </div>
414
 
415
+ <!-- [修正] 移除舊的隱藏提示區塊,將 hint-display 移至下方 quiz-container 內 -->
 
 
 
 
416
 
417
  <!-- [第三步] 插入手寫板介面 (取代舊的 input form) -->
418
  <div id="quiz-container" class="w-full max-w-md mt-4">
 
447
 
448
  <button id="submit-answer-btn" class="w-full bg-indigo-500 text-white p-4 rounded-xl text-xl font-bold hover:bg-indigo-600 transition-colors">提交答案</button>
449
 
450
+ <div class="flex flex-col items-center gap-2">
451
+ <button id="hint-btn" class="w-full bg-yellow-500 text-white p-3 rounded-xl text-lg font-bold hover:bg-yellow-600 transition-colors hidden">顯示提示</button>
452
+ <!-- [修正] hint-display 移到這裡,確保它在可見區域 -->
453
+ <p id="hint-display" class="text-gray-600 font-semibold min-h-[1.5rem]"></p>
454
+ </div>
455
  </div>
456
+ <div id="feedback-display" class="text-center mt-1 h-6 font-semibold"></div>
457
  </div>
458
 
459
  <!-- 答錯確認區塊 (間隔重複模式使用) -->
 
897
  if (part === '...') {
898
  // 插入省略號文字
899
  const ellipsis = document.createElement('div');
900
+ ellipsis.className = 'text-3xl font-bold text-gray-400 mx-1 select-none w-full text-center py-2'; // [修改] 加寬與置中
901
  ellipsis.textContent = '...';
902
  wrapper.appendChild(ellipsis);
903
  // 省略號不佔用 hwInstances 索引
 
905
  // 建立 Canvas 容器
906
  const container = document.createElement('div');
907
  container.className = 'canvas-container relative';
908
+
909
+ // [修改] 強制設定寬度為 100%,讓多個畫布垂直堆疊,保持最大書寫空間
910
+ container.style.width = '100%';
 
 
 
 
 
 
911
  container.style.height = '250px';
912
+ container.style.marginBottom = '10px'; // 畫布之間增加一點間距
913
 
914
  // 建立 Canvas
915
  const canvas = document.createElement('canvas');
 
1096
  };
1097
  }
1098
 
1099
+ // [修改] 清空畫布 (支援清除全部)
1100
+ function clearCanvas(forceClearAll = false) {
1101
+ // 如果是按鈕點擊事件 (Event) 或者 forceClearAll 為 true,則清除所有
1102
+ const shouldClearAll = (forceClearAll === true) || (forceClearAll instanceof Event);
1103
+
1104
+ if (shouldClearAll) {
1105
+ hwInstances.forEach(inst => {
1106
+ if (inst.ctx) {
1107
+ inst.ctx.fillStyle = '#ffffff';
1108
+ inst.ctx.fillRect(0, 0, inst.element.width, inst.element.height);
1109
+ inst.strokes = [];
1110
+ }
1111
+ });
1112
  answerInput.value = '';
1113
+ } else {
1114
+ // 只清除當前 (保留給特定邏輯使用)
1115
+ const inst = hwInstances[activeHwIndex];
1116
+ if(!inst || !inst.ctx) return;
1117
+
1118
+ inst.ctx.fillStyle = '#ffffff';
1119
+ inst.ctx.fillRect(0, 0, inst.element.width, inst.element.height);
1120
+ inst.strokes = [];
1121
+
1122
+ if (hwInstances.length === 1) {
1123
+ answerInput.value = '';
1124
+ }
1125
  }
1126
  candidateBar.innerHTML = '';
1127
  candidateBar.classList.add('hidden');
 
1806
  feedbackDisplay.classList.add('text-green-600');
1807
  triggerConfetti();
1808
 
1809
+ // [修正] 答對時清除所有畫布 (傳入 true)
1810
+ clearCanvas(true);
1811
 
1812
  if (!flashcardContainer.classList.contains('flipped')) {
1813
  flashcardContainer.classList.add('flipped');
 
1909
  const reinsertIndex = Math.min(quizQueue.length, 3);
1910
  quizQueue.splice(reinsertIndex, 0, wrongCard);
1911
  // [修正] 清空手寫板
1912
+ clearCanvas(true);
1913
  displayCard();
1914
  });
1915
 
 
1943
  endSpeedChallenge();
1944
  }
1945
  };
 
 
 
 
 
1946
 
1947
  const endSpeedChallenge = () => {
1948
  clearInterval(timerInterval);