antigrav_lab/js/main.js

44 lines
1.4 KiB
JavaScript

/**
* Main Application Entry Point.
* Non-module version.
*/
document.addEventListener('DOMContentLoaded', () => {
console.log('Antigravity Plotter Initializing...');
// Basic error check for dependencies
if (typeof DataGenerator === 'undefined' || typeof Plotter === 'undefined') {
document.getElementById('loading').innerHTML = "Script Error: JS files not loaded correctly.<br>Check console (F12) for details.";
return;
}
try {
// Initialize Plotter
const plotter = new Plotter('plotCanvas');
// Data Load Logic
const loadData = async () => {
try {
document.getElementById('status-text').textContent = "Status: Loading Data...";
const { labels, data } = await DataLoader.loadBinary('simulation.bin');
plotter.update(labels, data);
document.getElementById('status-text').textContent = "Status: Data Loaded (" + data.length + " points)";
} catch (err) {
console.error(err);
document.getElementById('status-text').textContent = "Error: " + err.message;
}
};
// Initial Load
loadData();
// Expose refresh for button
window.refreshPlot = loadData;
} catch (e) {
console.error(e);
document.getElementById('loading').textContent = "Runtime Error: " + e.message;
}
});