Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: popup.js

Issue 29371763: Issue 4795 - Use modern JavaScript syntax (Closed)
Patch Set: Created Jan. 13, 2017, 12:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/ext/common.js ('K') | « options.js ('k') | qunit/common.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: popup.js
diff --git a/popup.js b/popup.js
index d611a7b44aa3bfd718e15635d0ec99297413008e..09f68343da9616943a3bfbbe0a6396e084281951 100644
--- a/popup.js
+++ b/popup.js
@@ -15,20 +15,20 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-var backgroundPage = ext.backgroundPage.getWindow();
-var require = backgroundPage.require;
+let backgroundPage = ext.backgroundPage.getWindow();
+let require = backgroundPage.require;
-var Filter = require("filterClasses").Filter;
-var FilterStorage = require("filterStorage").FilterStorage;
-var Prefs = require("prefs").Prefs;
-var checkWhitelisted = require("whitelisting").checkWhitelisted;
-var getDecodedHostname = require("url").getDecodedHostname;
+let Filter = require("filterClasses").Filter;
+let FilterStorage = require("filterStorage").FilterStorage;
+let Prefs = require("prefs").Prefs;
+let checkWhitelisted = require("whitelisting").checkWhitelisted;
+let getDecodedHostname = require("url").getDecodedHostname;
-var page = null;
+let page = null;
function onLoad()
{
- ext.pages.query({active: true, lastFocusedWindow: true}, function(pages)
+ ext.pages.query({active: true, lastFocusedWindow: true}, pages =>
{
page = pages[0];
@@ -40,7 +40,7 @@ function onLoad()
{
document.body.classList.add("nohtml");
require("messaging").getPort(window).on(
- "composer.ready", function(message, sender)
+ "composer.ready", (message, sender) =>
{
if (sender.page.id == page.id)
document.body.classList.remove("nohtml");
@@ -57,7 +57,7 @@ function onLoad()
if (checkWhitelisted(page))
document.body.classList.add("disabled");
- page.sendMessage({type: "composer.content.getState"}, function(response)
+ page.sendMessage({type: "composer.content.getState"}, response =>
{
if (response && response.active)
document.body.classList.add("clickhide-active");
@@ -68,16 +68,14 @@ function onLoad()
document.getElementById("enabled").addEventListener("click", toggleEnabled, false);
document.getElementById("clickhide").addEventListener("click", activateClickHide, false);
document.getElementById("clickhide-cancel").addEventListener("click", cancelClickHide, false);
- document.getElementById("options").addEventListener("click", function()
+ document.getElementById("options").addEventListener("click", () =>
{
ext.showOptions();
}, false);
// Set up collapsing of menu items
- var collapsers = document.getElementsByClassName("collapse");
- for (var i = 0; i < collapsers.length; i++)
+ for (let collapser of document.getElementsByClassName("collapse"))
{
- var collapser = collapsers[i];
collapser.addEventListener("click", toggleCollapse, false);
if (!Prefs[collapser.dataset.option])
document.getElementById(collapser.dataset.collapsable).classList.add("collapsed");
@@ -86,11 +84,11 @@ function onLoad()
function toggleEnabled()
{
- var disabled = document.body.classList.toggle("disabled");
+ let disabled = document.body.classList.toggle("disabled");
if (disabled)
{
- var host = getDecodedHostname(page.url).replace(/^www\./, "");
- var filter = Filter.fromText("@@||" + host + "^$document");
+ let host = getDecodedHostname(page.url).replace(/^www\./, "");
+ let filter = Filter.fromText("@@||" + host + "^$document");
if (filter.subscriptions.length && filter.disabled)
filter.disabled = false;
else
@@ -102,7 +100,7 @@ function toggleEnabled()
else
{
// Remove any exception rules applying to this URL
- var filter = checkWhitelisted(page);
+ let filter = checkWhitelisted(page);
while (filter)
{
FilterStorage.removeFilter(filter);
@@ -135,7 +133,7 @@ function cancelClickHide()
function toggleCollapse(event)
{
- var collapser = event.currentTarget;
+ let collapser = event.currentTarget;
Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option];
collapser.parentNode.classList.toggle("collapsed");
}
« chrome/ext/common.js ('K') | « options.js ('k') | qunit/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld