Spaces:
Sleeping
Sleeping
Fix button event handling - use addEventListener instead of onclick
Browse files
app.py
CHANGED
|
@@ -372,6 +372,21 @@ function downloadFromDrive(fileId, fileName) {
|
|
| 372 |
// Initialize when page loads - multiple attempts to ensure it works
|
| 373 |
window.addEventListener('load', function() {
|
| 374 |
console.log('🚀 Page loaded, starting Google Drive initialization...');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
initializeGoogleDrive();
|
| 376 |
});
|
| 377 |
|
|
@@ -379,6 +394,20 @@ window.addEventListener('load', function() {
|
|
| 379 |
setTimeout(function() {
|
| 380 |
console.log('🔄 Delayed initialization attempt...');
|
| 381 |
initializeGoogleDrive();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
}, 2000);
|
| 383 |
</script>
|
| 384 |
|
|
@@ -386,11 +415,11 @@ setTimeout(function() {
|
|
| 386 |
<h3>🔗 Google Drive Integration (Client-Side)</h3>
|
| 387 |
<p><strong>Each user authenticates with their own Google account</strong></p>
|
| 388 |
|
| 389 |
-
<button
|
| 390 |
🔐 Authenticate with Google Drive
|
| 391 |
</button>
|
| 392 |
|
| 393 |
-
<button
|
| 394 |
📁 Browse Google Drive
|
| 395 |
</button>
|
| 396 |
|
|
|
|
| 372 |
// Initialize when page loads - multiple attempts to ensure it works
|
| 373 |
window.addEventListener('load', function() {
|
| 374 |
console.log('🚀 Page loaded, starting Google Drive initialization...');
|
| 375 |
+
|
| 376 |
+
// Attach event listeners to buttons
|
| 377 |
+
const authBtn = document.getElementById('auth-btn');
|
| 378 |
+
const pickerBtn = document.getElementById('picker-btn');
|
| 379 |
+
|
| 380 |
+
if (authBtn) {
|
| 381 |
+
authBtn.addEventListener('click', window.authenticateGoogleDrive);
|
| 382 |
+
console.log('✅ Auth button listener attached');
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
if (pickerBtn) {
|
| 386 |
+
pickerBtn.addEventListener('click', window.openDrivePicker);
|
| 387 |
+
console.log('✅ Picker button listener attached');
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
initializeGoogleDrive();
|
| 391 |
});
|
| 392 |
|
|
|
|
| 394 |
setTimeout(function() {
|
| 395 |
console.log('🔄 Delayed initialization attempt...');
|
| 396 |
initializeGoogleDrive();
|
| 397 |
+
|
| 398 |
+
// Try attaching listeners again in case they weren't ready
|
| 399 |
+
const authBtn = document.getElementById('auth-btn');
|
| 400 |
+
const pickerBtn = document.getElementById('picker-btn');
|
| 401 |
+
|
| 402 |
+
if (authBtn && !authBtn.onclick) {
|
| 403 |
+
authBtn.addEventListener('click', window.authenticateGoogleDrive);
|
| 404 |
+
console.log('✅ Delayed: Auth button listener attached');
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
if (pickerBtn && !pickerBtn.onclick) {
|
| 408 |
+
pickerBtn.addEventListener('click', window.openDrivePicker);
|
| 409 |
+
console.log('✅ Delayed: Picker button listener attached');
|
| 410 |
+
}
|
| 411 |
}, 2000);
|
| 412 |
</script>
|
| 413 |
|
|
|
|
| 415 |
<h3>🔗 Google Drive Integration (Client-Side)</h3>
|
| 416 |
<p><strong>Each user authenticates with their own Google account</strong></p>
|
| 417 |
|
| 418 |
+
<button id="auth-btn" style="background: #4285f4; color: white; padding: 10px 20px; border: none; border-radius: 5px; margin: 5px;">
|
| 419 |
🔐 Authenticate with Google Drive
|
| 420 |
</button>
|
| 421 |
|
| 422 |
+
<button id="picker-btn" style="background: #34a853; color: white; padding: 10px 20px; border: none; border-radius: 5px; margin: 5px;">
|
| 423 |
📁 Browse Google Drive
|
| 424 |
</button>
|
| 425 |
|