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

Unified Diff: ext/background.js

Issue 29375899: Issue 4871 - Start using ESLint for adblockplusui (Closed)
Patch Set: Addressed Wladimir's feedback, restored IIFEs Created March 10, 2017, 7:25 a.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
« no previous file with comments | « devtools-panel.js ('k') | ext/common.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/background.js
diff --git a/ext/background.js b/ext/background.js
index 88665eab3e936b3225131b706751a01eee9014d8..1874974f64ffe97519fdc02ecfaba9c75f1fcbe0 100644
--- a/ext/background.js
+++ b/ext/background.js
@@ -15,17 +15,19 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-(function(global)
+"use strict";
+
+(function()
{
- if (!global.ext)
- global.ext = {};
+ if (typeof ext == "undefined")
+ window.ext = {};
- window.addEventListener("load", function()
+ window.addEventListener("load", () =>
{
parent.postMessage({
type: "backgroundPageLoaded"
}, "*");
- }, false)
+ }, false);
function PageMap()
{
@@ -33,27 +35,27 @@
this._values = [];
}
PageMap.prototype = {
- keys: function()
+ keys()
{
- return this._keys.map(function(source)
+ return this._keys.map((source) =>
{
- return new global.ext.Page(source);
+ return new window.ext.Page(source);
});
},
- get: function(page)
+ get(page)
{
return this._values[this._keys.indexOf(page._source)];
},
- set: function(page, value)
+ set(page, value)
{
- var index = this._keys.indexOf(page._source);
+ let index = this._keys.indexOf(page._source);
if (index < 0)
{
index = this._keys.push(page._source) - 1;
- var callback = function()
+ let callback = function()
{
page._source.removeEventListener("unload", callback, false);
this.delete(page);
@@ -63,9 +65,9 @@
this._values[index] = value;
},
- delete: function(page)
+ delete(page)
{
- var index = this._keys.indexOf(page._source);
+ let index = this._keys.indexOf(page._source);
if (index >= 0)
{
this._keys.splice(index, 1);
@@ -74,9 +76,9 @@
}
};
- global.ext.PageMap = PageMap;
+ window.ext.PageMap = PageMap;
- global.ext.showOptions = function(callback)
+ window.ext.showOptions = function(callback)
{
if (top.location.href.indexOf("new-options.html") == -1)
window.open("new-options.html", "_blank");
@@ -85,11 +87,11 @@
callback();
};
- global.ext.devtools = {
+ window.ext.devtools = {
onCreated: {
- addListener: function(listener)
+ addListener(listener)
{
- window.addEventListener("message", function(event)
+ window.addEventListener("message", (event) =>
{
if (event.data.type == "devtools")
listener(new ext.Page(event.source));
@@ -97,4 +99,4 @@
}
}
};
-})(this);
+}());
« no previous file with comments | « devtools-panel.js ('k') | ext/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld