1
0
mirror of https://github.com/octoleo/plantuml-server.git synced 2024-06-07 02:40:51 +00:00
plantuml-server/src/main/webapp/components/app.js
Florian 478ef3bce7 front-end code refactoring
Since the front-end received much more code (features) than first expected, the files became much too large. For this reason, the JS and CSS code has now been split by component and thus into several small files. However, since there are now many small files, a JS and CSS bundle tool had to come :D.
2023-05-19 13:55:18 +02:00

47 lines
1.3 KiB
JavaScript

/*********************************
* PlantUML Server Application JS *
**********************************/
"use strict";
async function initApp() {
const view = new URL(window.location.href).searchParams.get("view")?.toLowerCase();
function initializeAppData() {
const analysedUrl = analyseUrl(window.location.href);
const code = document.editor?.getValue();
document.appData = Object.assign({}, window.opener?.document.appData);
if (Object.keys(document.appData).length === 0) {
document.appData = {
encodedDiagram: analysedUrl.encodedDiagram,
index: analysedUrl.index,
numberOfDiagramPages: (code) ? getNumberOfDiagramPagesFromCode(code) : 1,
};
}
}
await initEditor(view);
initializeAppData();
initTheme();
initAppCommunication();
await initPreview(view);
initModals(view);
if (document.editor) {
document.editor.focus();
if (document.appData.encodedDiagram == "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000") {
// if default `Bob -> Alice : hello` example mark example code for faster editing
document.editor.setSelection({
startLineNumber: 2,
endLineNumber: 2,
startColumn: 1,
endColumn: 21,
});
}
}
document.appConfig.autoRefreshState = "complete";
}
// main entry
window.onload = initApp;