es6
es6

file:a/main.js -> file:b/main.js
--- a/main.js
+++ b/main.js
@@ -16,10 +16,10 @@
 
 function createWindow() {
     // Create the browser window.
-    var electronScreen = electron.screen;
-    var size = electronScreen.getPrimaryDisplay().workAreaSize;
-    var width = 9 * size.width/10;
-    var height = 9 * size.height/10;
+    let electronScreen = electron.screen;
+    let size = electronScreen.getPrimaryDisplay().workAreaSize;
+    let width = 9 * size.width/10;
+    let height = 9 * size.height/10;
     mainWindow = new BrowserWindow({width: width, height: height, show: true, skipTaskbar: true});
     //mainWindow = new BrowserWindow({width: 1000, height: 800, show: false});
 
@@ -63,9 +63,9 @@
         icon: 'icon.ico'
     });*/
 
-    var ap = new AppMenus(mainWindow, electron).render();
+    let ap = new AppMenus(mainWindow, electron).render();
 
-    var accelerator = 'CmdOrCtrl+Shift+D';
+    let accelerator = 'CmdOrCtrl+Shift+D';
     if (globalShortcut.isRegistered(accelerator) == false) {
         globalShortcut.register(accelerator, function() {
             mainWindow.show();
@@ -98,7 +98,7 @@
     }
 });
 
