📝 Fix code style issue
* Change `var` to `let`. * Change `function() {}` to `() => {}`. * Use shorthand function syntax on object notation. * Remove spaces between object notation brackets. * Small fixes.
This commit is contained in:
parent
139a4f984a
commit
f1b184ef78
23 changed files with 64 additions and 67 deletions
|
@ -176,7 +176,7 @@ certificate you should prevent the default behavior with
|
||||||
`event.preventDefault()` and call `callback(true)`.
|
`event.preventDefault()` and call `callback(true)`.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
app.on('certificate-error', function(event, webContents, url, error, certificate, callback) {
|
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
|
||||||
if (url === 'https://github.com') {
|
if (url === 'https://github.com') {
|
||||||
// Verification logic.
|
// Verification logic.
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -207,7 +207,7 @@ and `callback` needs to be called with an entry filtered from the list. Using
|
||||||
certificate from the store.
|
certificate from the store.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
app.on('select-client-certificate', function(event, webContents, url, list, callback) {
|
app.on('select-client-certificate', (event, webContents, url, list, callback) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
callback(list[0]);
|
callback(list[0]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ const {BrowserWindow} = require('electron');
|
||||||
// Or in the renderer process.
|
// Or in the renderer process.
|
||||||
const {BrowserWindow} = require('electron').remote;
|
const {BrowserWindow} = require('electron').remote;
|
||||||
|
|
||||||
let win = new BrowserWindow({ width: 800, height: 600, show: false });
|
let win = new BrowserWindow({width: 800, height: 600, show: false});
|
||||||
win.on('closed', () => {
|
win.on('closed', () => {
|
||||||
win = null;
|
win = null;
|
||||||
});
|
});
|
||||||
|
@ -220,7 +220,7 @@ reloaded. In Electron, returning an empty string or `false` would cancel the
|
||||||
close. For example:
|
close. For example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
window.onbeforeunload = function(e) {
|
window.onbeforeunload = (e) => {
|
||||||
console.log('I do not want to be closed');
|
console.log('I do not want to be closed');
|
||||||
|
|
||||||
// Unlike usual browsers, in which a string should be returned and the user is
|
// Unlike usual browsers, in which a string should be returned and the user is
|
||||||
|
@ -392,7 +392,7 @@ Objects created with `new BrowserWindow` have the following properties:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// In this example `win` is our instance
|
// In this example `win` is our instance
|
||||||
var win = new BrowserWindow({ width: 800, height: 600 });
|
let win = new BrowserWindow({width: 800, height: 600});
|
||||||
```
|
```
|
||||||
|
|
||||||
### `win.webContents`
|
### `win.webContents`
|
||||||
|
@ -689,7 +689,7 @@ attached just below the window frame, but you may want to display them beneath
|
||||||
a HTML-rendered toolbar. For example:
|
a HTML-rendered toolbar. For example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var toolbarRect = document.getElementById('toolbar').getBoundingClientRect();
|
let toolbarRect = document.getElementById('toolbar').getBoundingClientRect();
|
||||||
win.setSheetOffset(toolbarRect.height);
|
win.setSheetOffset(toolbarRect.height);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ const options = {
|
||||||
traceOptions: 'record-until-full,enable-sampling'
|
traceOptions: 'record-until-full,enable-sampling'
|
||||||
};
|
};
|
||||||
|
|
||||||
contentTracing.startRecording(options, function() {
|
contentTracing.startRecording(options, () => {
|
||||||
console.log('Tracing started');
|
console.log('Tracing started');
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -9,7 +9,7 @@ const {desktopCapturer} = require('electron');
|
||||||
|
|
||||||
desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
|
desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
for (var i = 0; i < sources.length; ++i) {
|
for (let i = 0; i < sources.length; ++i) {
|
||||||
if (sources[i].name === 'Electron') {
|
if (sources[i].name === 'Electron') {
|
||||||
navigator.webkitGetUserMedia({
|
navigator.webkitGetUserMedia({
|
||||||
audio: false,
|
audio: false,
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
An example of showing a dialog to select multiple files and directories:
|
An example of showing a dialog to select multiple files and directories:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var win = ...; // BrowserWindow in which to show the dialog
|
let win = ...; // BrowserWindow in which to show the dialog
|
||||||
const {dialog} = require('electron');
|
const {dialog} = require('electron');
|
||||||
|
|
||||||
console.log(dialog.showOpenDialog({ properties: [ 'openFile', 'openDirectory', 'multiSelections' ]}));
|
console.log(dialog.showOpenDialog({properties: ['openFile', 'openDirectory', 'multiSelections']}));
|
||||||
```
|
```
|
||||||
|
|
||||||
The Dialog is opened from Electron's main thread. If you want to use the dialog
|
The Dialog is opened from Electron's main thread. If you want to use the dialog
|
||||||
|
@ -43,10 +43,10 @@ selected when you want to limit the user to a specific type. For example:
|
||||||
```javascript
|
```javascript
|
||||||
{
|
{
|
||||||
filters: [
|
filters: [
|
||||||
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] },
|
{name: 'Images', extensions: ['jpg', 'png', 'gif']},
|
||||||
{ name: 'Movies', extensions: ['mkv', 'avi', 'mp4'] },
|
{name: 'Movies', extensions: ['mkv', 'avi', 'mp4']},
|
||||||
{ name: 'Custom File Type', extensions: ['as'] },
|
{name: 'Custom File Type', extensions: ['as']},
|
||||||
{ name: 'All Files', extensions: ['*'] }
|
{name: 'All Files', extensions: ['*']}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -15,7 +15,7 @@ To create a frameless window, you need to set `frame` to `false` in
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {BrowserWindow} = require('electron');
|
const {BrowserWindow} = require('electron');
|
||||||
let win = new BrowserWindow({ width: 800, height: 600, frame: false });
|
let win = new BrowserWindow({width: 800, height: 600, frame: false});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Alternatives on OS X
|
### Alternatives on OS X
|
||||||
|
@ -28,7 +28,7 @@ the window controls ("traffic lights") for standard window actions.
|
||||||
You can do so by specifying the new `titleBarStyle` option:
|
You can do so by specifying the new `titleBarStyle` option:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
let win = new BrowserWindow({ 'titleBarStyle': 'hidden' });
|
let win = new BrowserWindow({titleBarStyle: 'hidden'});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Transparent window
|
## Transparent window
|
||||||
|
@ -37,7 +37,7 @@ By setting the `transparent` option to `true`, you can also make the frameless
|
||||||
window transparent:
|
window transparent:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
let win = new BrowserWindow({ transparent: true, frame: false });
|
let win = new BrowserWindow({transparent: true, frame: false});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Limitations
|
### Limitations
|
||||||
|
|
|
@ -15,7 +15,7 @@ const {app, globalShortcut} = require('electron');
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
// Register a 'CommandOrControl+X' shortcut listener.
|
// Register a 'CommandOrControl+X' shortcut listener.
|
||||||
const ret = globalShortcut.register('CommandOrControl+X', function() {
|
const ret = globalShortcut.register('CommandOrControl+X', () => {
|
||||||
console.log('CommandOrControl+X is pressed');
|
console.log('CommandOrControl+X is pressed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ the user right clicks the page:
|
||||||
const {Menu, MenuItem} = require('electron').remote;
|
const {Menu, MenuItem} = require('electron').remote;
|
||||||
|
|
||||||
const menu = new Menu();
|
const menu = new Menu();
|
||||||
menu.append(new MenuItem({ label: 'MenuItem1', click: () => { console.log('item 1 clicked'); } }));
|
menu.append(new MenuItem({label: 'MenuItem1', click() { console.log('item 1 clicked'); }}));
|
||||||
menu.append(new MenuItem({ type: 'separator' }));
|
menu.append(new MenuItem({type: 'separator'}));
|
||||||
menu.append(new MenuItem({ label: 'MenuItem2', type: 'checkbox', checked: true }));
|
menu.append(new MenuItem({label: 'MenuItem2', type: 'checkbox', checked: true}));
|
||||||
|
|
||||||
window.addEventListener('contextmenu', (e) => {
|
window.addEventListener('contextmenu', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -78,14 +78,14 @@ const template = [
|
||||||
{
|
{
|
||||||
label: 'Reload',
|
label: 'Reload',
|
||||||
accelerator: 'CmdOrCtrl+R',
|
accelerator: 'CmdOrCtrl+R',
|
||||||
click: (item, focusedWindow) => {
|
click(item, focusedWindow) {
|
||||||
if (focusedWindow) focusedWindow.reload();
|
if (focusedWindow) focusedWindow.reload();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle Full Screen',
|
label: 'Toggle Full Screen',
|
||||||
accelerator: process.platform === 'darwin' ? 'Ctrl+Command+F' : 'F11',
|
accelerator: process.platform === 'darwin' ? 'Ctrl+Command+F' : 'F11',
|
||||||
click: (item, focusedWindow) => {
|
click(item, focusedWindow) {
|
||||||
if (focusedWindow)
|
if (focusedWindow)
|
||||||
focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
|
focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ const template = [
|
||||||
{
|
{
|
||||||
label: 'Toggle Developer Tools',
|
label: 'Toggle Developer Tools',
|
||||||
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
||||||
click: (item, focusedWindow) => {
|
click(item, focusedWindow) {
|
||||||
if (focusedWindow)
|
if (focusedWindow)
|
||||||
focusedWindow.webContents.toggleDevTools();
|
focusedWindow.webContents.toggleDevTools();
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ const template = [
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: 'Learn More',
|
label: 'Learn More',
|
||||||
click: () => { require('electron').shell.openExternal('http://electron.atom.io') }
|
click() { require('electron').shell.openExternal('http://electron.atom.io'); }
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -168,7 +168,7 @@ if (process.platform === 'darwin') {
|
||||||
{
|
{
|
||||||
label: 'Quit',
|
label: 'Quit',
|
||||||
accelerator: 'Command+Q',
|
accelerator: 'Command+Q',
|
||||||
click: () => { app.quit(); }
|
click() { app.quit(); }
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -49,7 +49,7 @@ images/
|
||||||
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var appIcon = new Tray('/Users/somebody/images/icon.png');
|
let appIcon = new Tray('/Users/somebody/images/icon.png');
|
||||||
```
|
```
|
||||||
|
|
||||||
Following suffixes for DPI are also supported:
|
Following suffixes for DPI are also supported:
|
||||||
|
@ -118,7 +118,7 @@ The following methods are available on instances of `nativeImage`:
|
||||||
```javascript
|
```javascript
|
||||||
const nativeImage = require('electron').nativeImage;
|
const nativeImage = require('electron').nativeImage;
|
||||||
|
|
||||||
var image = nativeImage.createFromPath('/Users/somebody/images/icon.png');
|
let image = nativeImage.createFromPath('/Users/somebody/images/icon.png');
|
||||||
```
|
```
|
||||||
|
|
||||||
### `image.toPng()`
|
### `image.toPng()`
|
||||||
|
|
|
@ -32,7 +32,7 @@ the global scope when node integration is turned off:
|
||||||
// preload.js
|
// preload.js
|
||||||
const _setImmediate = setImmediate;
|
const _setImmediate = setImmediate;
|
||||||
const _clearImmediate = clearImmediate;
|
const _clearImmediate = clearImmediate;
|
||||||
process.once('loaded', function() {
|
process.once('loaded', () => {
|
||||||
global.setImmediate = _setImmediate;
|
global.setImmediate = _setImmediate;
|
||||||
global.clearImmediate = _clearImmediate;
|
global.clearImmediate = _clearImmediate;
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,11 +9,11 @@ An example of implementing a protocol that has the same effect as the
|
||||||
const {app, protocol} = require('electron');
|
const {app, protocol} = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
app.on('ready', function () {
|
app.on('ready', () => {
|
||||||
protocol.registerFileProtocol('atom', function (request, callback) {
|
protocol.registerFileProtocol('atom', (request, callback) => {
|
||||||
const url = request.url.substr(7);
|
const url = request.url.substr(7);
|
||||||
callback({path: path.normalize(__dirname + '/' + url)});
|
callback({path: path.normalize(__dirname + '/' + url)});
|
||||||
}, function (error) {
|
}, (error) => {
|
||||||
if (error)
|
if (error)
|
||||||
console.error('Failed to register protocol');
|
console.error('Failed to register protocol');
|
||||||
});
|
});
|
||||||
|
@ -53,7 +53,7 @@ have to register it as standard scheme:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
protocol.registerStandardSchemes(['atom']);
|
protocol.registerStandardSchemes(['atom']);
|
||||||
app.on('ready', function () {
|
app.on('ready', () => {
|
||||||
protocol.registerHttpProtocol('atom', ...);
|
protocol.registerHttpProtocol('atom', ...);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
|
@ -16,7 +16,7 @@ renderer process:
|
||||||
```javascript
|
```javascript
|
||||||
const {BrowserWindow} = require('electron').remote;
|
const {BrowserWindow} = require('electron').remote;
|
||||||
|
|
||||||
var win = new BrowserWindow({ width: 800, height: 600 });
|
let win = new BrowserWindow({width: 800, height: 600});
|
||||||
win.loadURL('https://github.com');
|
win.loadURL('https://github.com');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ emitted (by invoking or requiring it).
|
||||||
`screen` is an [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter).
|
`screen` is an [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter).
|
||||||
|
|
||||||
**Note:** In the renderer / DevTools, `window.screen` is a reserved DOM
|
**Note:** In the renderer / DevTools, `window.screen` is a reserved DOM
|
||||||
property, so writing `var screen = require('electron').screen` will not work.
|
property, so writing `let {screen} = require('electron')` will not work.
|
||||||
In our examples below, we use `electronScreen` as the variable name instead.
|
In our examples below, we use `electronScreen` as the variable name instead.
|
||||||
An example of creating a window that fills the whole screen:
|
An example of creating a window that fills the whole screen:
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ let mainWindow;
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
const {width, height} = electronScreen.getPrimaryDisplay().workAreaSize;
|
const {width, height} = electronScreen.getPrimaryDisplay().workAreaSize;
|
||||||
mainWindow = new BrowserWindow({ width, height });
|
mainWindow = new BrowserWindow({width, height});
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ const {app, BrowserWindow, screen: electronScreen} = require('electron');
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
var displays = electronScreen.getAllDisplays();
|
let displays = electronScreen.getAllDisplays();
|
||||||
var externalDisplay = null;
|
let externalDisplay = null;
|
||||||
for (let i in displays) {
|
for (let i in displays) {
|
||||||
if (displays[i].bounds.x !== 0 || displays[i].bounds.y !== 0) {
|
if (displays[i].bounds.x !== 0 || displays[i].bounds.y !== 0) {
|
||||||
externalDisplay = displays[i];
|
externalDisplay = displays[i];
|
||||||
|
|
|
@ -11,7 +11,7 @@ property of [`webContents`](web-contents.md) which is a property of
|
||||||
```javascript
|
```javascript
|
||||||
const {BrowserWindow} = require('electron');
|
const {BrowserWindow} = require('electron');
|
||||||
|
|
||||||
let win = new BrowserWindow({ width: 800, height: 600 });
|
let win = new BrowserWindow({width: 800, height: 600});
|
||||||
win.loadURL('http://github.com');
|
win.loadURL('http://github.com');
|
||||||
|
|
||||||
const ses = win.webContents.session;
|
const ses = win.webContents.session;
|
||||||
|
@ -89,13 +89,13 @@ session.defaultSession.cookies.get({}, (error, cookies) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Query all cookies associated with a specific url.
|
// Query all cookies associated with a specific url.
|
||||||
session.defaultSession.cookies.get({ url : 'http://www.github.com' }, (error, cookies) => {
|
session.defaultSession.cookies.get({url : 'http://www.github.com'}, (error, cookies) => {
|
||||||
console.log(cookies);
|
console.log(cookies);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set a cookie with the given cookie data;
|
// Set a cookie with the given cookie data;
|
||||||
// may overwrite equivalent cookies if they exist.
|
// may overwrite equivalent cookies if they exist.
|
||||||
const cookie = { url : 'http://www.github.com', name : 'dummy_name', value : 'dummy' };
|
const cookie = {url : 'http://www.github.com', name : 'dummy_name', value : 'dummy'};
|
||||||
session.defaultSession.cookies.set(cookie, (error) => {
|
session.defaultSession.cookies.set(cookie, (error) => {
|
||||||
if (error)
|
if (error)
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
|
@ -56,7 +56,7 @@ An example of using it to determine if you should create a transparent window or
|
||||||
not (transparent windows won't work correctly when DWM composition is disabled):
|
not (transparent windows won't work correctly when DWM composition is disabled):
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
let browserOptions = { width: 1000, height: 800 };
|
let browserOptions = {width: 1000, height: 800};
|
||||||
|
|
||||||
// Make the window transparent only if the platform supports it.
|
// Make the window transparent only if the platform supports it.
|
||||||
if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) {
|
if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) {
|
||||||
|
|
|
@ -3,19 +3,16 @@
|
||||||
> Add icons and context menus to the system's notification area.
|
> Add icons and context menus to the system's notification area.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const electron = require('electron');
|
const {app, Menu, Tray} = require('electron');
|
||||||
const app = electron.app;
|
|
||||||
const Menu = electron.Menu;
|
|
||||||
const Tray = electron.Tray;
|
|
||||||
|
|
||||||
let appIcon = null;
|
let appIcon = null;
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
appIcon = new Tray('/path/to/my/icon');
|
appIcon = new Tray('/path/to/my/icon');
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{ label: 'Item1', type: 'radio' },
|
{label: 'Item1', type: 'radio'},
|
||||||
{ label: 'Item2', type: 'radio' },
|
{label: 'Item2', type: 'radio'},
|
||||||
{ label: 'Item3', type: 'radio', checked: true },
|
{label: 'Item3', type: 'radio', checked: true},
|
||||||
{ label: 'Item4', type: 'radio' }
|
{label: 'Item4', type: 'radio'}
|
||||||
]);
|
]);
|
||||||
appIcon.setToolTip('This is my application.');
|
appIcon.setToolTip('This is my application.');
|
||||||
appIcon.setContextMenu(contextMenu);
|
appIcon.setContextMenu(contextMenu);
|
||||||
|
|
|
@ -603,7 +603,7 @@ the request can be obtained by subscribing to
|
||||||
Stops any `findInPage` request for the `webContents` with the provided `action`.
|
Stops any `findInPage` request for the `webContents` with the provided `action`.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
webContents.on('found-in-page', function(event, result) {
|
webContents.on('found-in-page', (event, result) => {
|
||||||
if (result.finalUpdate)
|
if (result.finalUpdate)
|
||||||
webContents.stopFindInPage('clearSelection');
|
webContents.stopFindInPage('clearSelection');
|
||||||
});
|
});
|
||||||
|
@ -700,7 +700,7 @@ Adds the specified path to DevTools workspace. Must be used after DevTools
|
||||||
creation:
|
creation:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
mainWindow.webContents.on('devtools-opened', function() {
|
mainWindow.webContents.on('devtools-opened', () => {
|
||||||
mainWindow.webContents.addWorkSpace(__dirname);
|
mainWindow.webContents.addWorkSpace(__dirname);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -887,7 +887,7 @@ End subscribing for frame presentation events.
|
||||||
* `HTMLOnly` - Save only the HTML of the page.
|
* `HTMLOnly` - Save only the HTML of the page.
|
||||||
* `HTMLComplete` - Save complete-html page.
|
* `HTMLComplete` - Save complete-html page.
|
||||||
* `MHTML` - Save complete-html page as MHTML.
|
* `MHTML` - Save complete-html page as MHTML.
|
||||||
* `callback` Function - `function(error) {}`.
|
* `callback` Function - `(error) => {}`.
|
||||||
* `error` Error
|
* `error` Error
|
||||||
|
|
||||||
Returns true if the process of saving page has been initiated successfully.
|
Returns true if the process of saving page has been initiated successfully.
|
||||||
|
|
|
@ -59,7 +59,7 @@ An example of using [node-spellchecker][spellchecker] as provider:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
webFrame.setSpellCheckProvider('en-US', true, {
|
webFrame.setSpellCheckProvider('en-US', true, {
|
||||||
spellCheck: function(text) {
|
spellCheck(text) {
|
||||||
return !(require('spellchecker').isMisspelled(text));
|
return !(require('spellchecker').isMisspelled(text));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -600,7 +600,7 @@ The following example code forwards all log messages to the embedder's console
|
||||||
without regard for log level or other properties.
|
without regard for log level or other properties.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
webview.addEventListener('console-message', function(e) {
|
webview.addEventListener('console-message', (e) => {
|
||||||
console.log('Guest page logged a message:', e.message);
|
console.log('Guest page logged a message:', e.message);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -620,7 +620,7 @@ Fired when a result is available for
|
||||||
[`webview.findInPage`](web-view-tag.md#webviewtagfindinpage) request.
|
[`webview.findInPage`](web-view-tag.md#webviewtagfindinpage) request.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
webview.addEventListener('found-in-page', function(e) {
|
webview.addEventListener('found-in-page', (e) => {
|
||||||
if (e.result.finalUpdate)
|
if (e.result.finalUpdate)
|
||||||
webview.stopFindInPage('keepSelection');
|
webview.stopFindInPage('keepSelection');
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,7 +85,7 @@ For example, to get a file with `$.get`:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var $ = require('./jquery.min.js');
|
let $ = require('./jquery.min.js');
|
||||||
$.get('file:///path/to/example.asar/file.txt', (data) => {
|
$.get('file:///path/to/example.asar/file.txt', (data) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,7 +22,7 @@ let myNotification = new Notification('Title', {
|
||||||
body: 'Lorem Ipsum Dolor Sit Amet'
|
body: 'Lorem Ipsum Dolor Sit Amet'
|
||||||
});
|
});
|
||||||
|
|
||||||
myNotification.onclick = function () {
|
myNotification.onclick = () => {
|
||||||
console.log('Notification clicked');
|
console.log('Notification clicked');
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
@ -118,7 +118,7 @@ const app = electron.app;
|
||||||
const Menu = electron.Menu;
|
const Menu = electron.Menu;
|
||||||
|
|
||||||
const dockMenu = Menu.buildFromTemplate([
|
const dockMenu = Menu.buildFromTemplate([
|
||||||
{ label: 'New Window', click: () => { console.log('New Window'); } },
|
{ label: 'New Window', click() { console.log('New Window'); } },
|
||||||
{ label: 'New Window with Settings', submenu: [
|
{ label: 'New Window with Settings', submenu: [
|
||||||
{ label: 'Basic' },
|
{ label: 'Basic' },
|
||||||
{ label: 'Pro'}
|
{ label: 'Pro'}
|
||||||
|
@ -221,13 +221,13 @@ win.setThumbarButtons([
|
||||||
{
|
{
|
||||||
tooltip: 'button1',
|
tooltip: 'button1',
|
||||||
icon: path.join(__dirname, 'button1.png'),
|
icon: path.join(__dirname, 'button1.png'),
|
||||||
click: () => { console.log('button2 clicked'); }
|
click() { console.log('button2 clicked'); }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tooltip: 'button2',
|
tooltip: 'button2',
|
||||||
icon: path.join(__dirname, 'button2.png'),
|
icon: path.join(__dirname, 'button2.png'),
|
||||||
flags:['enabled', 'dismissonclick'],
|
flags: ['enabled', 'dismissonclick'],
|
||||||
click: () => { console.log('button2 clicked.'); }
|
click() { console.log('button2 clicked.'); }
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
```
|
```
|
||||||
|
|
|
@ -82,15 +82,15 @@ example being:
|
||||||
```javascript
|
```javascript
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
// Module to control application life.
|
// Module to control application life.
|
||||||
const app = electron.app;
|
const {app} = electron;
|
||||||
// Module to create native browser window.
|
// Module to create native browser window.
|
||||||
const BrowserWindow = electron.BrowserWindow;
|
const {BrowserWindow} = electron;
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// 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.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({width: 800, height: 600});
|
mainWindow = new BrowserWindow({width: 800, height: 600});
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ driver.get('http://www.google.com');
|
||||||
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
|
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
|
||||||
driver.findElement(webdriver.By.name('btnG')).click();
|
driver.findElement(webdriver.By.name('btnG')).click();
|
||||||
driver.wait(() => {
|
driver.wait(() => {
|
||||||
return driver.getTitle().then(function(title) {
|
return driver.getTitle().then((title) => {
|
||||||
return title === 'webdriver - Google Search';
|
return title === 'webdriver - Google Search';
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -106,7 +106,7 @@ const options = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var client = webdriverio.remote(options);
|
let client = webdriverio.remote(options);
|
||||||
|
|
||||||
client
|
client
|
||||||
.init()
|
.init()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue