Skip to content

Commit e21f31e

Browse files
authored
Add files via upload
1 parent 904661b commit e21f31e

1 file changed

Lines changed: 21 additions & 25 deletions

File tree

3code_mobile.html

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;700&display=swap" rel="stylesheet">
1010
<style>
1111
/* ----------------------------------------------------- */
12-
/* 樣式定義 */
12+
/* 樣式定義 (未變動) */
1313
/* ----------------------------------------------------- */
1414

1515
:root {
@@ -38,7 +38,6 @@
3838
align-items: center;
3939
background-color: var(--background-color);
4040
min-height: 100vh;
41-
/* 保持足夠的底部空間以容納鍵盤 */
4241
padding-bottom: 490px;
4342
}
4443

@@ -313,7 +312,7 @@
313312
</div>
314313

315314
<div class="search-area">
316-
<input type="text" id="search-input" placeholder="在此輸入漢字 (1字)" maxlength="1">
315+
<input type="text" id="search-input" placeholder="在此輸入字符 (1字)" maxlength="1">
317316
<div id="search-result">查詢結果顯示在此</div>
318317
</div>
319318
<div id="app-container">
@@ -343,7 +342,7 @@
343342
const CURSOR_HTML = '<span id="main-cursor" class="cursor">\u200c</span>';
344343
const NON_BREAK_ANCHOR = '\ufeff';
345344

346-
// --- 鍵盤顯示內容映射表 ---
345+
// --- 鍵盤顯示內容映射表 (與前次一致) ---
347346
const letter_maps = {
348347
'cn_normal': (key) => key.toUpperCase(),
349348
'cn_shifted': (key) => key.toUpperCase(),
@@ -427,6 +426,10 @@
427426
return null;
428427
}
429428

429+
/**
430+
* 核心格式化函數:將半型英文字母/符號碼轉換為全型顯示。
431+
* 用於:輸入區 (main-input) 和 查碼結果 (search-result)。
432+
*/
430433
function formatCode(code) {
431434
let displayString = '';
432435
const map = key_display_maps.cn_normal;
@@ -435,28 +438,21 @@
435438
if (char.match(/^[a-z]$/)) {
436439
const upperCaseChar = char.toUpperCase();
437440
if (upperCaseChar >= 'A' && upperCaseChar <= 'Z') {
441+
// 將 A-Z 轉為全型 A-Z (U+FF21 - U+FF3A)
438442
const fullwidthChar = String.fromCharCode(upperCaseChar.charCodeAt(0) - 0x20 + 0xFF00);
439443
displayString += fullwidthChar;
440444
} else {
441445
displayString += upperCaseChar;
442446
}
443447
} else if (map[char]) {
448+
// 處理 ; ' , . / 轉為全型符號 ; 〃 , . /
444449
displayString += map[char];
445450
} else {
446451
displayString += char;
447452
}
448453
}
449454
return displayString;
450455
}
451-
452-
// 查碼功能專用:編碼格式化
453-
function formatCodeForSearch(code) {
454-
let displayString = '';
455-
for (const char of code) {
456-
displayString += char.toUpperCase();
457-
}
458-
return displayString;
459-
}
460456

461457
function formatComposition(code) {
462458
if (!code) return '';
@@ -834,7 +830,7 @@
834830

835831
async function loadSecondaryCodemap() {
836832
const fileName = './3codes2.txt';
837-
let textToParse = `# 這是備用的模擬編碼表\nqwe\t測試\n`;
833+
let textToParse = `# 這是備用的模擬編碼表\nqwe\t測試\n「\t[;'\n」\t';]\n○\tqwe\n`; // 增加測試符號
838834
let statusMessage = '編碼表載入中...';
839835

840836
try {
@@ -1178,21 +1174,21 @@
11781174
}
11791175
}
11801176

1181-
// --- 查碼功能事件處理 ---
1177+
// --- 查碼功能事件處理 (已修復) ---
11821178
function handleSearchInput(event) {
11831179
const charToSearch = searchInput.value;
11841180
if (charToSearch.length === 1) {
1185-
// 檢查是否為中文字 (簡單判斷)
1186-
if (charToSearch.match(/[\u4e00-\u9fff]/)) {
1187-
const codes = currentReverseCodemap[charToSearch];
1188-
if (codes && codes.length > 0) {
1189-
const formattedCodes = codes.map(code => formatCodeForSearch(code));
1190-
searchResult.textContent = `編碼: ${formattedCodes.join(' ')}`;
1191-
} else {
1192-
searchResult.textContent = '找不到該漢字編碼。';
1193-
}
1181+
1182+
// 移除字符類型檢查,直接查找碼表
1183+
const codes = currentReverseCodemap[charToSearch];
1184+
1185+
if (codes && codes.length > 0) {
1186+
// 使用 formatCode 函數確保編碼以全型字元顯示
1187+
const formattedCodes = codes.map(code => formatCode(code));
1188+
searchResult.textContent = `編碼: ${formattedCodes.join(' ')}`;
11941189
} else {
1195-
searchResult.textContent = '請輸入一個中文字查詢。';
1190+
// 修正提示訊息,接受所有字符
1191+
searchResult.textContent = '找不到該字符的編碼。';
11961192
}
11971193
} else {
11981194
searchResult.textContent = '查詢結果顯示在此';

0 commit comments

Comments
 (0)