Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform != 'darwin') {
app.quit();
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
function requestHandler(req, res) {
var
file = req.url == '/' ? '/app.html' : req.url,
root = __dirname + '/',
page404 = root + '/404.html';
console.log((root + file))
getFile((root + file), res, page404);
};
// start a simple server that can serve an html page and resolve local file loading.
var server = http.createServer(requestHandler).listen(3000);
// Put the app on a secondary display if availalbe
var atomScreen = require('screen');
var displays = atomScreen.getAllDisplays();
// Report crashes to our server.
require('crash-reporter').start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;
app.on('window-all-closed', function() {
if(process.platform !== 'darwin') {
app.quit();
}
});
// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
// Register a 'ctrl+x' shortcut listener.
var ret = globalShortcut.register(process.platform === 'win32' ? 'ctrl+g' : 'cmd+g', function() {
console.log('cmd+g/ctrl+g is pressed');
console.log(clipboard.readText('selection'));
var url = clipboard.readText('selection');
mainWindow.webContents.executeJavaScript("addNewURL('"+url+"');");
});
if (!ret) {
console.log('registration failed');
}
if (app.dock) app.dock.hide();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
app.quit();
});
var Menu = require('menu');
// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
initWindow();
function initWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 1058, height: 640, resizable: false});
// and load the index.html of the app.
mainWindow.loadUrl(hosturl + '#/setup')
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
onNext = function (data) {
modeNext += 1;
switch (modeNext) {
case 1:
/* istanbul ignore next */
if (process.env.npm_config_mode_auto_restart) {
return;
}
// wait for electron to init
try {
require("app").on("ready", onNext);
} catch (ignore) {
require("electron").app.once("ready", onNext);
}
break;
case 2:
// init options
options = {
frame: false,
height: 768,
width: 1024,
x: 0,
y: 0
};
// init browserWindow;
try {
options.BrowserWindow = require("browser-window");
var target = path.basename(process.execPath);
switch (squirrelCommand) {
case "--squirrel-install":
case "--squirrel-updated":
updateCmd(["--createShortcut", target], app.quit);
break;
case "--squirrel-uninstall":
updateCmd(["--removeShortcut", target], app.quit);
break;
case "--squirrel-obsolete":
app.quit();
break;
}
}
app.on("ready", function() {
var appIcon = new Tray(iconIdle);
initWindow();
if (process.platform === "darwin") {
applySettings();
}
function initWindow() {
var defaults = {
frame: false,
height: 600,
resizable: false,
width: 360
};
appIcon.window = new BrowserWindow(defaults);