amine_dubs
commited on
Commit
·
60da4f1
1
Parent(s):
a92ab1c
- static/script.js +28 -23
static/script.js
CHANGED
@@ -44,36 +44,41 @@ window.onload = function() {
|
|
44 |
if (errorElement) errorElement.style.display = 'none';
|
45 |
if (debugElement) debugElement.style.display = 'none';
|
46 |
|
47 |
-
// ---
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
console.error('FATAL:
|
53 |
-
showError('Internal error: Text input
|
54 |
return;
|
55 |
} else {
|
56 |
-
console.log('[DEBUG]
|
57 |
-
|
58 |
-
|
59 |
-
} catch (e) {
|
60 |
-
console.error('[DEBUG] Error accessing outerHTML:', e);
|
61 |
-
}
|
62 |
-
|
63 |
-
// Now try accessing the value
|
64 |
-
let text = '';
|
65 |
try {
|
66 |
-
console.log('[DEBUG] Attempting to access .value...');
|
67 |
-
|
68 |
-
console.log('[DEBUG] Accessed .value successfully. Value:',
|
69 |
} catch (e) {
|
70 |
-
|
71 |
-
console.error('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
showError('Internal error: Failed to read text input value. Check console.');
|
73 |
return; // Stop execution
|
74 |
}
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
77 |
if (!text) {
|
78 |
showError('Please enter text to translate');
|
79 |
return;
|
|
|
44 |
if (errorElement) errorElement.style.display = 'none';
|
45 |
if (debugElement) debugElement.style.display = 'none';
|
46 |
|
47 |
+
// --- FINAL DEFENSIVE CHECK using variable captured onload ---
|
48 |
+
console.log('[DEBUG] Checking textInput variable captured onload:', textInput);
|
49 |
+
|
50 |
+
if (!textInput) {
|
51 |
+
// This should ideally not happen if the check on load passed
|
52 |
+
console.error('FATAL: textInput variable (captured onload) is null INSIDE handler.');
|
53 |
+
showError('Internal error: Text input reference lost.');
|
54 |
return;
|
55 |
} else {
|
56 |
+
console.log('[DEBUG] textInput variable IS NOT NULL. Type:', typeof textInput);
|
57 |
+
let inputValue = null;
|
58 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
try {
|
60 |
+
console.log('[DEBUG] Attempting to access .value from textInput variable...');
|
61 |
+
inputValue = textInput.value; // Potential error point (Line 65 approx)
|
62 |
+
console.log('[DEBUG] Accessed .value successfully. Raw Value:', inputValue);
|
63 |
} catch (e) {
|
64 |
+
// This catch block should now definitively catch the error if it happens during value access
|
65 |
+
console.error('FATAL: Error occurred accessing .value from textInput variable:', e);
|
66 |
+
console.error('[DEBUG] textInput variable state just before error:', textInput);
|
67 |
+
try {
|
68 |
+
// Attempt to log outerHTML for more context if possible
|
69 |
+
console.error('[DEBUG] Element outerHTML at time of error:', textInput.outerHTML);
|
70 |
+
} catch (htmlError) {
|
71 |
+
console.error('[DEBUG] Could not get outerHTML:', htmlError);
|
72 |
+
}
|
73 |
showError('Internal error: Failed to read text input value. Check console.');
|
74 |
return; // Stop execution
|
75 |
}
|
76 |
+
|
77 |
+
// Now use the stored value
|
78 |
+
const text = inputValue ? inputValue.trim() : '';
|
79 |
+
console.log('[DEBUG] Trimmed text value:', text);
|
80 |
+
// --- END FINAL DEFENSIVE CHECK ---
|
81 |
+
|
82 |
if (!text) {
|
83 |
showError('Please enter text to translate');
|
84 |
return;
|