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

Unified Diff: options/whitelist.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
« files/sources.js ('K') | « options/time.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« files/sources.js ('K') | « options/time.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld