Index: options/whitelist.js |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/options/whitelist.js |
@@ -0,0 +1,66 @@ |
+var section = document.createElement('h3'); |
+section.appendChild(document.createTextNode(translate.get('whitelist'))); |
+listsParent.appendChild(section); |
+ |
+var descript = document.createElement('p'); |
+descript.innerHTML = translate.get('whitelist_descript'); |
+listsParent.appendChild(descript); |
+ |
+var element = document.createElement('div'); |
+element.setAttribute('id', 'whitelist'); |
+element.setAttribute('class', 'section'); |
+listsParent.appendChild(element); |
+ |
+var element = document.createElement('input'); |
+element.setAttribute('id', 'newWhitelist'); |
+element.setAttribute('type', 'text'); |
+element.setAttribute('placeholder', translate.get('whitelist_holder')); |
+listsParent.appendChild(element); |
+ |
+var elementParent = document.createElement('div'); |
+elementParent.setAttribute('class', 'button_parent'); |
+var element = document.createElement('button'); |
+element.setAttribute('onClick', 'whitelist.add()'); |
+element.appendChild(document.createTextNode(translate.get('save_apply'))); |
+elementParent.appendChild(element) |
+listsParent.appendChild(elementParent); |
+ |
+const whitelist = { |
+ add: function() { |
+ var rule = document.getElementById('newWhitelist').value; |
+ if(rule != "") { |
+ lists.whitelist.add(rule, true); |
+ document.getElementById('newWhitelist').value = ""; |
+ opera.extension.postMessage({request: 'ping', type: 'css'}); |
+ this.display(); |
+ } |
+ }, |
+ remove: function(rule) { |
+ lists.whitelist.remove(rule, true); |
+ opera.extension.postMessage({request: 'ping', type: 'css'}); |
+ this.display(); |
+ }, |
+ display: function() { |
+ var container = document.createElement('div'); |
+ var whitelist = lists.whitelist.get(); |
+ for(i in whitelist) { |
+ var element = document.createElement('span'); |
+ var removeLink = document.createElement('a'); |
+ var removeButton = document.createElement('img'); |
+ removeButton.setAttribute('src', '/images/remove14.png'); |
+ removeButton.setAttribute('style', 'vertical-align: middle;'); |
+ removeLink.appendChild(removeButton); |
+ removeLink.setAttribute('onClick', 'whitelist.remove("' + whitelist[i] +'")'); |
+ element.appendChild(removeLink); |
+ element.appendChild(document.createTextNode(' ' + whitelist[i])); |
+ container.appendChild(element); |
+ var br = document.createElement('br'); |
+ container.appendChild(br); |
+ } |
+ |
+ var whiteParent = document.getElementById('whitelist'); |
+ whiteParent.innerHTML = ''; |
+ whiteParent.appendChild(container); |
+ } |
+} |
+whitelist.display(); |