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

Unified Diff: files/button.js

Issue 8493027: Acquired Opera AdBlock code (Closed)
Patch Set: Created Oct. 2, 2012, 1:15 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
Index: files/button.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/files/button.js
@@ -0,0 +1,50 @@
+const button = {
+ update: function(url) {
+ var url = opera.extension.tabs.getSelected().url;
+ if(url) {
+ if(whitelist.check(url))
+ buttonElement.icon = '/images/icon18.png';
+ else
+ buttonElement.icon = '/images/icon_green18.png';
+ }
+ else
+ buttonElement.icon = '/images/icon_yellow18.png';
+ },
+ click: function() {
+ this.update();
+ },
+ enable: function() {
+ preferences.bool('button', true);
+ this.display();
+ },
+ disable: function() {
+ preferences.bool('button', false);
+ opera.contexts.toolbar.removeItem(buttonElement);
+
+ opera.extension.windows.removeEventListener('focus', button.update, false);
+ opera.extension.tabs.removeEventListener('focus', button.update, false);
+ window.clearInterval(button.update, 1000);
+ },
+ status: function() {
+ return preferences.bool('button');
+ },
+ display: function() {
+ if(this.status()) {
+ this.update();
+ opera.contexts.toolbar.addItem(buttonElement);
+
+ opera.extension.windows.addEventListener('focus', button.update, false);
+ opera.extension.tabs.addEventListener('focus', button.update, false);
+ window.setInterval(button.update, 1000);
+ }
+ }
+};
+var properties = {
+ disabled: true,
+ icon: '/images/icon18.png',
+ title: translate.get('ext_name')
+};
+var buttonElement = opera.contexts.toolbar.createItem(properties);
+buttonElement.addEventListener('click', button.click(), false);
+
+button.display();

Powered by Google App Engine
This is Rietveld