2023-05-08 12:25:13 -07:00
|
|
|
/**
|
|
|
|
* This file will automatically be loaded by vite and run in the "renderer" context.
|
|
|
|
* To learn more about the differences between the "main" and the "renderer" context in
|
|
|
|
* Electron, visit:
|
|
|
|
*
|
|
|
|
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
|
|
|
|
*
|
|
|
|
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
|
|
|
|
* in a renderer process, please be aware of potential security implications. You can read
|
|
|
|
* more about security risks here:
|
|
|
|
*
|
|
|
|
* https://electronjs.org/docs/tutorial/security
|
|
|
|
*
|
|
|
|
* To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`
|
|
|
|
* flag:
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* // Create the browser window.
|
|
|
|
* mainWindow = new BrowserWindow({
|
|
|
|
* width: 800,
|
|
|
|
* height: 600,
|
|
|
|
* webPreferences: {
|
|
|
|
* nodeIntegration: true
|
|
|
|
* }
|
|
|
|
* });
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
|
2023-05-09 16:05:58 -07:00
|
|
|
import 'bootstrap/dist/css/bootstrap.css'
|
2023-05-09 12:55:15 -07:00
|
|
|
import './assets/index.css'
|
2023-05-08 17:42:09 -07:00
|
|
|
import './icons/flaticon.css'
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-08 17:42:09 -07:00
|
|
|
const { app } = require('electron')
|
2023-05-08 12:25:13 -07:00
|
|
|
import { JournalInterface } from './interfaces/JournalInterface'
|
2023-05-09 12:55:15 -07:00
|
|
|
import { createBodyRow } from './ui'
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-08 17:42:09 -07:00
|
|
|
// Grab app.isPackaged from main process
|
|
|
|
let isPackaged = false
|
|
|
|
window.process.argv.forEach((item) => {
|
|
|
|
if (item.includes('EDS-ENV')) {
|
|
|
|
isPackaged = (item.split('=').pop() === 'true')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
/* ------------------------------------------------------------------------------- app setup ---- */
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
const journal = new JournalInterface(isPackaged)
|
2023-05-08 13:10:38 -07:00
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
if (journal.journalDir === null) {
|
|
|
|
// handle error
|
|
|
|
}
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
journal.watchDirectory()
|
|
|
|
journal.watchJournal()
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-09 13:40:32 -07:00
|
|
|
/* --------------------------------------------------------------------------- init complete ---- */
|
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
journal.once('INIT_COMPLETE', () => {
|
|
|
|
if (journal.location !== null) {
|
|
|
|
$('#currentSystem')
|
|
|
|
.addClass('charted')
|
|
|
|
.removeClass('highlighted text-center')
|
2023-05-08 17:42:09 -07:00
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
$('#currentSystemName').text(journal.location.name)
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
$('#currentSystemIcon').removeClass('hidden')
|
2023-05-08 12:25:13 -07:00
|
|
|
}
|
2023-05-09 12:55:15 -07:00
|
|
|
|
|
|
|
if (journal.location.bodies.length > 0) {
|
|
|
|
journal.location.bodies.forEach((body) => {
|
|
|
|
const row = createBodyRow(body)
|
|
|
|
$('#lowValueScans').appendChild(row)
|
|
|
|
})
|
|
|
|
}
|
2023-05-09 13:40:32 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- entered new system ---- */
|
|
|
|
|
|
|
|
journal.on('ENTERED_NEW_SYSTEM', () => {
|
|
|
|
$('#highValueScans').children().remove()
|
|
|
|
$('#lowValueScans').children().remove()
|
|
|
|
|
|
|
|
$('#currentSystemName').text(journal.location.name)
|
2023-05-09 16:05:58 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- body scan detected ---- */
|
|
|
|
|
|
|
|
journal.on('BODY_SCANNED', (body, DSS) => {
|
|
|
|
// If this is a DSS scan, it's very likely that the body already exists in our list so we just
|
|
|
|
// need to remove the highlighting if applicable
|
|
|
|
if (DSS) {
|
|
|
|
const bodyRow = $(`#${body.BodyID}`)
|
|
|
|
|
|
|
|
if (bodyRow.length > 0) {
|
|
|
|
bodyRow.removeClass('highlighted uncharted').addClass('charted')
|
|
|
|
}
|
|
|
|
}
|
2023-05-09 12:55:15 -07:00
|
|
|
})
|