Fixes for ESLint

This commit is contained in:
YFdyh000
2017-07-09 05:47:00 +08:00
parent af3e105a41
commit 0a745348f3
14 changed files with 39 additions and 26 deletions

View File

@@ -4,14 +4,14 @@ const contentBox = document.querySelector("#content");
/* /*
Make the content box editable as soon as the user mouses over the sidebar. Make the content box editable as soon as the user mouses over the sidebar.
*/ */
window.addEventListener("mouseover", (e) => { window.addEventListener("mouseover", () => {
contentBox.setAttribute("contenteditable", true); contentBox.setAttribute("contenteditable", true);
}); });
/* /*
When the user mouses out, save the current contents of the box. When the user mouses out, save the current contents of the box.
*/ */
window.addEventListener("mouseout", (e) => { window.addEventListener("mouseout", () => {
contentBox.setAttribute("contenteditable", false); contentBox.setAttribute("contenteditable", false);
browser.tabs.query({windowId: myWindowId, active: true}).then((tabs) => { browser.tabs.query({windowId: myWindowId, active: true}).then((tabs) => {
let contentToStore = {}; let contentToStore = {};

View File

@@ -51,7 +51,7 @@ When first loaded, initialize the page action for all tabs.
*/ */
var gettingAllTabs = browser.tabs.query({}); var gettingAllTabs = browser.tabs.query({});
gettingAllTabs.then((tabs) => { gettingAllTabs.then((tabs) => {
for (tab of tabs) { for (let tab of tabs) {
initializePageAction(tab); initializePageAction(tab);
} }
}); });

View File

@@ -12,7 +12,7 @@
*/ */
var gettingAllCommands = browser.commands.getAll(); var gettingAllCommands = browser.commands.getAll();
gettingAllCommands.then((commands) => { gettingAllCommands.then((commands) => {
for (command of commands) { for (let command of commands) {
console.log(command); console.log(command);
} }
}); });

View File

@@ -2,6 +2,8 @@
* This file contains the Map of word --> emoji substitutions. * This file contains the Map of word --> emoji substitutions.
*/ */
/* exported sortedEmojiMap */
let dictionary = new Map(); let dictionary = new Map();
dictionary.set('apple', '🍎'); dictionary.set('apple', '🍎');
dictionary.set('banana', '🍌'); dictionary.set('banana', '🍌');

View File

@@ -3,6 +3,8 @@
* all occurrences of each mapped word with its emoji counterpart. * all occurrences of each mapped word with its emoji counterpart.
*/ */
/*global sortedEmojiMap*/
// emojiMap.js defines the 'sortedEmojiMap' variable. // emojiMap.js defines the 'sortedEmojiMap' variable.
// Referenced here to reduce confusion. // Referenced here to reduce confusion.
const emojiMap = sortedEmojiMap; const emojiMap = sortedEmojiMap;

View File

@@ -1,3 +1,5 @@
/* exported getAccessToken */
const REDIRECT_URL = browser.identity.getRedirectURL(); const REDIRECT_URL = browser.identity.getRedirectURL();
const CLIENT_ID = "YOUR-CLIENT-ID"; const CLIENT_ID = "YOUR-CLIENT-ID";
const SCOPES = ["openid", "email", "profile"]; const SCOPES = ["openid", "email", "profile"];

View File

@@ -1,3 +1,5 @@
/*global getAccessToken*/
function notifyUser(user) { function notifyUser(user) {
browser.notifications.create({ browser.notifications.create({
"type": "basic", "type": "basic",

View File

@@ -2,6 +2,9 @@
Fetch the user's info, passing in the access token in the Authorization Fetch the user's info, passing in the access token in the Authorization
HTTP request header. HTTP request header.
*/ */
/* exported getUserInfo */
function getUserInfo(accessToken) { function getUserInfo(accessToken) {
const requestURL = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json"; const requestURL = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json";
const requestHeaders = new Headers(); const requestHeaders = new Headers();

View File

@@ -7,7 +7,7 @@ function get_hostname(url) {
} }
function set_domain(domain) { function set_domain(domain) {
spans = document.getElementsByClassName('domain'); const spans = document.getElementsByClassName('domain');
[].slice.call(spans).forEach((span) => { [].slice.call(spans).forEach((span) => {
span.textContent = domain; span.textContent = domain;
}); });
@@ -65,7 +65,7 @@ function clearAll(e) {
// Loop through them and delete them one by one. // Loop through them and delete them one by one.
var searchingHistory = browser.history.search({text: hostname}) var searchingHistory = browser.history.search({text: hostname})
searchingHistory.then((results) => { searchingHistory.then((results) => {
for (k = 0; k < results.length; k++) { for (let k of results) {
browser.history.deleteUrl({url: results[k].url}); browser.history.deleteUrl({url: results[k].url});
} }
// Clear out the UI. // Clear out the UI.

View File

@@ -1,6 +1,6 @@
function showCookiesForTab(tabs) { function showCookiesForTab(tabs) {
//get the first tab object in the array //get the first tab object in the array
tab = tabs.pop(); let tab = tabs.pop();
//get all cookies in the domain //get all cookies in the domain
var gettingAllCookies = browser.cookies.getAll({url: tab.url}); var gettingAllCookies = browser.cookies.getAll({url: tab.url});
@@ -14,22 +14,22 @@ function showCookiesForTab(tabs) {
if (cookies.length > 0) { if (cookies.length > 0) {
//add an <li> item with the name and value of the cookie to the list //add an <li> item with the name and value of the cookie to the list
for (cookie of cookies) { for (let cookie of cookies) {
var li = document.createElement("li"); let li = document.createElement("li");
var content = document.createTextNode(cookie.name + ": "+ cookie.value); let content = document.createTextNode(cookie.name + ": "+ cookie.value);
li.appendChild(content); li.appendChild(content);
cookieList.appendChild(li); cookieList.appendChild(li);
} }
} else { } else {
var p = document.createElement("p"); let p = document.createElement("p");
var content = document.createTextNode("No cookies in this tab."); let content = document.createTextNode("No cookies in this tab.");
var parent = cookieList.parentNode; let parent = cookieList.parentNode;
p.appendChild(content); p.appendChild(content);
parent.appendChild(p); parent.appendChild(p);
} }
}); });
}; }
//get active tab to run an callback function. //get active tab to run an callback function.
//it sends to our callback an array of tab objects //it sends to our callback an array of tab objects

View File

@@ -1,3 +1,5 @@
/* exported FindProxyForURL */
var blockedHosts = []; var blockedHosts = [];
const allow = "DIRECT 1234"; const allow = "DIRECT 1234";
const deny = "PROXY 127.0.0.1:65535"; const deny = "PROXY 127.0.0.1:65535";

View File

@@ -1,7 +1,7 @@
/* /*
copy the selected text to clipboard copy the selected text to clipboard
*/ */
function copySelection(e) { function copySelection() {
var selectedText = window.getSelection().toString().trim(); var selectedText = window.getSelection().toString().trim();
if (selectedText) { if (selectedText) {

View File

@@ -163,7 +163,7 @@ document.addEventListener("click", function(e) {
// Currently (11/2/2016) only supported by Chrome // Currently (11/2/2016) only supported by Chrome
else if (e.target.id === "tabs-highlight") { // highlights current tab and next tab (cycles back to first tab if current tab is the last one) else if (e.target.id === "tabs-highlight") { // highlights current tab and next tab (cycles back to first tab if current tab is the last one)
callOnActiveTab((tab, tabs) => { callOnActiveTab((tab, tabs) => {
next = (tab.index+1) % tabs.length; let next = (tab.index+1) % tabs.length;
browser.tabs.highlight({tabs:[tab.index, next]}); browser.tabs.highlight({tabs:[tab.index, next]});
}); });
} }

View File

@@ -26,48 +26,48 @@ document.addEventListener("click", (e) => {
} }
else if (e.target.id === "window-create-normal") { else if (e.target.id === "window-create-normal") {
var createData = {}; let createData = {};
var creating = browser.windows.create(createData); let creating = browser.windows.create(createData);
creating.then(() => { creating.then(() => {
console.log("The normal window has been created"); console.log("The normal window has been created");
}); });
} }
else if (e.target.id === "window-create-incognito") { else if (e.target.id === "window-create-incognito") {
var createData = { let createData = {
incognito: true, incognito: true,
}; };
var creating = browser.windows.create(createData); let creating = browser.windows.create(createData);
creating.then(() => { creating.then(() => {
console.log("The incognito window has been created"); console.log("The incognito window has been created");
}); });
} }
else if (e.target.id === "window-create-panel") { else if (e.target.id === "window-create-panel") {
var createData = { let createData = {
type: "panel", type: "panel",
}; };
var creating = browser.windows.create(createData); let creating = browser.windows.create(createData);
creating.then(() => { creating.then(() => {
console.log("The panel has been created"); console.log("The panel has been created");
}); });
} }
else if (e.target.id === "window-create-detached-panel") { else if (e.target.id === "window-create-detached-panel") {
var createData = { let createData = {
type: "detached_panel", type: "detached_panel",
}; };
var creating = browser.windows.create(createData); let creating = browser.windows.create(createData);
creating.then(() => { creating.then(() => {
console.log("The detached panel has been created"); console.log("The detached panel has been created");
}); });
} }
else if (e.target.id === "window-create-popup") { else if (e.target.id === "window-create-popup") {
var createData = { let createData = {
type: "popup", type: "popup",
}; };
var creating = browser.windows.create(createData); let creating = browser.windows.create(createData);
creating.then(() => { creating.then(() => {
console.log("The popup has been created"); console.log("The popup has been created");
}); });