fixed some jshint complaints

This commit is contained in:
tigerbot 2017-05-19 13:19:43 -06:00
parent ea55a90883
commit c9fa8fdc37
10 changed files with 92 additions and 94 deletions

View File

@ -1,3 +1,5 @@
'use strict';
var electron = require('electron');
// This file should be included from the main thread and every renderer thread.

View File

@ -1,9 +1,48 @@
'use strict';
var electron = require('electron');
var app = electron.app;
var ipc = electron.ipcMain;
var argv = sliceArgv(process.argv);
var win;
function sliceArgv(argv) {
var count = 1;
// We need to determine if we were run using electron or as a system installed app.
if (argv[0].search('electron') >= 0) {
count += 1;
}
return argv.slice(count);
}
var argv = sliceArgv(process.argv);
function processArgv(argv) {
var files = [];
argv.forEach(function(arg) {
if (arg.substr(0, 2) === '--') {
console.log('received argument', arg);
} else {
files.push(arg);
}
});
if (files.length > 0) {
win.webContents.send('files', files);
}
}
function onOpen(e, filename) {
e.preventDefault();
if (app.ipcReady) {
processArgv([ filename ]);
} else {
argv.push(filename);
}
}
app.on('open-file', onOpen);
app.on('open-url', onOpen);
function init(window) {
if (win) {
console.error("can't initiliaze drag-and-drop multiple times");
@ -17,39 +56,4 @@ function init(window) {
});
}
app.on('open-file', onOpen);
app.on('open-url', onOpen);
function onOpen(e, filename) {
e.preventDefault();
if (app.ipcReady) {
processArgv([ filename ]);
} else {
argv.push(filename);
}
}
function sliceArgv(argv) {
var count = 1;
// We need to determine if we were run using electron or as a system installed app.
if (argv[0].search('electron') >= 0) {
count += 1;
}
return argv.slice(count);
}
function processArgv(argv) {
var files = [];
argv.forEach(function(arg) {
if (arg.substr(0 ,2) == '--') {
console.log('received argument', arg);
} else {
files.push(arg);
}
});
if (files.length > 0) {
win.webContents.send('files', files);
}
}
module.exports.init = init;

View File

@ -1,3 +1,5 @@
'use strict';
var electron = require('electron');
var ipc = electron.ipcRenderer;

View File

@ -1,3 +1,5 @@
'use strict';
var electron = require('electron');
var app = electron.app;
var BrowserWindow = electron.BrowserWindow;

26
menu.js
View File

@ -1,5 +1,6 @@
'use strict';
var electron = require('electron');
var app = electron.app;
var win, menu;
@ -14,25 +15,6 @@ function getMenuItem (label) {
return menuItem || {};
}
function updateFullScreenCheckbox() {
getMenuItem('Full Screen').checked = win.isFullScreen();
win.setMenuBarVisibility(!win.isFullScreen());
}
function toggleFullScreen(flag) {
if (!win || !win.isVisible()) {
return;
}
if (typeof flag !== 'boolean') {
flag = !win.isFullScreen();
}
if (flag) {
// Fullscreen and aspect ratio do not play well together. (Mac)
win.setAspectRatio(0);
}
win.setFullScreen(flag);
}
// Sets whether the window should always show on top of other windows
function toggleAlwaysOnTop(flag) {
if (!win) {
@ -209,10 +191,6 @@ function init(window) {
menu = electron.Menu.buildFromTemplate(template);
electron.Menu.setApplicationMenu(menu);
win.webContents.on('dom-ready', updateFullScreenCheckbox);
win.on('enter-full-screen', updateFullScreenCheckbox);
win.on('leave-full-screen', updateFullScreenCheckbox);
}
module.exports.init = init;

View File

@ -1,3 +1,5 @@
'use strict';
var electron = require('electron');
var ipc = electron.ipcRenderer;
// This file runs in a render thread of the Electron app. It must be required (directly or

View File

@ -1,23 +1,11 @@
'use strict';
var electron = require('electron');
var app = electron.app;
var ipc = electron.ipcMain;
var win;
function init(window) {
if (win) {
console.error("can't initialize badge/progress tracker multiple times");
return;
}
win = window;
ipc.on('notification', function (ev, count, target) {
updateProgress(count, target);
increaseBadge();
});
win.on('focus', clearBadge);
}
function increaseBadge() {
if (!win.isFocused()) {
app.setBadgeCount(app.getBadgeCount() + 1);
@ -35,4 +23,18 @@ function updateProgress(count, target) {
}
}
function init(window) {
if (win) {
console.error("can't initialize badge/progress tracker multiple times");
return;
}
win = window;
ipc.on('notification', function (ev, count, target) {
updateProgress(count, target);
increaseBadge();
});
win.on('focus', clearBadge);
}
module.exports.init = init;

View File

@ -1,3 +1,5 @@
'use strict';
var AutoLaunch = require('auto-launch');
var electron = require('electron');
var app = electron.app;
@ -18,6 +20,26 @@ var appLauncher = new AutoLaunch({
isHidden: true
});
function install () {
return appLauncher
.isEnabled()
.then(function (enabled) {
if (!enabled) {
return appLauncher.enable();
}
});
}
function uninstall () {
return appLauncher
.isEnabled()
.then(function (enabled) {
if (enabled) {
return appLauncher.disable();
}
});
}
var win;
function init(window) {
if (win) {
@ -42,26 +64,6 @@ function init(window) {
});
}
function install () {
return appLauncher
.isEnabled()
.then(function (enabled) {
if (!enabled) {
return appLauncher.enable();
}
});
}
function uninstall () {
return appLauncher
.isEnabled()
.then(function (enabled) {
if (enabled) {
return appLauncher.disable();
}
});
}
module.exports = {
init: init,
};

View File

@ -1,3 +1,5 @@
'use strict';
var electron = require('electron');
var ipc = electron.ipcRenderer;

View File

@ -1,3 +1,5 @@
'use strict';
var path = require('path');
var electron = require('electron');
var app = electron.app;