diff options
Diffstat (limited to 'src/index.ts')
-rwxr-xr-x | src/index.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts new file mode 100755 index 0000000..f6d526f --- /dev/null +++ b/src/index.ts @@ -0,0 +1,41 @@ +import {ipcRenderer} from "electron"; +import {PrisbeamApp} from "./PrisbeamApp"; + +let loaded = false; + +window.onload = () => { + loaded = true; +} + +// noinspection JSUnusedGlobalSymbols +export function runApp(bootstrap: any) { + ipcRenderer.on('path', (_, appDataPath) => { + let instance = window['instance'] = new PrisbeamApp(bootstrap); + instance.dataStore.appData = appDataPath; + + let loadInterval = setInterval(() => { + if (loaded) { + clearInterval(loadInterval); + instance.loadApp(); + } + }); + + window.onclose = () => { + instance.dataStore.close = true; + } + + window.onbeforeunload = (e: DOMEvent) => { + if (instance.dataStore.database && !instance.dataStore.unloaded) { + e.preventDefault(); + instance.safeReload(); + } + }; + + document.getElementById("preview").addEventListener('hide.bs.modal', () => { + document.getElementById("preview-content").innerHTML = ""; + instance.display.updateTitle(); + }); + + instance.bootstrapTooltips(); + }); +} |