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. 8, 2012, 5:58 a.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
« no previous file with comments | « 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,70 @@
+if(opera.version() >= 12.1) { //Whitelist is only supported above Opera 12.1
+
+ 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();
+
+}
« no previous file with comments | « options/time.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld