diff --git a/README.md b/README.md index 0093063..d645457 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,5 @@ * Ronaldson Bellande -# USE CASE --------------------------------------------------------------------------------------------------------- -* The Organization Website Application is accessible for complimentary download and installation. It is imperative to note that the source code responsible for creating this application is governed by a specific license agreement. This license restricts the utilization of the code for any purposes other than those explicitly permitted, necessitating prior authorization for any deviation from its prescribed usage. Consequently, users are encouraged to respect and adhere to the terms and conditions outlined in the license agreement to ensure compliance with the software's legal framework --------------------------------------------------------------------------------------------------------- - ## License This package is distributed under the [GPL-3.0 license](https://www.gnu.org/licenses/gpl-3.0.en.html), see [LICENSE](https://github.com/https://github.com/Robotics-Sensors/organization-robotics-sensors-website-application/blob/main/LICENSE) and [NOTICE](https://github.com/https://github.com/Robotics-Sensors/organization-robotics-sensors-website-application/blob/main/LICENSE) for more information. diff --git a/scripts/index.js b/scripts/index.js index 8bba788..3a3b1c6 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -1,119 +1,47 @@ -const { app, globalShortcut, BrowserWindow, session } = require('electron'); -const path = require('path'); -const { switchFullscreenState } = require('./windowManager.js'); +const { app, BrowserWindow } = require('electron'); -var homePage = 'https://robotics-sensors.github.io'; -var userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.3'; +// Application configuration +const appConfig = { + homePageURL: 'https://robotics-sensors.github.io', + userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.3', +}; -console.log('Using user agent: ' + userAgent); -console.log('Process arguments: ' + process.argv); +console.log(`Using user agent: ${appConfig.userAgent}`); +console.log(`Process arguments: ${process.argv}`); +// Configure Electron command line switches app.commandLine.appendSwitch('enable-features', 'VaapiVideoDecoder,WaylandWindowDecorations,RawDraw'); - -app.commandLine.appendSwitch( - 'disable-features', - 'UseChromeOSDirectVideoDecoder' -); +app.commandLine.appendSwitch('disable-features', 'UseChromeOSDirectVideoDecoder'); app.commandLine.appendSwitch('enable-accelerated-mjpeg-decode'); -app.commandLine.appendSwitch('enable-accelerated-video'); -app.commandLine.appendSwitch('ignore-gpu-blocklist'); -app.commandLine.appendSwitch('enable-native-gpu-memory-buffers'); -app.commandLine.appendSwitch('enable-gpu-rasterization'); -app.commandLine.appendSwitch('enable-zero-copy'); -app.commandLine.appendSwitch('enable-gpu-memory-buffer-video-frames'); -app.commandLine.appendSwitch('use-gl'); -async function createWindow() { +// Create the main application window +async function createMainWindow() { const mainWindow = new BrowserWindow({ fullscreenable: true, webPreferences: { - preload: path.join(__dirname, 'preload.js'), contextIsolation: false, - userAgent: userAgent, + userAgent: appConfig.userAgent, }, }); - if (process.argv.includes('--direct-start')) { - mainWindow.loadURL(homePage); - } else { - mainWindow.loadURL(homePage); - } - + await mainWindow.loadURL(appConfig.homePageURL); + return mainWindow; } +// Initialize the application app.whenReady().then(async () => { - createWindow(); + await createMainWindow(); - app.on('activate', async function() { + app.on('activate', async () => { if (BrowserWindow.getAllWindows().length === 0) { - createWindow(); + await createMainWindow(); } }); - const { globalShortcut, BrowserWindow } = require('electron'); - - // Register global shortcuts - const window = BrowserWindow.getAllWindows()[0]; - globalShortcut.register('Super+F', async () => { - switchFullscreenState(window); - }); - - globalShortcut.register('F11', async () => { - switchFullscreenState(window); - }); - - globalShortcut.register('Alt+F4', async () => { - app.quit(); - }); - - globalShortcut.register('Alt+Home', async () => { - window.loadURL(homePage); - }); - - globalShortcut.register('F4', async () => { - app.quit(); - }); - - globalShortcut.register('Control+Shift+I', () => { - window.webContents.toggleDevTools(); - }); - - globalShortcut.register('Esc', async () => { - // Handle 'Esc' key press event - window.webContents.sendInputEvent({ - type: 'keyDown', - keyCode: 'Esc' - }); - window.webContents.sendInputEvent({ - type: 'char', - keyCode: 'Esc' - }); - window.webContents.sendInputEvent({ - type: 'keyUp', - keyCode: 'Esc' - }); - }); -}); - -app.on('browser-window-created', async function(e, window) { - window.setBackgroundColor('#1A1D1F'); - window.setMenu(null); - - window.webContents.setUserAgent(userAgent); - - window.webContents.on('new-window', (event, url) => { - event.preventDefault(); - BrowserWindow.getAllWindows()[0].loadURL(url); + // Quit the application when all windows are closed + app.on('window-all-closed', async () => { + if (process.platform !== 'darwin') { + app.quit(); + } }); - -}); - -app.on('will-quit', async () => { - globalShortcut.unregisterAll(); -}); - -app.on('window-all-closed', async function() { - if (process.platform !== 'darwin') { - app.quit(); - } });