diff --git a/docs/api/screen.md b/docs/api/screen.md index 258263904b..7dd6203316 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -15,11 +15,11 @@ An example of creating a window that fills the whole screen: ```javascript const {app, BrowserWindow, screen: electronScreen} = require('electron'); -let mainWindow; +let win; app.on('ready', () => { const {width, height} = electronScreen.getPrimaryDisplay().workAreaSize; - mainWindow = new BrowserWindow({width, height}); + win = new BrowserWindow({width, height}); }); ``` @@ -28,7 +28,7 @@ Another example of creating a window in the external display: ```javascript const {app, BrowserWindow, screen: electronScreen} = require('electron'); -let mainWindow; +let win; app.on('ready', () => { let displays = electronScreen.getAllDisplays(); @@ -41,7 +41,7 @@ app.on('ready', () => { } if (externalDisplay) { - mainWindow = new BrowserWindow({ + win = new BrowserWindow({ x: externalDisplay.bounds.x + 50, y: externalDisplay.bounds.y + 50 }); diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 55021945e4..47e2e4c349 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -700,8 +700,8 @@ Adds the specified path to DevTools workspace. Must be used after DevTools creation: ```javascript -mainWindow.webContents.on('devtools-opened', () => { - mainWindow.webContents.addWorkSpace(__dirname); +win.webContents.on('devtools-opened', () => { + win.webContents.addWorkSpace(__dirname); }); ``` @@ -763,13 +763,13 @@ An example of sending messages from the main process to the renderer process: ```javascript // In the main process. -let mainWindow = null; +let win = null; app.on('ready', () => { - mainWindow = new BrowserWindow({width: 800, height: 600}); - mainWindow.loadURL(`file://${__dirname}/index.html`); - mainWindow.webContents.on('did-finish-load', () => { - mainWindow.webContents.send('ping', 'whoooooooh!'); + win = new BrowserWindow({width: 800, height: 600}); + win.loadURL(`file://${__dirname}/index.html`); + win.webContents.on('did-finish-load', () => { + win.webContents.send('ping', 'whoooooooh!'); }); }); ``` diff --git a/docs/faq/electron-faq.md b/docs/faq/electron-faq.md index 94a4c6714b..239b4411d4 100644 --- a/docs/faq/electron-faq.md +++ b/docs/faq/electron-faq.md @@ -87,7 +87,7 @@ To solve this, you can turn off node integration in Electron: ```javascript // In the main process. -let mainWindow = new BrowserWindow({ +let win = new BrowserWindow({ webPreferences: { nodeIntegration: false } diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index abbaf10553..59ee27602b 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -88,24 +88,24 @@ const {BrowserWindow} = electron; // 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. -let mainWindow; +let win; function createWindow() { // Create the browser window. - mainWindow = new BrowserWindow({width: 800, height: 600}); + win = new BrowserWindow({width: 800, height: 600}); // and load the index.html of the app. - mainWindow.loadURL(`file://${__dirname}/index.html`); + win.loadURL(`file://${__dirname}/index.html`); // Open the DevTools. - mainWindow.webContents.openDevTools(); + win.webContents.openDevTools(); // Emitted when the window is closed. - mainWindow.on('closed', () => { + win.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. - mainWindow = null; + win = null; }); } @@ -126,7 +126,7 @@ app.on('window-all-closed', () => { app.on('activate', () => { // On OS X it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. - if (mainWindow === null) { + if (win === null) { createWindow(); } }); diff --git a/docs/tutorial/using-pepper-flash-plugin.md b/docs/tutorial/using-pepper-flash-plugin.md index 31ab1104b1..76c89d6fdd 100644 --- a/docs/tutorial/using-pepper-flash-plugin.md +++ b/docs/tutorial/using-pepper-flash-plugin.md @@ -29,14 +29,14 @@ app.commandLine.appendSwitch('ppapi-flash-path', '/path/to/libpepflashplayer.so' app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169'); app.on('ready', () => { - mainWindow = new BrowserWindow({ + win = new BrowserWindow({ width: 800, height: 600, webPreferences: { plugins: true } }); - mainWindow.loadURL(`file://${__dirname}/index.html`); + win.loadURL(`file://${__dirname}/index.html`); // Something else }); ``` diff --git a/docs/tutorial/using-widevine-cdm-plugin.md b/docs/tutorial/using-widevine-cdm-plugin.md index d1afae8558..af1337c5ea 100644 --- a/docs/tutorial/using-widevine-cdm-plugin.md +++ b/docs/tutorial/using-widevine-cdm-plugin.md @@ -59,9 +59,9 @@ app.commandLine.appendSwitch('widevine-cdm-path', '/path/to/widevinecdmadapter.p // The version of plugin can be got from `chrome://plugins` page in Chrome. app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866'); -let mainWindow = null; +let win = null; app.on('ready', () => { - mainWindow = new BrowserWindow({ + win = new BrowserWindow({ webPreferences: { // The `plugins` have to be enabled. plugins: true