2022-05-30 18:54:42 +00:00
|
|
|
/**
|
|
|
|
* Initializes graphs on the website.
|
|
|
|
*
|
|
|
|
* @param {Array<[id: string, commands: string[], initializer: (any) => void]>} graphs
|
|
|
|
* The graphs to initialize.
|
|
|
|
*/
|
|
|
|
window.graphs = (graphs) => {
|
|
|
|
window.addEventListener(
|
|
|
|
"load",
|
|
|
|
() =>
|
|
|
|
{
|
|
|
|
for (let entry of graphs) {
|
|
|
|
new GGBApplet(
|
|
|
|
{
|
|
|
|
height: 250,
|
|
|
|
preventFocus: true,
|
|
|
|
perspective: "G",
|
|
|
|
enableFileFeatures: false,
|
|
|
|
appletOnLoad: (api) => {
|
|
|
|
for (let command of entry[1]) {
|
|
|
|
api.evalCommand(command);
|
|
|
|
}
|
2022-06-09 13:53:17 +00:00
|
|
|
|
2022-05-30 18:54:42 +00:00
|
|
|
for (let object of api.getAllObjectNames()) {
|
|
|
|
api.evalCommand(`ShowLabel(${object}, true)`);
|
|
|
|
}
|
2022-06-09 13:53:17 +00:00
|
|
|
|
|
|
|
(entry[2] ?? (() => {}))(api);
|
|
|
|
api.evalCommand("ZoomIn()");
|
|
|
|
(entry[3] ?? (() => {}))(api);
|
2022-05-30 18:54:42 +00:00
|
|
|
},
|
|
|
|
...(entry[2] ?? {})
|
|
|
|
},
|
|
|
|
true).inject(entry[0]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|