Advertisement
U2F

My code

U2F
Jul 27th, 2018
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const electron = require('electron');
  2. const url = require('url');
  3. const path = require('path');
  4.  
  5. const {app , BrowserWindow , Menu} = electron;
  6.  
  7. let mainWindow;
  8. let addWindow;
  9.  
  10. //Listen for the app to be ready
  11. app.on('ready' , function(){
  12.     //Create new window
  13.     mainWindow = new BrowserWindow({});
  14.     //Load HTML file into the main window
  15.     mainWindow.loadURL(url.format({
  16.         pathname: path.join(__dirname , 'mainWindow.html'),
  17.         protocol: 'file:',
  18.         slashes:true
  19.     }));
  20.  
  21.     //Build menu from template
  22.     const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
  23.  
  24.     //Insert the menu
  25.     Menu.setApplicationMenu(mainMenu);
  26. });
  27.  
  28. //Handle CreateAddWindow function
  29. function CreateAddWindow()
  30. {
  31.    //Create new window
  32.     addWindow = new BrowserWindow
  33.     ({
  34.         width: 200,
  35.         height: 300,
  36.         title: 'Add to shopping list'
  37.     });
  38.     //Load HTML file into the main window
  39.     addWindow.loadURL(url.format({
  40.     pathname: path.join(__dirname , 'addWindow.html'),
  41.     protocol: 'file:',
  42.     slashes:true
  43.     }));
  44. }
  45.  
  46.  
  47. const mainMenuTemplate =
  48. [
  49.     {
  50.         label:'File',
  51.         submenu:
  52.         [
  53.             {
  54.                 label:'Add Item',
  55.                 CreateAddWindow()
  56.             },
  57.             {
  58.                 label: 'Clear Items'
  59.             },
  60.             {
  61.                 label:'Quit',
  62.                 accelerator: process.platform == 'darwin' ? 'Command+Q' : 'Ctrl+Q',
  63.                 click()
  64.                 {
  65.                     app.quit();
  66.                 }
  67.             }
  68.         ]
  69.     }
  70. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement