feat: initialize example images manager on app startup and streamline event listener setup

This commit is contained in:
Will Miao
2025-04-30 14:17:39 +08:00
parent cb5e64d26b
commit b32756932b
3 changed files with 26 additions and 36 deletions

View File

@@ -10,20 +10,32 @@ class ExampleImagesManager {
this.startTime = null;
this.progressPanel = null;
// Wait for DOM before initializing event listeners
document.addEventListener('DOMContentLoaded', () => {
this.initEventListeners();
// Initialize progress panel reference
this.progressPanel = document.getElementById('exampleImagesProgress');
});
// Initialize download path field
// Initialize download path field and check download status
this.initializePathOptions();
// Check download status on page load
this.checkDownloadStatus();
}
// Initialize the manager
initialize() {
// Initialize event listeners
this.initEventListeners();
// Initialize progress panel reference
this.progressPanel = document.getElementById('exampleImagesProgress');
// Initialize progress panel button handlers
const pauseBtn = document.getElementById('pauseExampleDownloadBtn');
const collapseBtn = document.getElementById('collapseProgressBtn');
if (pauseBtn) {
pauseBtn.onclick = () => this.pauseDownload();
}
if (collapseBtn) {
collapseBtn.onclick = () => this.toggleProgressPanel();
}
}
// Initialize event listeners for buttons
initEventListeners() {
const downloadBtn = document.getElementById('exampleImagesDownloadBtn');