whois-team /
whoisdigger
| 1 | // jshint esversion: 8, -W104, -W069 |
||
| 2 | |||
| 3 | const electron = require('electron'), |
||
| 4 | url = require('url'), |
||
| 5 | debug = require('debug')('main'), |
||
| 6 | debugb = require('debug')('renderer'), |
||
| 7 | fs = require('fs'); |
||
| 8 | |||
| 9 | const { |
||
| 10 | app, |
||
| 11 | BrowserWindow, |
||
| 12 | Menu, |
||
| 13 | ipcMain, |
||
| 14 | dialog, |
||
| 15 | remote |
||
| 16 | } = electron; |
||
| 17 | |||
| 18 | require('./main/index'); |
||
| 19 | |||
| 20 | var settings = require('./common/settings').load(); |
||
| 21 | let mainWindow; |
||
| 22 | |||
| 23 | /* |
||
| 24 | app.on('ready', function() {...} |
||
| 25 | When application is ready |
||
| 26 | */ |
||
| 27 | app.on('ready', function() { |
||
| 28 | const { |
||
| 29 | 'custom.configuration': configuration, |
||
| 30 | 'app.window': appWindow, |
||
| 31 | 'app.window.webPreferences': webPreferences, |
||
| 32 | 'app.window.url': appUrl |
||
| 33 | } = settings; |
||
| 34 | |||
| 35 | // Custom application settings startup |
||
| 36 | if (fs.existsSync(app.getPath('userData') + configuration.filepath)) { |
||
|
0 ignored issues
–
show
|
|||
| 37 | debug("Reading persistent configurations"); |
||
| 38 | settings = fs.readFile(app.getPath('userData') + configuration.filepath); |
||
| 39 | } else { |
||
| 40 | debug("Using default configurations"); |
||
| 41 | } |
||
| 42 | |||
| 43 | // Some application start debugging messages |
||
| 44 | debug("App is starting"); |
||
| 45 | debug("'appWindow.frame': {0}".format(appWindow.frame)); |
||
|
0 ignored issues
–
show
The variable
appWindow seems to be never declared. If this is a global, consider adding a /** global: appWindow */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 46 | debug("'appWindow.height': {0}".format(appWindow.height)); |
||
| 47 | debug("'appWindow.width': {0}".format(appWindow.width)); |
||
| 48 | |||
| 49 | // mainWindow, Main application window initialization |
||
| 50 | mainWindow = new BrowserWindow({ |
||
| 51 | frame: appWindow.frame, // Is basic frame shown (default: false) |
||
| 52 | show: appWindow.show, // Show app before load (default: false) |
||
| 53 | height: appWindow.height, // Window height in pixels (default: 700) |
||
| 54 | width: appWindow.width, // Window width in pixels (default: 1000) |
||
| 55 | icon: appWindow.icon, // App icon path (default: ...app.png) |
||
| 56 | center: appWindow.center, // Center window |
||
| 57 | minimizable: appWindow.minimizable, // Make window minimizable |
||
| 58 | maximizable: appWindow.maximizable, // Make window maximizable |
||
| 59 | movable: appWindow.movable, // Make window movable |
||
| 60 | resizable: appWindow.resizable, // Make window resizable |
||
| 61 | closable: appWindow.closable, // Make window closable |
||
| 62 | focusable: appWindow.focusable, // Make window focusable |
||
| 63 | alwaysOnTop: appWindow.alwaysOnTop, // Keep window on top |
||
| 64 | fullscreen: appWindow.fullscreen, // Show window in fullscreen |
||
| 65 | fullscreenable: appWindow.fullscreenable, // Make window able to go fullscreen |
||
| 66 | kiosk: appWindow.kiosk, // Enable kiosk mode |
||
| 67 | darkTheme: appWindow.darkTheme, // GTK dark theme mode |
||
| 68 | thickFrame: appWindow.thickFrame, // Use WS_THICKFRAME style for frameless windows on Windows, which adds standard window frame. Setting it to false will remove window shadow and window animations. |
||
| 69 | webPreferences: { |
||
| 70 | nodeIntegration: webPreferences.nodeIntegration, // Enable node integration |
||
|
0 ignored issues
–
show
The variable
webPreferences seems to be never declared. If this is a global, consider adding a /** global: webPreferences */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 71 | contextIsolation: webPreferences.contextIsolation, // Context isolation |
||
| 72 | zoomFactor: webPreferences.zoomFactor, // Page zoom factor |
||
| 73 | image: webPreferences.image, // Image support |
||
| 74 | experimentalFeatures: webPreferences.experimentalFeatures, // Enable Chromium experimental features |
||
| 75 | backgroundThrottling: webPreferences.backgroundThrottling, // Whether to throttle animations and timers when the page becomes background |
||
| 76 | offscreen: webPreferences.offscreen, // enable offscreen rendering for the browser window |
||
| 77 | spellcheck: webPreferences.spellcheck, // Enable builtin spellchecker |
||
| 78 | enableRemoteModule: webPreferences.enableRemoteModule // Enable remote module |
||
| 79 | } |
||
| 80 | }); |
||
| 81 | |||
| 82 | // mainWindow, Main window URL load |
||
| 83 | mainWindow.loadURL(url.format({ |
||
| 84 | pathname: appUrl.pathname, |
||
|
0 ignored issues
–
show
The variable
appUrl seems to be never declared. If this is a global, consider adding a /** global: appUrl */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 85 | protocol: appUrl.protocol, |
||
| 86 | slashes: appUrl.slashes |
||
| 87 | })); |
||
| 88 | |||
| 89 | // Some more debugging messages |
||
| 90 | debug("'settings.url.protocol': {0}".format(appUrl.protocol)); |
||
| 91 | debug("'settings.url.pathname': {0}".format(appUrl.pathname)); |
||
| 92 | debug("'mainWindow' object: %o", mainWindow); |
||
| 93 | |||
| 94 | /* |
||
| 95 | mainWindow.once('ready-to-show', function() {...}); |
||
| 96 | Show main window when everything is ready |
||
| 97 | */ |
||
| 98 | mainWindow.once('ready-to-show', function() { |
||
| 99 | startup(); |
||
| 100 | debug('Showing main window'); |
||
| 101 | mainWindow.show(); |
||
| 102 | |||
| 103 | return; |
||
|
0 ignored issues
–
show
|
|||
| 104 | }); |
||
| 105 | |||
| 106 | /* |
||
| 107 | mainWindow.on('closed', function() {...}); |
||
| 108 | Quit application when main window is closed |
||
| 109 | */ |
||
| 110 | mainWindow.on('closed', function() { |
||
| 111 | var { |
||
| 112 | 'app.window': appWindow |
||
| 113 | } = settings; |
||
| 114 | |||
| 115 | if (appWindow.closable) { |
||
|
0 ignored issues
–
show
The variable
appWindow seems to be never declared. If this is a global, consider adding a /** global: appWindow */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 116 | debug('Exiting application'); |
||
| 117 | app.quit(); |
||
| 118 | } |
||
| 119 | |||
| 120 | return; |
||
|
0 ignored issues
–
show
|
|||
| 121 | }); |
||
| 122 | |||
| 123 | return; |
||
|
0 ignored issues
–
show
|
|||
| 124 | }); |
||
| 125 | |||
| 126 | /* |
||
| 127 | startup |
||
| 128 | Main thread startup checks |
||
| 129 | */ |
||
| 130 | function startup() { |
||
| 131 | const { |
||
| 132 | 'startup': startup |
||
| 133 | } = settings; |
||
| 134 | |||
| 135 | debug('Doing startup checks'); |
||
| 136 | debug("'settings.startup.developerTools': {0}".format(startup.developerTools)); |
||
| 137 | if (startup.developerTools) mainWindow.toggleDevTools(); |
||
| 138 | |||
| 139 | return; |
||
|
0 ignored issues
–
show
|
|||
| 140 | } |
||
| 141 | |||
| 142 | /* |
||
| 143 | ipcMain.on('app:minimize', function() {...}); |
||
| 144 | Application minimize event |
||
| 145 | */ |
||
| 146 | ipcMain.on('app:minimize', function() { |
||
| 147 | var { |
||
| 148 | 'app.window': appWindow |
||
| 149 | } = settings; |
||
| 150 | if (appWindow.minimizable) { |
||
|
0 ignored issues
–
show
The variable
appWindow seems to be never declared. If this is a global, consider adding a /** global: appWindow */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 151 | debug("App minimized"); |
||
| 152 | mainWindow.minimize(); |
||
| 153 | } |
||
| 154 | |||
| 155 | return; |
||
|
0 ignored issues
–
show
|
|||
| 156 | }); |
||
| 157 | |||
| 158 | /* |
||
| 159 | ipcMain.on('app:debug', function(...) {...}); |
||
| 160 | Application debug event |
||
| 161 | */ |
||
| 162 | ipcMain.on('app:debug', function(event, message) { |
||
| 163 | debugb(message); |
||
| 164 | |||
| 165 | return; |
||
|
0 ignored issues
–
show
|
|||
| 166 | }); |
||
| 167 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.