-var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
+let shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
     if (mainWindow) {
         mainWindow.show();
         if (mainWindow.isMinimized()) mainWindow.restore();

file:a/menus.js -> file:b/menus.js
--- a/menus.js
+++ b/menus.js
@@ -1,171 +1,172 @@
 'use strict';
 
+let mainWindow;
 let app;
 let Menu;
 let Tray;
 let globalShortcut;
-let mainWindow;
 
-function AppMenus(win, electron){
-    mainWindow = win;
-    app = electron.app;
-    Menu = electron.Menu;
-    Tray = electron.Tray;
-    globalShortcut = electron.globalShortcut;
+class AppMenus {
+    constructor(win, electron) {
+        mainWindow = win;
+        app = electron.app;
+        Menu = electron.Menu;
+        Tray = electron.Tray;
+        globalShortcut = electron.globalShortcut;
+        return this;
+    }
 
-    return this;
-}
+    tray() {
+        let appIcon = null;
+        appIcon = new Tray('app.ico');
+        let contextMenu = Menu.buildFromTemplate([
+            {
+                label: 'Show',
+                accelerator: 'CmdOrCtrl+Shift+D',
+                click: function() {
+                    mainWindow.show();
+                }
+            },
+            {
+                label: 'Toggle DevTools',
+                click: function() {
+                    mainWindow.show();
+                    mainWindow.toggleDevTools();
+                }
+            },
+            {
+                label: 'Quit',
+                selector: 'terminate:',
+                click: function() {
+                    app.exit(0);
+                }
+            }
+        ]);
+        appIcon.setToolTip('DeadlineApp by Webstyler');
+        appIcon.setContextMenu(contextMenu);
+        appIcon.on('double-click', function() {
+            mainWindow.show();
+        });
+        appIcon.on('click', function() {
+            mainWindow.show();
+        });
+    }
 
-AppMenus.prototype.tray = function() {
-    var appIcon = null;
-    appIcon = new Tray('app.ico');
-    var contextMenu = Menu.buildFromTemplate([
-        {
-            label: 'Show',
-            accelerator: 'CmdOrCtrl+Shift+D',
-            click: function() {
-                mainWindow.show();
-            }
-        },
-        {
-            label: 'Toggle DevTools',
-            click: function() {
-                mainWindow.show();
-                mainWindow.toggleDevTools();
-            }
-        },
-        {
-            label: 'Quit',
-            selector: 'terminate:',
-            click: function() {
-                app.exit(0);
-            }
-        }
-    ]);
-    appIcon.setToolTip('DeadlineApp by Webstyler');
-    appIcon.setContextMenu(contextMenu);
-    appIcon.on('double-click', function() {
-        mainWindow.show();
-    });
-    appIcon.on('click', function() {
-        mainWindow.show();
-    });
-}
-
-AppMenus.prototype.menu = function() {
-   var template = [
-      {
-        label: 'Edit',
-        submenu: [
+    menu() {
+       let template = [
           {
-            label: 'Undo',
-            accelerator: 'CmdOrCtrl+Z',
-            role: 'undo'
+            label: 'Edit',
+            submenu: [
+              {
+                label: 'Undo',
+                accelerator: 'CmdOrCtrl+Z',
+                role: 'undo'
+              },
+              {
+                label: 'Redo',
+                accelerator: 'Shift+CmdOrCtrl+Z',
+                role: 'redo'
+              },
+              {
+                type: 'separator'
+              },
+              {
+                label: 'Cut',
+                accelerator: 'CmdOrCtrl+X',
+                role: 'cut'
+              },
+              {
+                label: 'Copy',
+                accelerator: 'CmdOrCtrl+C',
+                role: 'copy'
+              },
+              {
+                label: 'Paste',
+                accelerator: 'CmdOrCtrl+V',
+                role: 'paste'
+              },
+              {
+                label: 'Select All',
+                accelerator: 'CmdOrCtrl+A',
+                role: 'selectall'
+              },
+            ]
           },
           {
-            label: 'Redo',
-            accelerator: 'Shift+CmdOrCtrl+Z',
-            role: 'redo'
+            label: 'View',
+            submenu: [
+              {
+                label: 'Reload',
+                accelerator: 'F5',
+                click: function(item, focusedWindow) {
+                  if (focusedWindow)
+                    focusedWindow.reload();
+                }
+              },
+              {
+                label: 'Toggle Full Screen',
+                accelerator: (function() {
+                  if (process.platform == 'darwin')
+                    return 'Ctrl+Command+F';
+                  else
+                    return 'F11';
+                })(),
+                click: function(item, focusedWindow) {
+                  if (focusedWindow)
+                    focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
+                }
+              },
+              {
+                label: 'Toggle Developer Tools',
+                accelerator: (function() {
+                  if (process.platform == 'darwin')
+                    return 'Alt+Command+I';
+                  else
+                    return 'Ctrl+Shift+I';
+                })(),
+                click: function(item, focusedWindow) {
+                  if (focusedWindow)
+                    focusedWindow.toggleDevTools();
+                }
+              },
+            ]
           },
           {
-            type: 'separator'
+            label: 'Window',
+            role: 'window',
+            submenu: [
+                {
+                    label: 'Minimize',
+                    accelerator: 'CmdOrCtrl+M',
+                    role: 'minimize'
+                },
+                {
+                    label: 'Close',
+                    accelerator: 'CmdOrCtrl+W',
+                    role: 'close'
+                },
+            ]
           },
-          {
-            label: 'Cut',
-            accelerator: 'CmdOrCtrl+X',
-            role: 'cut'
-          },
-          {
-            label: 'Copy',
-            accelerator: 'CmdOrCtrl+C',
-            role: 'copy'
-          },
-          {
-            label: 'Paste',
-            accelerator: 'CmdOrCtrl+V',
-            role: 'paste'
-          },
-          {
-            label: 'Select All',
-            accelerator: 'CmdOrCtrl+A',
-            role: 'selectall'
-          },
-        ]
-      },
-      {
-        label: 'View',
-        submenu: [
-          {
-            label: 'Reload',
-            accelerator: 'F5',
-            click: function(item, focusedWindow) {
-              if (focusedWindow)
-                focusedWindow.reload();
-            }
-          },
-          {
-            label: 'Toggle Full Screen',
-            accelerator: (function() {
-              if (process.platform == 'darwin')
-                return 'Ctrl+Command+F';
-              else
-                return 'F11';
-            })(),
-            click: function(item, focusedWindow) {
-              if (focusedWindow)
-                focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
-            }
-          },
-          {
-            label: 'Toggle Developer Tools',
-            accelerator: (function() {
-              if (process.platform == 'darwin')
-                return 'Alt+Command+I';
-              else
-                return 'Ctrl+Shift+I';
-            })(),
-            click: function(item, focusedWindow) {
-              if (focusedWindow)
-                focusedWindow.toggleDevTools();
-            }
-          },
-        ]
-      },
-      {
-        label: 'Window',
-        role: 'window',
-        submenu: [
-            {
-                label: 'Minimize',
-                accelerator: 'CmdOrCtrl+M',
-                role: 'minimize'
-            },
-            {
-                label: 'Close',
-                accelerator: 'CmdOrCtrl+W',
-                role: 'close'
-            },
-        ]
-      },
-      /*{
-        label: 'Help',
-        role: 'help',
-        submenu: [
-          {
-            label: 'Learn More',
-            click: function() { require('electron').shell.openExternal('http://electron.atom.io') }
-          },
-        ]
-      },*/
-    ];
+          /*{
+            label: 'Help',
+            role: 'help',
+            submenu: [
+              {
+                label: 'Learn More',
+                click: function() { require('electron').shell.openExternal('http://electron.atom.io') }
+              },
+            ]
+          },*/
+        ];
 
-    var menu = Menu.buildFromTemplate(template);
-    Menu.setApplicationMenu(menu);
-}
+        let menu = Menu.buildFromTemplate(template);
+        Menu.setApplicationMenu(menu);
+    }
 
-AppMenus.prototype.render = function() {
-    this.tray();
-    this.menu();
+    render() {
+        this.tray();
+        this.menu();
+    }
 }
 
 module.exports = AppMenus;

comments