📝 Fix code style issue

* Match equality operators for consistent that `==`, `!=` by `===`,
`!==`.
* Match string expression notation `"` by `'`.

[ci skip]
This commit is contained in:
Plusb Preco 2016-05-10 18:42:11 +09:00
parent 3cc2dd216f
commit 5787bb0226
11 changed files with 33 additions and 33 deletions

View file

@ -176,7 +176,7 @@ certificate you should prevent the default behavior with
```javascript ```javascript
app.on('certificate-error', function(event, webContents, url, error, certificate, callback) { app.on('certificate-error', function(event, webContents, url, error, certificate, callback) {
if (url == "https://github.com") { if (url === 'https://github.com') {
// Verification logic. // Verification logic.
event.preventDefault(); event.preventDefault();
callback(true); callback(true);

View file

@ -10,7 +10,7 @@ var { 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 (var i = 0; i < sources.length; ++i) {
if (sources[i].name == "Electron") { if (sources[i].name === 'Electron') {
navigator.webkitGetUserMedia({ navigator.webkitGetUserMedia({
audio: false, audio: false,
video: { video: {

View file

@ -18,10 +18,10 @@ win.webContents.session.on('will-download', (event, item, webContents) => {
console.log('Received bytes: ' + item.getReceivedBytes()); console.log('Received bytes: ' + item.getReceivedBytes());
}); });
item.on('done', (e, state) => { item.on('done', (e, state) => {
if (state === "completed") { if (state === 'completed') {
console.log("Download successfully"); console.log('Download successfully');
} else { } else {
console.log("Download is cancelled or interrupted that can't be resumed"); console.log('Download is cancelled or interrupted that can\'t be resumed');
} }
}); });
}); });

View file

@ -98,7 +98,7 @@ const template = [
{ {
label: 'Toggle Developer Tools', label: 'Toggle Developer Tools',
accelerator: (() => { accelerator: (() => {
if (process.platform == 'darwin') if (process.platform === 'darwin')
return 'Alt+Command+I'; return 'Alt+Command+I';
else else
return 'Ctrl+Shift+I'; return 'Ctrl+Shift+I';

View file

@ -79,7 +79,7 @@ exports.withLocalCallback = () => {
```javascript ```javascript
// renderer process // renderer process
const mapNumbers = require("remote").require("./mapNumbers"); const mapNumbers = require('remote').require('./mapNumbers');
const withRendererCb = mapNumbers.withRendererCallback(x => x + 1); const withRendererCb = mapNumbers.withRendererCallback(x => x + 1);

View file

@ -37,7 +37,7 @@ app.on('ready', () => {
var displays = electronScreen.getAllDisplays(); var displays = electronScreen.getAllDisplays();
var externalDisplay = null; var 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];
break; break;
} }

View file

@ -12,7 +12,7 @@ property of [`webContents`](web-contents.md) which is a property of
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);
@ -307,7 +307,7 @@ Calling `callback(true)` will allow the permission and `callback(false)` will re
```javascript ```javascript
session.fromPartition(partition).setPermissionRequestHandler((webContents, permission, callback) => { session.fromPartition(partition).setPermissionRequestHandler((webContents, permission, callback) => {
if (webContents.getURL() === host) { if (webContents.getURL() === host) {
if (permission === "notifications") { if (permission === 'notifications') {
callback(false); // denied. callback(false); // denied.
return; return;
} }
@ -343,7 +343,7 @@ called with an `response` object when `listener` has done its work.
```javascript ```javascript
// Modify the user agent for all requests to the following urls. // Modify the user agent for all requests to the following urls.
const filter = { const filter = {
urls: ["https://*.github.com/*", "*://electron.github.io"] urls: ['https://*.github.com/*', '*://electron.github.io']
}; };
session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => { session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => {

View file

@ -12,7 +12,7 @@ the [`BrowserWindow`](browser-window.md) object. An example of accessing the
const { BrowserWindow } = require('electron'); const { BrowserWindow } = require('electron');
let win = new BrowserWindow({width: 800, height: 1500}); let win = new BrowserWindow({width: 800, height: 1500});
win.loadURL("http://github.com"); win.loadURL('http://github.com');
let webContents = win.webContents; let webContents = win.webContents;
``` ```
@ -384,7 +384,7 @@ e.g. the `http://` or `file://`. If the load should bypass http cache then
use the `pragma` header to achieve it. use the `pragma` header to achieve it.
```javascript ```javascript
const options = {"extraHeaders" : "pragma: no-cache\n"} const options = {extraHeaders: 'pragma: no-cache\n'};
webContents.loadURL(url, options) webContents.loadURL(url, options)
``` ```
@ -401,7 +401,7 @@ Returns URL of the current web page.
```javascript ```javascript
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');
let currentURL = win.webContents.getURL(); let currentURL = win.webContents.getURL();
``` ```
@ -605,10 +605,10 @@ 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', function(event, result) {
if (result.finalUpdate) if (result.finalUpdate)
webContents.stopFindInPage("clearSelection"); webContents.stopFindInPage('clearSelection');
}); });
const requestId = webContents.findInPage("api"); const requestId = webContents.findInPage('api');
``` ```
### `webContents.hasServiceWorker(callback)` ### `webContents.hasServiceWorker(callback)`
@ -898,7 +898,7 @@ win.loadURL('https://github.com');
win.webContents.on('did-finish-load', () => { win.webContents.on('did-finish-load', () => {
win.webContents.savePage('/tmp/test.html', 'HTMLComplete', (error) => { win.webContents.savePage('/tmp/test.html', 'HTMLComplete', (error) => {
if (!error) if (!error)
console.log("Save page successfully"); console.log('Save page successfully');
}); });
}); });
``` ```
@ -928,23 +928,23 @@ Debugger API serves as an alternate transport for [remote debugging protocol][rd
```javascript ```javascript
try { try {
win.webContents.debugger.attach("1.1"); win.webContents.debugger.attach('1.1');
} catch(err) { } catch(err) {
console.log("Debugger attach failed : ", err); console.log('Debugger attach failed : ', err);
}; };
win.webContents.debugger.on('detach', (event, reason) => { win.webContents.debugger.on('detach', (event, reason) => {
console.log("Debugger detached due to : ", reason); console.log('Debugger detached due to : ', reason);
}); });
win.webContents.debugger.on('message', (event, method, params) => { win.webContents.debugger.on('message', (event, method, params) => {
if (method === "Network.requestWillBeSent") { if (method === 'Network.requestWillBeSent') {
if (params.request.url === "https://www.github.com") if (params.request.url === 'https://www.github.com')
win.webContents.debugger.detach(); win.webContents.debugger.detach();
} }
}) })
win.webContents.debugger.sendCommand("Network.enable"); win.webContents.debugger.sendCommand('Network.enable');
``` ```
#### `webContents.debugger.attach([protocolVersion])` #### `webContents.debugger.attach([protocolVersion])`

View file

@ -58,7 +58,7 @@ whether the word passed is correctly spelled.
An example of using [node-spellchecker][spellchecker] as provider: 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: function(text) {
return !(require('spellchecker').isMisspelled(text)); return !(require('spellchecker').isMisspelled(text));
} }

View file

@ -213,7 +213,7 @@ The `webview` tag has the following methods:
**Example** **Example**
```javascript ```javascript
webview.addEventListener("dom-ready", () => { webview.addEventListener('dom-ready', () => {
webview.openDevTools(); webview.openDevTools();
}); });
``` ```
@ -622,10 +622,10 @@ Fired when a result is available for
```javascript ```javascript
webview.addEventListener('found-in-page', function(e) { webview.addEventListener('found-in-page', function(e) {
if (e.result.finalUpdate) if (e.result.finalUpdate)
webview.stopFindInPage("keepSelection"); webview.stopFindInPage('keepSelection');
}); });
const rquestId = webview.findInPage("test"); const rquestId = webview.findInPage('test');
``` ```
### Event: 'new-window' ### Event: 'new-window'

View file

@ -219,15 +219,15 @@ let win = new BrowserWindow({
win.setThumbarButtons([ 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.'); }
} }
]); ]);
``` ```