Skip to content

Commit e58bbde

Browse files
authored
Update test.html
1 parent c5b2529 commit e58bbde

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

test.html

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,13 @@ <h2>輸入法模式:</h2>
490490
if (!newReverseCodemap[char]) {
491491
newReverseCodemap[char] = [];
492492
}
493-
newReverseCodemap[char].push(code);
493+
// 檢查該字元是否已存在該編碼,避免重複
494+
if (!newReverseCodemap[char].some(item => item.code === code)) {
495+
newReverseCodemap[char].push({
496+
code: code,
497+
index: newCodemap[code].length - 1
498+
});
499+
}
494500
}
495501
}
496502
});
@@ -943,18 +949,18 @@ <h2>輸入法模式:</h2>
943949
searchInput.addEventListener('input', (event) => {
944950
const charToSearch = searchInput.value;
945951
if (charToSearch.length === 1) {
946-
const codes = currentReverseCodemap[charToSearch];
947-
if (codes && codes.length > 0) {
948-
const formattedCodes = codes.map((code, index) => {
952+
const results = currentReverseCodemap[charToSearch];
953+
if (results && results.length > 0) {
954+
const formattedCodes = results.map(result => {
955+
const code = result.code;
956+
const index = result.index;
949957
let suffix = '';
950-
if (codes.length > 1) {
951-
if (index < 9) {
952-
suffix = (index + 1).toString();
953-
} else if (index === 9) {
954-
suffix = '0';
955-
} else {
956-
suffix = '>';
957-
}
958+
if (index < 9) {
959+
suffix = (index + 1).toString();
960+
} else if (index === 9) {
961+
suffix = '0';
962+
} else {
963+
suffix = '>';
958964
}
959965
return formatCode(code) + suffix;
960966
});
@@ -981,4 +987,4 @@ <h2>輸入法模式:</h2>
981987
switchInputMethod('primary');
982988
updateKeyboardDisplay();
983989
</script>
984-
</body></html>
990+
</body></html>

0 commit comments

Comments
 (0)