Skip to content

Commit 2b8ecc0

Browse files
Revert "Add cross-simulation event orchestration: EventBus, ScenarioEngine, always-alive mounting, tab badges"
This reverts commit 182795b.
1 parent 182795b commit 2b8ecc0

25 files changed

Lines changed: 36 additions & 3496 deletions

client/app.js

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1+
// app.js
12
import Modal from './design-system/components/modal/modal.js';
2-
import SimulationLoader from './simulation-loader.js';
3-
import EventBus from './event-bus.js';
4-
import TabNotifier from './tab-notifier.js';
5-
import ScenarioEngine from './scenario-engine.js';
63

74
let websocket = null;
85
let helpModal = null;
9-
let loader = null;
10-
let eventBus = null;
11-
let notifier = null;
12-
let scenarioEngine = null;
136

7+
// Initialize WebSocket connection
148
function initializeWebSocket() {
159
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
1610
const host = window.location.host;
@@ -19,41 +13,39 @@ function initializeWebSocket() {
1913
try {
2014
websocket = new WebSocket(wsUrl);
2115

22-
websocket.onopen = () => {
16+
websocket.onopen = function(event) {
2317
console.log('WebSocket connected');
2418
};
2519

26-
websocket.onmessage = (event) => {
20+
websocket.onmessage = function(event) {
2721
try {
2822
const data = JSON.parse(event.data);
2923
if (data.type === 'message' && data.message) {
30-
if (loader) {
31-
loader.sendMessage(data);
32-
} else {
33-
alert(data.message);
34-
}
24+
alert(data.message);
3525
}
3626
} catch (error) {
3727
console.error('Error parsing WebSocket message:', error);
3828
}
3929
};
4030

41-
websocket.onclose = () => {
31+
websocket.onclose = function(event) {
4232
console.log('WebSocket disconnected');
33+
// Attempt to reconnect after 3 seconds
4334
setTimeout(() => {
4435
console.log('Attempting to reconnect WebSocket...');
4536
initializeWebSocket();
4637
}, 3000);
4738
};
4839

49-
websocket.onerror = (error) => {
40+
websocket.onerror = function(error) {
5041
console.error('WebSocket error:', error);
5142
};
5243
} catch (error) {
5344
console.error('Failed to create WebSocket connection:', error);
5445
}
5546
}
5647

48+
// Load help content and initialize modal
5749
async function initializeHelpModal() {
5850
try {
5951
const response = await fetch('./help-content.html');
@@ -66,13 +58,15 @@ async function initializeHelpModal() {
6658

6759
const helpButton = document.getElementById('btn-help');
6860
if (helpButton) {
69-
helpButton.addEventListener('click', () => helpModal.open());
61+
helpButton.addEventListener('click', () => {
62+
helpModal.open();
63+
});
7064
}
7165
} catch (error) {
7266
console.error('Failed to load help content:', error);
7367
helpModal = Modal.createHelpModal({
7468
title: 'Help / User Guide',
75-
content: '<p>Help content could not be loaded.</p>'
69+
content: '<p>Help content could not be loaded. Please check that help-content.html exists.</p>'
7670
});
7771
const helpButton = document.getElementById('btn-help');
7872
if (helpButton) {
@@ -81,59 +75,14 @@ async function initializeHelpModal() {
8175
}
8276
}
8377

84-
async function initializeSimulations() {
85-
const containerEl = document.getElementById('sim-container');
86-
const tabBarEl = document.getElementById('sim-tab-bar');
87-
88-
eventBus = new EventBus();
89-
90-
loader = new SimulationLoader({
91-
containerEl,
92-
tabBarEl,
93-
eventBus,
94-
onActivate: (simId) => {
95-
console.log(`Simulation activated: ${simId}`);
96-
if (notifier) notifier.clearBadge(simId);
97-
},
98-
onDeactivate: (simId) => {
99-
console.log(`Simulation deactivated: ${simId}`);
100-
}
101-
});
102-
103-
notifier = new TabNotifier(loader);
104-
scenarioEngine = new ScenarioEngine({ eventBus, loader, notifier });
105-
106-
try {
107-
const configRes = await fetch('/simulations/simulations.json');
108-
const config = await configRes.json();
109-
110-
await loader.loadConfig('/simulations/simulations.json');
111-
112-
const urlParams = new URLSearchParams(window.location.search);
113-
const scenarioParam = urlParams.get('scenario') || config.scenario;
114-
if (scenarioParam) {
115-
await scenarioEngine.loadScenario(`/simulations/scenarios/${scenarioParam}.js`);
116-
}
117-
} catch (error) {
118-
console.error('Failed to load simulations config:', error);
119-
containerEl.innerHTML = `
120-
<div class="sim-empty">
121-
<p>No simulations configured. Place simulations.json in the simulations/ directory.</p>
122-
</div>
123-
`;
124-
}
125-
}
126-
78+
// Initialize both help modal and WebSocket when DOM is ready
12779
async function initialize() {
12880
await initializeHelpModal();
12981
initializeWebSocket();
130-
await initializeSimulations();
13182
}
13283

13384
if (document.readyState === 'loading') {
13485
document.addEventListener('DOMContentLoaded', initialize);
13586
} else {
13687
initialize();
13788
}
138-
139-
export { eventBus, loader, notifier, scenarioEngine };

client/event-bus.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

client/index.html

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<title>Simulations</title>
5+
<title><!-- APP_TITLE --></title>
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<!-- Fonts (Work Sans) -->
88
<link rel="preconnect" href="https://fonts.googleapis.com">
@@ -22,27 +22,24 @@
2222
<link rel="stylesheet" href="./design-system/components/tags/tags.css">
2323
<link rel="stylesheet" href="./design-system/components/modal/modal.css">
2424

25-
<!-- Template + Host styles -->
25+
<!-- Template-specific components (layout, utilities, temporary components) -->
2626
<link rel="stylesheet" href="./bespoke-template.css" />
27-
<link rel="stylesheet" href="./super-simulation.css" />
27+
<!-- APP_SPECIFIC_CSS -->
2828
</head>
2929
<body class="bespoke">
3030
<!-- Navigation Header -->
3131
<header class="header">
32-
<h1 class="heading-small">Simulations</h1>
33-
<nav class="sim-tab-bar" id="sim-tab-bar"></nav>
32+
<h1 class="heading-small">APP NAME</h1>
33+
<!-- APP_SPECIFIC_HEADER_CONTENT -->
3434
<div class="spacer"></div>
3535
<button id="btn-help" class="button button-text">Help</button>
3636
</header>
3737

38-
<!-- Simulation Container -->
39-
<main class="sim-container" id="sim-container">
40-
<div class="sim-empty" id="sim-empty">
41-
<p>Select a simulation tab to begin.</p>
42-
</div>
43-
</main>
38+
<!-- Main Application Content -->
39+
<!-- APP_SPECIFIC_MAIN_CONTENT -->
4440

4541
<!-- Core Scripts -->
4642
<script type="module" src="./app.js"></script>
43+
<!-- APP_SPECIFIC_SCRIPTS -->
4744
</body>
4845
</html>

client/scenario-engine.js

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)