-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
92 lines (76 loc) · 3.73 KB
/
Copy pathmain.js
File metadata and controls
92 lines (76 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { initializeState, setRenderFunction } from './state.js';
import { initializeUI } from './ui.js';
import { renderAll } from './renderer.js';
import { initializeLibrary } from './library-loader.js';
// --- Global Functions for Multi-Studio Environment ---
// FIX: Expose FA setMachine globally (used by FA file.js and FA conversion animation)
import { setMachine } from './state.js';
window.setFaMachine = setMachine;
// Function to handle loading of FA Studio
function loadFaStudio(machineData) {
if (machineData) {
setMachine(machineData); // Use the FA setter
}
initializeUI();
initializeLibrary();
}
window.loadFaStudio = loadFaStudio;
// NOTE: Moore/Mealy Studio must define and initialize itself separately
// Its initialization functions (like initializeMMUI) are imported by unified_main.js
// but since we are modifying files locally, we will keep the core logic simple.
// --- Main Application Startup ---
document.addEventListener("DOMContentLoaded", () => {
const splashScreen = document.getElementById('splashScreen');
const mainApp = document.getElementById('mainApp');
// FIX: Update the selectors to match the HTML buttons ('FA' and 'MM')
const faButton = document.querySelector('.splash-nav-btn[data-target="FA"]');
const mmButton = document.querySelector('.splash-nav-btn[data-target="MM"]');
// Assuming renderAll is for the FA studio visualization panel by default
setRenderFunction(renderAll);
// This is the common function to hide the splash screen and start the FA app
const startFaApp = () => {
if (mainApp) mainApp.style.display = 'block';
setTimeout(() => {
if (typeof lucide !== 'undefined') {
lucide.createIcons();
}
// Load the FA studio logic
loadFaStudio();
}, 0);
};
// --- Splash Screen Navigation ---
if (splashScreen && mainApp) {
// Find the button that is likely auto-clicked if a unified_main.js isn't loaded
// FIX: The FA studio should only start when its button is clicked
if (faButton) {
faButton.addEventListener('click', () => {
splashScreen.style.opacity = '0';
setTimeout(() => {
splashScreen.style.display = 'none';
startFaApp();
}, 800);
});
}
// We need a proper loader for the MM Studio as well, likely provided by unified_main.js
if (mmButton) {
mmButton.addEventListener('click', async () => {
splashScreen.style.opacity = '0';
setTimeout(async () => {
splashScreen.style.display = 'none';
// The MM Studio needs to load its HTML content and run its own initialization
// Assuming this is done by a unified_main.js or similar logic that loads 'mealy_moore_studio.html' content
// Since I don't have unified_main.js, I rely on the existing environment setup.
// For now, let's ensure the MM studio buttons are clickable and try to trigger the MM initialization.
// Fallback attempt: if MM Studio UI function exists (from moore_mealy_ui.js) call it
if (window.initializeMMUI) {
window.initializeMMUI(); // Assumes MM studio UI is loaded/ready
}
}, 800);
});
}
// Default start (if no unified_main or external loader)
if (!faButton && !mmButton) {
startFaApp(); // This will try to load FA studio if no buttons are found, relying on external HTML injection
}
}
});