diff --git a/front-end/js/app.js b/front-end/js/app.js index 30aa939..8e15622 100644 --- a/front-end/js/app.js +++ b/front-end/js/app.js @@ -13,9 +13,9 @@ const CONSTANTS = { pollTime: 1000 }; -var isFlashing = false; +let isFlashing = false; -var last_notification = ""; +let last_notification = ""; /************************ * Backend dependencies. @@ -257,7 +257,7 @@ function updateProgressBar(percent, svg){ finishDot.style.opacity = 0; } - for(var i = 0; i < percent * (bgLine.points.numberOfItems / 100); i ++) { + for(let i = 0; i < percent * (bgLine.points.numberOfItems / 100); i ++) { if(i < bgLine.points.numberOfItems) { const point = bgLine.points.getItem(i); const newPoint = svg.createSVGPoint(); diff --git a/index.js b/index.js index 333e199..e40f76a 100644 --- a/index.js +++ b/index.js @@ -13,22 +13,24 @@ const BrowserWindow = electron.BrowserWindow; // Module to create native browse const checkDialout = require("./back-end/checkDialout"); // 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; +let mainWindow = null; // Quit when all windows are closed. -app.on('window-all-closed', function() { +app.on('window-all-closed', () => { // 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') { + if (process.platform !== 'darwin') { app.quit(); } }); -var launchApp = function() { - // load the index.html of the app. - mainWindow.loadURL('file://' + __dirname + '/front-end/index.html'); - +function launchApp() { + //Clears any crusty downloads/API calls + mainWindow.webContents.session.clearCache(() => { + // load the index.html of the app. + mainWindow.loadURL('file://' + __dirname + '/front-end/index.html'); + }); } function launchLinuxHelper() { @@ -38,7 +40,7 @@ function launchLinuxHelper() { // This method will be called when Electron has finished // initialization and is ready to create browser windows. -app.on('ready', function() { +app.on('ready', function () { // Create the browser window. mainWindow = new BrowserWindow({ width: 520, @@ -48,23 +50,23 @@ app.on('ready', function() { 'accept-first-mouse': true }); - if(process.platform === "linux") { - checkDialout(launchApp, (err) => { - if(err.message === checkDialout.ERROR_MESSAGES.USER_NOT_IN_DIALOUT) { - launchLinuxHelper(); - } else { - //TODO: When another error occurs propogate the error somehow. - launchApp(); - } - }); + if (process.platform === "linux") { + checkDialout(launchApp, (err) => { + if (err.message === checkDialout.ERROR_MESSAGES.USER_NOT_IN_DIALOUT) { + launchLinuxHelper(); + } else { + //TODO: When another error occurs propogate the error somehow. + launchApp(); + } + }); } else { - launchApp(); + launchApp(); } // Open the DevTools. // mainWindow.webContents.openDevTools(); // Emitted when the window is closed. - mainWindow.on('closed', function() { + mainWindow.on('closed', () => { // 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. @@ -86,17 +88,17 @@ function handleSquirrelEvent() { const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe')); const exeName = path.basename(process.execPath); - const spawn = function(command, args) { + const spawn = function (command, args) { let spawnedProcess, error; try { - spawnedProcess = ChildProcess.spawn(command, args, {detached: true}); - } catch (error) {} + spawnedProcess = ChildProcess.spawn(command, args, { detached: true }); + } catch (error) { } return spawnedProcess; }; - const spawnUpdate = function(args) { + const spawnUpdate = function (args) { return spawn(updateDotExe, args); };