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

Unified Diff: background.js

Issue 4864767881641984: Issue 1528 - Implemented backend for general tab of new options page (Closed)
Patch Set: Created Jan. 21, 2015, 6:04 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
« no previous file with comments | « no previous file | messageResponder.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -34,7 +34,14 @@
var subscriptions =[
"https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt",
"https://easylist-downloads.adblockplus.org/exceptionrules.txt",
- "https://easylist-downloads.adblockplus.org/fanboy-social.txt"
+ "https://easylist-downloads.adblockplus.org/fanboy-social.txt",
+ "~user~786254"
+ ];
+ var filters = [
+ {text: "@@||alternate.de^$document"},
+ {text: "@@||der.postillion.com^$document"},
+ {text: "@@||taz.de^$document"},
+ {text: "@@||amazon.de^$document"}
];
var modules = {};
@@ -52,6 +59,12 @@
}
};
+ modules.prefs = {
+ Prefs: {
+ "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org/exceptionrules.txt"
+ }
+ }
+
modules.subscriptionClasses = {
Subscription: function(url)
{
@@ -61,11 +74,18 @@
this.lastDownload = 1234;
},
- SpecialSubscription: function() {}
+ SpecialSubscription: function(url) {
+ this.url = url;
+ this.disabled = false;
+ this.filters = filters.slice();
+ }
};
modules.subscriptionClasses.Subscription.fromURL = function(url)
{
- return new modules.subscriptionClasses.Subscription(url);
+ if (/^https?:\/\//.test(url))
+ return new modules.subscriptionClasses.Subscription(url);
+ else
+ return new modules.subscriptionClasses.SpecialSubscription(url);
};
modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionClasses.Subscription;
@@ -102,12 +122,43 @@
subscriptions.splice(index, 1);
modules.filterNotifier.FilterNotifier.triggerListeners("subscription.removed", subscription);
}
+ },
+
+ addFilter: function(filter)
+ {
+ var subscription = Subscription.fromURL("~user~786254");
saroyanm 2015/01/26 19:44:06 Subscription is not defined here, this needs to be
Thomas Greiner 2015/01/27 13:01:07 Done.
+ var index = subscription.filters.indexOf(filter);
+ if (index < 0)
+ {
+ subscription.filters.push(filter);
+ modules.filterNotifier.FilterNotifier.triggerListeners("filter.added", filter);
+ }
+ },
+
+ removeFilter: function(filter)
+ {
+ var subscription = Subscription.fromURL("~user~786254");
saroyanm 2015/01/26 19:44:06 Subscription is not defined here, this needs to be
Thomas Greiner 2015/01/27 13:01:07 Done.
+ var index = subscription.filters.indexOf(filter);
+ if (index >= 0)
+ {
+ subscription.filters.splice(index, 1);
+ modules.filterNotifier.FilterNotifier.triggerListeners("filter.removed", filter);
+ }
}
}
};
modules.filterClasses = {
- BlockingFilter: function() {}
+ BlockingFilter: function() {},
+ Filter: function(text)
+ {
+ this.text = text;
+ this.disabled = false;
+ }
+ };
+ modules.filterClasses.Filter.fromText = function(text)
+ {
+ return new modules.filterClasses.Filter(text);
};
modules.synchronizer = {
« no previous file with comments | « no previous file | messageResponder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld