Spaces:
Running
Running
Update index.html
Browse files- index.html +50 -20
index.html
CHANGED
|
@@ -180,7 +180,10 @@
|
|
| 180 |
</div>
|
| 181 |
</div>
|
| 182 |
|
| 183 |
-
<
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
<!-- 單字列表容器 -->
|
| 186 |
<div id="word-list-container" class="space-y-2 max-h-[50vh] overflow-y-auto pr-2">
|
|
@@ -335,6 +338,18 @@
|
|
| 335 |
</div>
|
| 336 |
</div>
|
| 337 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
|
| 339 |
<footer class="fixed bottom-4 right-4 text-xs text-gray-500 text-right z-50">
|
| 340 |
<p>遊戲設計者:新竹縣精華國中藍星宇</p>
|
|
@@ -362,6 +377,7 @@
|
|
| 362 |
const backToModesFromManageBtn = document.getElementById('back-to-modes-from-manage-btn');
|
| 363 |
const addWordsSection = document.getElementById('add-words-section');
|
| 364 |
const showAddWordsSectionBtn = document.getElementById('show-add-words-section-btn');
|
|
|
|
| 365 |
const englishWordsInput = document.getElementById('english-words');
|
| 366 |
const chineseExplanationsInput = document.getElementById('chinese-explanations');
|
| 367 |
const errorMessage = document.getElementById('error-message');
|
|
@@ -425,6 +441,9 @@
|
|
| 425 |
const copyLinkBtn = document.getElementById('copy-link-btn');
|
| 426 |
const copyFeedback = document.getElementById('copy-feedback');
|
| 427 |
const closeShareModalBtn = document.getElementById('close-share-modal-btn');
|
|
|
|
|
|
|
|
|
|
| 428 |
|
| 429 |
// 應用程式狀態
|
| 430 |
let words = [];
|
|
@@ -480,10 +499,8 @@
|
|
| 480 |
// --- 單字管理功能 ---
|
| 481 |
const renderWordList = () => {
|
| 482 |
wordListContainer.innerHTML = '';
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
sortedWords.forEach((word, index) => {
|
| 486 |
-
const originalIndex = words.findIndex(w => w.english === word.english && w.chinese === word.chinese);
|
| 487 |
const item = document.createElement('div');
|
| 488 |
item.className = 'list-item p-3 bg-gray-100 rounded-lg flex items-center justify-between';
|
| 489 |
item.innerHTML = `
|
|
@@ -493,8 +510,8 @@
|
|
| 493 |
<p class="text-gray-600 ml-4">${word.chinese}</p>
|
| 494 |
</div>
|
| 495 |
<div class="flex gap-2">
|
| 496 |
-
<button data-index="${
|
| 497 |
-
<button data-index="${
|
| 498 |
</div>
|
| 499 |
`;
|
| 500 |
wordListContainer.appendChild(item);
|
|
@@ -511,15 +528,13 @@
|
|
| 511 |
editChineseInput.value = words[index].chinese;
|
| 512 |
editWordModal.classList.remove('hidden');
|
| 513 |
} else if (button.classList.contains('delete-btn')) {
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
}, 300);
|
| 522 |
-
}
|
| 523 |
}
|
| 524 |
});
|
| 525 |
|
|
@@ -671,12 +686,12 @@
|
|
| 671 |
|
| 672 |
const start = parseInt(startRangeInput.value, 10);
|
| 673 |
const end = parseInt(endRangeInput.value, 10);
|
| 674 |
-
let sortedWords = [...words].sort((a,b) => a.english.localeCompare(b.english));
|
| 675 |
|
| 676 |
-
|
| 677 |
-
|
|
|
|
| 678 |
} else {
|
| 679 |
-
wordsForCurrentMode =
|
| 680 |
}
|
| 681 |
|
| 682 |
if (wordsForCurrentMode.length === 0) {
|
|
@@ -964,6 +979,21 @@
|
|
| 964 |
shareModal.classList.add('hidden');
|
| 965 |
});
|
| 966 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 967 |
// --- 應用程式初始化 ---
|
| 968 |
const initializeApp = () => {
|
| 969 |
const urlParams = new URLSearchParams(window.location.search);
|
|
|
|
| 180 |
</div>
|
| 181 |
</div>
|
| 182 |
|
| 183 |
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 mb-4">
|
| 184 |
+
<button id="show-add-words-section-btn" class="w-full bg-green-500 text-white font-bold py-3 rounded-full hover:bg-green-600 transition-all">+ 新增單字</button>
|
| 185 |
+
<button id="clear-all-words-btn" class="w-full bg-red-600 text-white font-bold py-3 rounded-full hover:bg-red-700 transition-all">🗑️ 清除所有單字</button>
|
| 186 |
+
</div>
|
| 187 |
|
| 188 |
<!-- 單字列表容器 -->
|
| 189 |
<div id="word-list-container" class="space-y-2 max-h-[50vh] overflow-y-auto pr-2">
|
|
|
|
| 338 |
</div>
|
| 339 |
</div>
|
| 340 |
</div>
|
| 341 |
+
|
| 342 |
+
<!-- 清除確認 Modal -->
|
| 343 |
+
<div id="confirm-clear-modal" class="hidden fixed inset-0 bg-gray-900 bg-opacity-75 flex items-center justify-center z-50 p-4">
|
| 344 |
+
<div class="bg-white p-8 rounded-2xl shadow-xl w-full max-w-sm">
|
| 345 |
+
<h3 class="text-2xl font-bold mb-4 text-gray-800">確認操作</h3>
|
| 346 |
+
<p class="text-gray-600 mb-6">您確定要清除所有單字嗎?此操作無法復原。</p>
|
| 347 |
+
<div class="flex justify-end gap-4 mt-6">
|
| 348 |
+
<button type="button" id="cancel-clear-btn" class="px-6 py-2 bg-gray-200 text-gray-800 rounded-lg hover:bg-gray-300 transition-colors">取消</button>
|
| 349 |
+
<button type="button" id="confirm-clear-btn" class="px-6 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors">確認清除</button>
|
| 350 |
+
</div>
|
| 351 |
+
</div>
|
| 352 |
+
</div>
|
| 353 |
|
| 354 |
<footer class="fixed bottom-4 right-4 text-xs text-gray-500 text-right z-50">
|
| 355 |
<p>遊戲設計者:新竹縣精華國中藍星宇</p>
|
|
|
|
| 377 |
const backToModesFromManageBtn = document.getElementById('back-to-modes-from-manage-btn');
|
| 378 |
const addWordsSection = document.getElementById('add-words-section');
|
| 379 |
const showAddWordsSectionBtn = document.getElementById('show-add-words-section-btn');
|
| 380 |
+
const clearAllWordsBtn = document.getElementById('clear-all-words-btn');
|
| 381 |
const englishWordsInput = document.getElementById('english-words');
|
| 382 |
const chineseExplanationsInput = document.getElementById('chinese-explanations');
|
| 383 |
const errorMessage = document.getElementById('error-message');
|
|
|
|
| 441 |
const copyLinkBtn = document.getElementById('copy-link-btn');
|
| 442 |
const copyFeedback = document.getElementById('copy-feedback');
|
| 443 |
const closeShareModalBtn = document.getElementById('close-share-modal-btn');
|
| 444 |
+
const confirmClearModal = document.getElementById('confirm-clear-modal');
|
| 445 |
+
const cancelClearBtn = document.getElementById('cancel-clear-btn');
|
| 446 |
+
const confirmClearBtn = document.getElementById('confirm-clear-btn');
|
| 447 |
|
| 448 |
// 應用程式狀態
|
| 449 |
let words = [];
|
|
|
|
| 499 |
// --- 單字管理功能 ---
|
| 500 |
const renderWordList = () => {
|
| 501 |
wordListContainer.innerHTML = '';
|
| 502 |
+
// 移除字母排序,直接按照陣列順序渲染
|
| 503 |
+
words.forEach((word, index) => {
|
|
|
|
|
|
|
| 504 |
const item = document.createElement('div');
|
| 505 |
item.className = 'list-item p-3 bg-gray-100 rounded-lg flex items-center justify-between';
|
| 506 |
item.innerHTML = `
|
|
|
|
| 510 |
<p class="text-gray-600 ml-4">${word.chinese}</p>
|
| 511 |
</div>
|
| 512 |
<div class="flex gap-2">
|
| 513 |
+
<button data-index="${index}" class="edit-btn p-2 text-blue-500 hover:bg-blue-100 rounded-full"><svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z" /><path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd" /></svg></button>
|
| 514 |
+
<button data-index="${index}" class="delete-btn p-2 text-red-500 hover:bg-red-100 rounded-full"><svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm4 0a1 1 0 012 0v6a1 1 0 11-2 0V8z" clip-rule="evenodd" /></svg></button>
|
| 515 |
</div>
|
| 516 |
`;
|
| 517 |
wordListContainer.appendChild(item);
|
|
|
|
| 528 |
editChineseInput.value = words[index].chinese;
|
| 529 |
editWordModal.classList.remove('hidden');
|
| 530 |
} else if (button.classList.contains('delete-btn')) {
|
| 531 |
+
const itemElement = button.closest('.list-item');
|
| 532 |
+
itemElement.classList.add('removing');
|
| 533 |
+
setTimeout(() => {
|
| 534 |
+
words.splice(index, 1);
|
| 535 |
+
saveWordsToStorage();
|
| 536 |
+
renderWordList();
|
| 537 |
+
}, 300);
|
|
|
|
|
|
|
| 538 |
}
|
| 539 |
});
|
| 540 |
|
|
|
|
| 686 |
|
| 687 |
const start = parseInt(startRangeInput.value, 10);
|
| 688 |
const end = parseInt(endRangeInput.value, 10);
|
|
|
|
| 689 |
|
| 690 |
+
// 學習時,使用新增順序
|
| 691 |
+
if (!isNaN(start) && !isNaN(end) && start > 0 && end >= start && end <= words.length) {
|
| 692 |
+
wordsForCurrentMode = words.slice(start - 1, end);
|
| 693 |
} else {
|
| 694 |
+
wordsForCurrentMode = [...words];
|
| 695 |
}
|
| 696 |
|
| 697 |
if (wordsForCurrentMode.length === 0) {
|
|
|
|
| 979 |
shareModal.classList.add('hidden');
|
| 980 |
});
|
| 981 |
|
| 982 |
+
clearAllWordsBtn.addEventListener('click', () => {
|
| 983 |
+
confirmClearModal.classList.remove('hidden');
|
| 984 |
+
});
|
| 985 |
+
|
| 986 |
+
cancelClearBtn.addEventListener('click', () => {
|
| 987 |
+
confirmClearModal.classList.add('hidden');
|
| 988 |
+
});
|
| 989 |
+
|
| 990 |
+
confirmClearBtn.addEventListener('click', () => {
|
| 991 |
+
words = [];
|
| 992 |
+
saveWordsToStorage();
|
| 993 |
+
renderWordList();
|
| 994 |
+
confirmClearModal.classList.add('hidden');
|
| 995 |
+
});
|
| 996 |
+
|
| 997 |
// --- 應用程式初始化 ---
|
| 998 |
const initializeApp = () => {
|
| 999 |
const urlParams = new URLSearchParams(window.location.search);
|