Skip to content

Commit f74d47c

Browse files
authored
Add files via upload
1 parent 7663b32 commit f74d47c

1 file changed

Lines changed: 30 additions & 27 deletions

File tree

test.html

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@
162162
padding: 8px;
163163
}
164164

165-
.text-output-area {
166-
min-height: 150px;
165+
/* 調整輸入框高度 */
166+
.text-output-area,
167+
#phrase-input {
168+
min-height: 50px;
169+
height: 50px;
167170
background-color: #fafafa;
168171
resize: none;
169172
}
@@ -239,7 +242,8 @@
239242
#phrase-input {
240243
width: 100%;
241244
min-height: 50px;
242-
resize: vertical;
245+
height: 50px;
246+
resize: none;
243247
font-size: var(--unified-font-size);
244248
padding: 8px;
245249
}
@@ -273,6 +277,11 @@
273277
box-sizing: border-box;
274278
gap: 2px;
275279
}
280+
281+
.char-encoding-column.highlight-char {
282+
border: 2px solid var(--primary-color);
283+
background-color: #d1d9ff;
284+
}
276285

277286
.char-encoding-column .char-label {
278287
font-weight: bold;
@@ -300,12 +309,6 @@
300309
color: red;
301310
}
302311

303-
/* 焦點高亮顯示 */
304-
.focused-char-background {
305-
background-color: #c5cae9 !important; /* 使用較明顯的藍色調 */
306-
border-radius: 4px;
307-
}
308-
309312
/* 鍵盤樣式 */
310313
.keyboard-container {
311314
width: 100%;
@@ -399,7 +402,13 @@ <h2>輸入法模式:</h2>
399402
</div>
400403
</div>
401404

402-
<textarea class="text-output-area" id="text-output"></textarea>
405+
<div class="lookup-section">
406+
<h2>查碼練習</h2>
407+
<textarea id="phrase-input" placeholder="在此輸入或貼上一段文字..."></textarea>
408+
<div id="encoding-results"></div>
409+
</div>
410+
411+
<textarea class="text-output-area" id="text-output" placeholder="開始輸入練習吧!"></textarea>
403412

404413
<div class="input-area">
405414
<input type="text" id="main-input" placeholder="編碼顯示在此" readonly="">
@@ -408,12 +417,6 @@ <h2>輸入法模式:</h2>
408417

409418
<div id="mode-display">模式:三碼</div>
410419

411-
<div class="lookup-section">
412-
<h2>查碼練習</h2>
413-
<textarea id="phrase-input" placeholder="在此輸入或貼上一段文字..."></textarea>
414-
<div id="encoding-results"></div>
415-
</div>
416-
417420
<div class="keyboard-container">
418421
<div class="key-row">
419422
<div class="key" data-code="1">1</div>
@@ -1033,13 +1036,17 @@ <h2>查碼練習</h2>
10331036
const column = document.createElement('div');
10341037
column.className = 'char-encoding-column';
10351038

1039+
const globalIndex = lookupStartIndex + i;
1040+
if (globalIndex === cursorPosition && (phraseInput === document.activeElement || textOutput === document.activeElement)) {
1041+
column.classList.add('highlight-char');
1042+
}
1043+
10361044
const charLabel = document.createElement('span');
10371045
charLabel.className = 'char-label';
10381046

10391047
if (i < characters.length) {
10401048
const char = characters[i];
10411049
charLabel.textContent = char;
1042-
const globalIndex = lookupStartIndex + i;
10431050

10441051
if (globalIndex < textToCompare.length && char === textToCompare[globalIndex]) {
10451052
// The character at this position matches the typed character.
@@ -1050,11 +1057,6 @@ <h2>查碼練習</h2>
10501057
}
10511058
}
10521059

1053-
// Add the highlighted background for the character corresponding to the cursor
1054-
if (i < characters.length && (lookupStartIndex + i) === cursorPosition) {
1055-
charLabel.classList.add('focused-char-background');
1056-
}
1057-
10581060
const encodingContainer = document.createElement('div');
10591061
encodingContainer.style.display = 'flex';
10601062
encodingContainer.style.flexDirection = 'column';
@@ -1106,14 +1108,15 @@ <h2>查碼練習</h2>
11061108
}
11071109

11081110
phraseInput.addEventListener('input', updatePhraseLookup);
1109-
phraseInput.addEventListener('keyup', updatePhraseLookup); // Capture key releases for cursor movement
1110-
phraseInput.addEventListener('click', updatePhraseLookup); // Capture mouse clicks for cursor movement
1111+
phraseInput.addEventListener('keyup', updatePhraseLookup);
1112+
phraseInput.addEventListener('click', updatePhraseLookup);
1113+
phraseInput.addEventListener('focus', updatePhraseLookup);
11111114

11121115
textOutput.addEventListener('input', updatePhraseLookup);
1113-
textOutput.addEventListener('keyup', updatePhraseLookup); // Capture key releases for cursor movement
1114-
textOutput.addEventListener('click', updatePhraseLookup); // Capture mouse clicks for cursor movement
1116+
textOutput.addEventListener('keyup', updatePhraseLookup);
1117+
textOutput.addEventListener('click', updatePhraseLookup);
1118+
textOutput.addEventListener('focus', updatePhraseLookup);
11151119

1116-
// 頁面載入時先初始化顯示
11171120
switchInputMethod('primary');
11181121
updateKeyboardDisplay();
11191122
</script>

0 commit comments

Comments
 (0)