📝 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
app.on('certificate-error', function(event, webContents, url, error, certificate, callback) {
if (url == "https://github.com") {
if (url === 'https://github.com') {
// Verification logic.
event.preventDefault();
callback(true);

View file

@ -10,7 +10,7 @@ var { desktopCapturer } = require('electron');
desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
if (error) throw error;
for (var i = 0; i < sources.length; ++i) {
if (sources[i].name == "Electron") {
if (sources[i].name === 'Electron') {
navigator.webkitGetUserMedia({
audio: false,
video: {

View file

@ -18,10 +18,10 @@ win.webContents.session.on('will-download', (event, item, webContents) => {
console.log('Received bytes: ' + item.getReceivedBytes());
});
item.on('done', (e, state) => {
if (state === "completed") {
console.log("Download successfully");
if (state === 'completed') {
console.log('Download successfully');
} 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',
accelerator: (() => {
if (process.platform == 'darwin')
if (process.platform === 'darwin')
return 'Alt+Command+I';
else
return 'Ctrl+Shift+I';

View file

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

View file

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

View file

@ -12,7 +12,7 @@ property of [`webContents`](web-contents.md) which is a property of
const { BrowserWindow } = require('electron');
let win = new BrowserWindow({ width: 800, height: 600 });
win.loadURL("http://github.com");
win.loadURL('http://github.com');
const ses = win.webContents.session;
```
@ -89,13 +89,13 @@ session.defaultSession.cookies.get({}, (error, cookies) => {
});
// 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);
});
// Set a cookie with the given cookie data;
// 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) => {
if (error)
console.error(error);
@ -307,7 +307,7 @@ Calling `callback(true)` will allow the permission and `callback(false)` will re
```javascript
session.fromPartition(partition).setPermissionRequestHandler((webContents, permission, callback) => {
if (webContents.getURL() === host) {
if (permission === "notifications") {
if (permission === 'notifications') {
callback(false); // denied.
return;
}
@ -343,7 +343,7 @@ called with an `response` object when `listener` has done its work.
```javascript
// Modify the user agent for all requests to the following urls.
const filter = {
urls: ["https://*.github.com/*", "*://electron.github.io"]
urls: ['https://*.github.com/*', '*://electron.github.io']
};
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');
let win = new BrowserWindow({width: 800, height: 1500});
win.loadURL("http://github.com");
win.loadURL('http://github.com');
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.
```javascript
const options = {"extraHeaders" : "pragma: no-cache\n"}
const options = {extraHeaders: 'pragma: no-cache\n'};
webContents.loadURL(url, options)
```
@ -401,7 +401,7 @@ Returns URL of the current web page.
```javascript
let win = new BrowserWindow({width: 800, height: 600});
win.loadURL("http://github.com");
win.loadURL('http://github.com');
let currentURL = win.webContents.getURL();
```
@ -605,10 +605,10 @@ Stops any `findInPage` request for the `webContents` with the provided `action`.
```javascript
webContents.on('found-in-page', function(event, result) {
if (result.finalUpdate)
webContents.stopFindInPage("clearSelection");
webContents.stopFindInPage('clearSelection');
});
const requestId = webContents.findInPage("api");
const requestId = webContents.findInPage('api');
```
### `webContents.hasServiceWorker(callback)`
@ -898,7 +898,7 @@ win.loadURL('https://github.com');
win.webContents.on('did-finish-load', () => {
win.webContents.savePage('/tmp/test.html', 'HTMLComplete', (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
try {
win.webContents.debugger.attach("1.1");
win.webContents.debugger.attach('1.1');
} catch(err) {
console.log("Debugger attach failed : ", err);
console.log('Debugger attach failed : ', err);
};
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) => {
if (method === "Network.requestWillBeSent") {
if (params.request.url === "https://www.github.com")
if (method === 'Network.requestWillBeSent') {
if (params.request.url === 'https://www.github.com')
win.webContents.debugger.detach();
}
})
win.webContents.debugger.sendCommand("Network.enable");
win.webContents.debugger.sendCommand('Network.enable');
```
#### `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:
```javascript
webFrame.setSpellCheckProvider("en-US", true, {
webFrame.setSpellCheckProvider('en-US', true, {
spellCheck: function(text) {
return !(require('spellchecker').isMisspelled(text));
}

View file

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

View file

@ -219,15 +219,15 @@ let win = new BrowserWindow({
win.setThumbarButtons([
{
tooltip: "button1",
tooltip: 'button1',
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'),
flags:['enabled', 'dismissonclick'],
click: () => { console.log("button2 clicked."); }
click: () => { console.log('button2 clicked.'); }
}
]);
```