| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 1 const button = { | 1 const button = { | 
| 2 update: function(url) { | 2 update: function(url) { | 
| 3 var url = opera.extension.tabs.getSelected().url; | 3 var url = opera.extension.tabs.getSelected().url; | 
| 4 if(url) { | 4 if(url) { | 
| 5 if(whitelist.check(url)) | 5 if(whitelist.check(url)) | 
| 6 buttonElement.icon = '/images/icon18.png'; | 6 buttonElement.icon = '/images/icon18.png'; | 
| 7 else | 7 else | 
| 8 buttonElement.icon = '/images/icon_green18.png'; | 8 buttonElement.icon = '/images/icon_green18.png'; | 
| 9 } | 9 } | 
| 10 else | 10 else | 
| 11 buttonElement.icon = '/images/icon_yellow18.png'; | 11 buttonElement.icon = '/images/icon_yellow18.png'; | 
| 12 }, | 12 }, | 
| 13 click: function() { | 13 click: function() { | 
| 
 
Felix Dahlke
2012/10/10 12:11:22
This is just an alias for update() that's just use
 
Wladimir Palant
2012/10/11 09:36:26
I didn't change this file, merely renamed it becau
 
 | |
| 14 this.update(); | 14 this.update(); | 
| 15 }, | 15 }, | 
| 16 enable: function() { | 16 enable: function() { | 
| 17 preferences.bool('button', true); | 17 preferences.bool('button', true); | 
| 18 this.display(); | 18 this.display(); | 
| 19 }, | 19 }, | 
| 20 disable: function() { | 20 disable: function() { | 
| 21 preferences.bool('button', false); | 21 preferences.bool('button', false); | 
| 22 opera.contexts.toolbar.removeItem(buttonElement); | 22 opera.contexts.toolbar.removeItem(buttonElement); | 
| 23 | 23 | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 34 opera.contexts.toolbar.addItem(buttonElement); | 34 opera.contexts.toolbar.addItem(buttonElement); | 
| 35 | 35 | 
| 36 opera.extension.windows.addEventListener('focus', button .update, false); | 36 opera.extension.windows.addEventListener('focus', button .update, false); | 
| 37 opera.extension.tabs.addEventListener('focus', button.up date, false); | 37 opera.extension.tabs.addEventListener('focus', button.up date, false); | 
| 38 window.setInterval(button.update, 1000); | 38 window.setInterval(button.update, 1000); | 
| 39 } | 39 } | 
| 40 } | 40 } | 
| 41 }; | 41 }; | 
| 42 var properties = { | 42 var properties = { | 
| 43 disabled: true, | 43 disabled: true, | 
| 44 icon: '/images/icon18.png', | 44 icon: '/images/icon18.png', | 
| 
 
Felix Dahlke
2012/10/10 12:11:22
update() is called soon, overwriting the icon prop
 
 | |
| 45 title: translate.get('ext_name') | 45 title: translate.get('ext_name') | 
| 46 }; | 46 }; | 
| 47 var buttonElement = opera.contexts.toolbar.createItem(properties); | 47 var buttonElement = opera.contexts.toolbar.createItem(properties); | 
| 48 buttonElement.addEventListener('click', button.click(), false); | 48 buttonElement.addEventListener('click', button.click(), false); | 
| 49 | 49 | 
| 50 button.display(); | 50 button.display(); | 
| OLD | NEW |