Files
JasonHoku-ComfyUI-Ultimate-…/resources/logic_init.js
T
Jason HokuandClaude Fable 5.1 5cf0782ce0 feat(dashboard): lazy manifest loading, the page is a shell and the SPA fetches /config_tester/manifest
html_generator.get_html_template now emits a shell (empty fullManifest flagged
__uscg_lazy__, inline_manifest=True restores the old behaviour). New route
GET /config_tester/manifest?session=<name>: compact JSON, weak ETag, 304 on
If-None-Match, gzip, torn-read retry (logic in run_api.load_manifest_for_fetch).
/config_tester/dashboard gets gzip + content ETag. The SPA boots with one fetch
(no more double load), resync is conditional and non-destructive, and
web/dashboard.js asks the iframe to re-fetch (reload_manifest) instead of
parsing data out of the Generator's executed message. Also fixes the dead
session-name regex in dashboard_node.py.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-04 03:25:59 -08:00

116 lines
3.6 KiB
JavaScript

/**
* INITIALIZATION
* Runs on startup to bind inputs and start the pipeline.
*/
function init() {
try {
// Bind Column Input
const colInput = document.getElementById('col-count');
if (colInput) {
// Load saved column preference
const savedCols = localStorage.getItem('ultimate_grid_cols');
if (savedCols) {
const val = parseInt(savedCols);
if (val > 0) colInput.value = val;
}
let colInputTimeout = null;
colInput.addEventListener('input', (e) => {
// Clear previous timeout
if (colInputTimeout) clearTimeout(colInputTimeout);
// Debounce the recalculation
colInputTimeout = setTimeout(() => {
const val = parseInt(e.target.value);
if (val > 0) {
localStorage.setItem('ultimate_grid_cols', val);
} else {
localStorage.removeItem('ultimate_grid_cols');
}
// Recalculate layout and re-render
if (typeof recalcColumns === 'function') {
recalcColumns();
}
}, 600);
});
}
// Load sort preference from localStorage
if (typeof loadSortPreference === 'function') {
loadSortPreference();
}
// Load label mode preferences from localStorage
if (typeof loadLabelPreferences === 'function') {
loadLabelPreferences();
}
// Pairwise review settings (cog panel) + vote sync
if (typeof initCompareUI === 'function') {
initCompareUI();
}
// Start
refreshIndices();
if (typeof initFilters === 'function') initFilters();
// Initialize search filter UI
if (typeof renderSearchFilters === 'function') renderSearchFilters();
// Initialize logic filter UI
if (typeof renderLogicFilters === 'function') renderLogicFilters();
// IMPORTANT: Calculate grid dimensions BEFORE running pipeline
if (typeof updateGridDimensions === 'function') {
updateGridDimensions();
}
updateDataPipeline();
// Initialize the virtual scroller (pan/zoom/keyboard controls)
if (typeof initVirtualScroller === 'function') {
initVirtualScroller();
}
// Try to restore saved viewport position BEFORE auto-fit
let restoredPosition = false;
if (typeof restoreViewportPosition === 'function') {
restoredPosition = restoreViewportPosition();
}
// (a lazy-shell boot has no data yet: its loadSession auto-fits once the data is in, unless this is true)
window._uscgViewportRestored = restoredPosition;
// Only auto-fit if we didn't restore a saved position
if (!restoredPosition) {
setTimeout(() => {
if (typeof autoFitZoom === 'function') {
autoFitZoom();
}
}, 100);
}
// Show session landing page if no data loaded, populate session picker
if (typeof showSessionLandingIfEmpty === 'function') {
showSessionLandingIfEmpty();
} else if (typeof fetchAndShowSessions === 'function') {
fetchAndShowSessions();
}
} catch (e) {
console.error("Init Error", e);
}
}
// Ensure init fires after DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}