| OLD | NEW | 
 | (Empty) | 
|   1 const button = { |  | 
|   2         update: function(url) { |  | 
|   3                 var url = opera.extension.tabs.getSelected().url; |  | 
|   4                 if(url) { |  | 
|   5                         if(whitelist.check(url)) |  | 
|   6                                 buttonElement.icon = '/images/icon18.png'; |  | 
|   7                         else |  | 
|   8                                 buttonElement.icon = '/images/icon_green18.png'; |  | 
|   9                 } |  | 
|  10                 else |  | 
|  11                         buttonElement.icon = '/images/icon_yellow18.png'; |  | 
|  12         }, |  | 
|  13         click: function() { |  | 
|  14                 this.update(); |  | 
|  15         }, |  | 
|  16         enable: function() { |  | 
|  17                 preferences.bool('button', true); |  | 
|  18                 this.display(); |  | 
|  19         }, |  | 
|  20         disable: function() { |  | 
|  21                 preferences.bool('button', false); |  | 
|  22                 opera.contexts.toolbar.removeItem(buttonElement); |  | 
|  23                  |  | 
|  24                 opera.extension.windows.removeEventListener('focus', button.upda
    te, false); |  | 
|  25                 opera.extension.tabs.removeEventListener('focus', button.update,
     false); |  | 
|  26                 window.clearInterval(button.update, 1000); |  | 
|  27         }, |  | 
|  28         status: function() { |  | 
|  29                 return preferences.bool('button'); |  | 
|  30         }, |  | 
|  31         display: function() { |  | 
|  32                 if(this.status()) { |  | 
|  33                         this.update(); |  | 
|  34                         opera.contexts.toolbar.addItem(buttonElement); |  | 
|  35                          |  | 
|  36                         opera.extension.windows.addEventListener('focus', button
    .update, false); |  | 
|  37                         opera.extension.tabs.addEventListener('focus', button.up
    date, false); |  | 
|  38                         window.setInterval(button.update, 1000); |  | 
|  39                 } |  | 
|  40         } |  | 
|  41 }; |  | 
|  42 var properties = { |  | 
|  43         disabled: true, |  | 
|  44         icon: '/images/icon18.png', |  | 
|  45         title: translate.get('ext_name') |  | 
|  46 }; |  | 
|  47 var buttonElement = opera.contexts.toolbar.createItem(properties); |  | 
|  48 buttonElement.addEventListener('click', button.click(), false); |  | 
|  49  |  | 
|  50 button.display(); |  | 
| OLD | NEW |