mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
feat: initialize example images manager on app startup and streamline event listener setup
This commit is contained in:
@@ -35,6 +35,9 @@ export class AppCore {
|
|||||||
initTheme();
|
initTheme();
|
||||||
initBackToTop();
|
initBackToTop();
|
||||||
|
|
||||||
|
// Initialize the example images manager
|
||||||
|
exampleImagesManager.initialize();
|
||||||
|
|
||||||
// Mark as initialized
|
// Mark as initialized
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
|
|||||||
@@ -10,20 +10,32 @@ class ExampleImagesManager {
|
|||||||
this.startTime = null;
|
this.startTime = null;
|
||||||
this.progressPanel = null;
|
this.progressPanel = null;
|
||||||
|
|
||||||
// Wait for DOM before initializing event listeners
|
// Initialize download path field and check download status
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
this.initEventListeners();
|
|
||||||
// Initialize progress panel reference
|
|
||||||
this.progressPanel = document.getElementById('exampleImagesProgress');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize download path field
|
|
||||||
this.initializePathOptions();
|
this.initializePathOptions();
|
||||||
|
|
||||||
// Check download status on page load
|
|
||||||
this.checkDownloadStatus();
|
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
|
// Initialize event listeners for buttons
|
||||||
initEventListeners() {
|
initEventListeners() {
|
||||||
const downloadBtn = document.getElementById('exampleImagesDownloadBtn');
|
const downloadBtn = document.getElementById('exampleImagesDownloadBtn');
|
||||||
|
|||||||
@@ -46,28 +46,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
// Initialize button onclick handlers when DOM is fully loaded
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const pauseBtn = document.getElementById('pauseExampleDownloadBtn');
|
|
||||||
const collapseBtn = document.getElementById('collapseProgressBtn');
|
|
||||||
|
|
||||||
// Make window.exampleImagesManager globally available
|
|
||||||
if (window.exampleImagesManager === undefined && typeof exampleImagesManager !== 'undefined') {
|
|
||||||
window.exampleImagesManager = exampleImagesManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pauseBtn && window.exampleImagesManager) {
|
|
||||||
pauseBtn.onclick = () => window.exampleImagesManager.pauseDownload();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (collapseBtn && window.exampleImagesManager) {
|
|
||||||
collapseBtn.onclick = () => {
|
|
||||||
if (window.exampleImagesManager.toggleProgressPanel) {
|
|
||||||
window.exampleImagesManager.toggleProgressPanel();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
Reference in New Issue
Block a user