Repository navigation
Expand file tree
/
Copy pathinput-debug.html
More file actions
323 lines (278 loc) · 12.6 KB
/
Copy pathinput-debug.html
File metadata and controls
323 lines (278 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WordDuel Input Debug</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
margin: 0;
padding: 20px;
min-height: 100vh;
color: white;
}
.debug-container {
max-width: 800px;
margin: 0 auto;
background: rgba(255,255,255,0.1);
backdrop-filter: blur(20px);
border-radius: 20px;
padding: 40px;
box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.test-section {
margin: 20px 0;
padding: 20px;
background: rgba(255,255,255,0.05);
border-radius: 10px;
border: 1px solid rgba(255,255,255,0.2);
}
.test-input {
width: 100%;
padding: 15px;
margin: 10px 0;
border: none;
border-radius: 10px;
background: rgba(255,255,255,0.1);
color: white;
font-size: 18px;
box-sizing: border-box;
}
.test-input::placeholder {
color: rgba(255,255,255,0.7);
}
.test-input:focus {
outline: 2px solid #FFC107;
background: rgba(255,255,255,0.2);
box-shadow: 0 0 15px rgba(255, 193, 7, 0.3);
}
.debug-btn {
padding: 12px 24px;
border: none;
border-radius: 8px;
cursor: pointer;
font-weight: bold;
margin: 5px;
transition: all 0.3s ease;
}
.debug-btn.primary { background: #4CAF50; color: white; }
.debug-btn.secondary { background: #2196F3; color: white; }
.debug-btn.warning { background: #FF9800; color: white; }
.debug-btn.danger { background: #F44336; color: white; }
.debug-btn:hover {
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.log-output {
background: rgba(0,0,0,0.3);
border-radius: 10px;
padding: 20px;
margin: 20px 0;
max-height: 400px;
overflow-y: auto;
font-family: monospace;
font-size: 14px;
}
.log-entry {
margin: 5px 0;
padding: 5px;
border-radius: 5px;
}
.log-info { background: rgba(33, 150, 243, 0.2); }
.log-success { background: rgba(76, 175, 80, 0.2); }
.log-warning { background: rgba(255, 193, 7, 0.2); }
.log-error { background: rgba(244, 67, 54, 0.2); }
.status-indicator {
display: inline-block;
width: 12px;
height: 12px;
border-radius: 50%;
margin-right: 8px;
}
.status-ok { background: #4CAF50; }
.status-error { background: #F44336; }
.status-warning { background: #FF9800; }
</style>
</head>
<body>
<div class="debug-container">
<h1>🔍 WordDuel Input Field Debug</h1>
<p>This page helps debug input field issues in the WordDuel game.</p>
<div class="test-section">
<h3>🎯 Test Input Field</h3>
<input type="text" id="testInput" class="test-input" placeholder="Type here to test input functionality..." maxlength="10">
<div style="margin: 10px 0;">
<button class="debug-btn primary" onclick="focusTestInput()">Focus Input</button>
<button class="debug-btn secondary" onclick="testInputEvents()">Test Events</button>
<button class="debug-btn warning" onclick="clearTestInput()">Clear Input</button>
</div>
</div>
<div class="test-section">
<h3>🔧 Debug Actions</h3>
<div style="margin: 10px 0;">
<button class="debug-btn primary" onclick="testWordDuelElements()">Test WordDuel Elements</button>
<button class="debug-btn secondary" onclick="simulateGameStart()">Simulate Game Start</button>
<button class="debug-btn warning" onclick="testInputArea()">Test Input Area</button>
<button class="debug-btn danger" onclick="clearLog()">Clear Log</button>
</div>
</div>
<div class="test-section">
<h3>📊 Element Status</h3>
<div id="elementStatus">
<p>Click "Test WordDuel Elements" to check element status</p>
</div>
</div>
<div class="test-section">
<h3>📝 Debug Log</h3>
<div class="log-output" id="debugLog">
<div class="log-entry log-info">Debug page loaded. Ready to test input functionality.</div>
</div>
</div>
</div>
<script>
const testInput = document.getElementById('testInput');
const debugLog = document.getElementById('debugLog');
const elementStatus = document.getElementById('elementStatus');
function log(message, type = 'info') {
const entry = document.createElement('div');
entry.className = `log-entry log-${type}`;
entry.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
debugLog.appendChild(entry);
debugLog.scrollTop = debugLog.scrollHeight;
}
function focusTestInput() {
testInput.focus();
log('Test input focused', 'success');
}
function testInputEvents() {
log('Testing input events...', 'info');
// Test input event
testInput.dispatchEvent(new Event('input', { bubbles: true }));
log('Input event dispatched', 'success');
// Test keydown event
testInput.dispatchEvent(new KeyboardEvent('keydown', { key: 'A', bubbles: true }));
log('Keydown event dispatched', 'success');
// Test focus event
testInput.dispatchEvent(new Event('focus', { bubbles: true }));
log('Focus event dispatched', 'success');
}
function clearTestInput() {
testInput.value = '';
log('Test input cleared', 'warning');
}
function clearLog() {
debugLog.innerHTML = '<div class="log-entry log-info">Log cleared...</div>';
}
function testWordDuelElements() {
log('Testing WordDuel elements...', 'info');
let statusHtml = '<h4>Element Status:</h4>';
// Test wordInput element
const wordInput = document.getElementById('wordInput');
if (wordInput) {
statusHtml += `<div><span class="status-indicator status-ok"></span>wordInput: Found</div>`;
statusHtml += `<div style="margin-left: 20px; font-size: 0.9em;">`;
statusHtml += `- ID: ${wordInput.id}<br>`;
statusHtml += `- Type: ${wordInput.type}<br>`;
statusHtml += `- Value: "${wordInput.value}"<br>`;
statusHtml += `- Display: ${getComputedStyle(wordInput).display}<br>`;
statusHtml += `- Visibility: ${getComputedStyle(wordInput).visibility}<br>`;
statusHtml += `- Z-Index: ${getComputedStyle(wordInput).zIndex}<br>`;
statusHtml += `- Pointer Events: ${getComputedStyle(wordInput).pointerEvents}`;
statusHtml += `</div>`;
log('wordInput element found', 'success');
} else {
statusHtml += `<div><span class="status-indicator status-error"></span>wordInput: NOT FOUND</div>`;
log('wordInput element NOT found', 'error');
}
// Test inputArea element
const inputArea = document.getElementById('inputArea');
if (inputArea) {
statusHtml += `<div><span class="status-indicator status-ok"></span>inputArea: Found</div>`;
statusHtml += `<div style="margin-left: 20px; font-size: 0.9em;">`;
statusHtml += `- ID: ${inputArea.id}<br>`;
statusHtml += `- Display: ${getComputedStyle(inputArea).display}<br>`;
statusHtml += `- Visibility: ${getComputedStyle(inputArea).visibility}`;
statusHtml += `</div>`;
log('inputArea element found', 'success');
} else {
statusHtml += `<div><span class="status-indicator status-error"></span>inputArea: NOT FOUND</div>`;
log('inputArea element NOT found', 'error');
}
// Test other game elements
const gameBoard = document.getElementById('gameBoard');
const keyboard = document.getElementById('keyboard');
const gameContainer = document.getElementById('gameContainer');
statusHtml += `<div><span class="status-indicator ${gameBoard ? 'status-ok' : 'status-error'}"></span>gameBoard: ${gameBoard ? 'Found' : 'NOT FOUND'}</div>`;
statusHtml += `<div><span class="status-indicator ${keyboard ? 'status-ok' : 'status-error'}"></span>keyboard: ${keyboard ? 'Found' : 'NOT FOUND'}</div>`;
statusHtml += `<div><span class="status-indicator ${gameContainer ? 'status-ok' : 'status-error'}"></span>gameContainer: ${gameContainer ? 'Found' : 'NOT FOUND'}</div>`;
elementStatus.innerHTML = statusHtml;
}
function simulateGameStart() {
log('Simulating game start...', 'info');
// Try to find and show input area
const inputArea = document.getElementById('inputArea');
if (inputArea) {
inputArea.style.display = 'block';
log('Input area shown', 'success');
// Try to focus wordInput
const wordInput = document.getElementById('wordInput');
if (wordInput) {
wordInput.style.display = 'block';
wordInput.style.visibility = 'visible';
wordInput.style.opacity = '1';
wordInput.style.zIndex = '1000';
wordInput.style.pointerEvents = 'auto';
setTimeout(() => {
wordInput.focus();
log('Word input focused after simulation', 'success');
}, 100);
} else {
log('Word input not found during simulation', 'error');
}
} else {
log('Input area not found during simulation', 'error');
}
}
function testInputArea() {
log('Testing input area functionality...', 'info');
const inputArea = document.getElementById('inputArea');
if (inputArea) {
// Toggle visibility
const currentDisplay = getComputedStyle(inputArea).display;
if (currentDisplay === 'none') {
inputArea.style.display = 'block';
log('Input area shown', 'success');
} else {
inputArea.style.display = 'none';
log('Input area hidden', 'warning');
}
} else {
log('Input area element not found', 'error');
}
}
// Test input event listeners
testInput.addEventListener('input', function(e) {
log(`Input event: "${e.target.value}" (Length: ${e.target.value.length})`, 'success');
});
testInput.addEventListener('keydown', function(e) {
log(`Keydown: "${e.key}" (Code: ${e.keyCode})`, 'info');
});
testInput.addEventListener('focus', function(e) {
log('Input focused', 'success');
});
testInput.addEventListener('blur', function(e) {
log('Input lost focus', 'warning');
});
// Auto-focus test input
window.addEventListener('load', function() {
setTimeout(() => {
testInput.focus();
log('Test input auto-focused on page load', 'success');
}, 500);
});
log('Debug page initialized successfully', 'success');
</script>
</body>
</html>