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

Side by Side Diff: options/whitelist.js

Issue 8560083: adblockplusopera: Port UI code from Chrome (Closed)
Patch Set: Created Oct. 18, 2012, 1:26 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 if(opera.version() >= 12.1) { //Whitelist is only supported above Opera 12.1
2
3 var section = document.createElement('h3');
4 section.appendChild(document.createTextNode(translate.get('whitelist'))) ;
5 listsParent.appendChild(section);
6
7 var descript = document.createElement('p');
8 descript.innerHTML = translate.get('whitelist_descript');
9 listsParent.appendChild(descript);
10
11 var element = document.createElement('div');
12 element.setAttribute('id', 'whitelist');
13 element.setAttribute('class', 'section');
14 listsParent.appendChild(element);
15
16 var element = document.createElement('input');
17 element.setAttribute('id', 'newWhitelist');
18 element.setAttribute('type', 'text');
19 element.setAttribute('placeholder', translate.get('whitelist_holder'));
20 listsParent.appendChild(element);
21
22 var elementParent = document.createElement('div');
23 elementParent.setAttribute('class', 'button_parent');
24 var element = document.createElement('button');
25 element.setAttribute('onClick', 'whitelist.add()');
26 element.appendChild(document.createTextNode(translate.get('save_apply')) );
27 elementParent.appendChild(element)
28 listsParent.appendChild(elementParent);
29
30 const whitelist = {
31 add: function() {
32 var rule = document.getElementById('newWhitelist').value ;
33 if(rule != "") {
34 lists.whitelist.add(rule, true);
35 document.getElementById('newWhitelist').value = "";
36 opera.extension.postMessage({request: 'ping', ty pe: 'css'});
37 this.display();
38 }
39 },
40 remove: function(rule) {
41 lists.whitelist.remove(rule, true);
42 opera.extension.postMessage({request: 'ping', type: 'css '});
43 this.display();
44 },
45 display: function() {
46 var container = document.createElement('div');
47 var whitelist = lists.whitelist.get();
48 for(i in whitelist) {
49 var element = document.createElement('span');
50 var removeLink = document.createElement('a');
51 var removeButton = document.createElement('img') ;
52 removeButton.setAttribute('src', '/images/remove 14.png');
53 removeButton.setAttribute('style', 'vertical-ali gn: middle;');
54 removeLink.appendChild(removeButton);
55 removeLink.setAttribute('onClick', 'whitelist.re move("' + whitelist[i] +'")');
56 element.appendChild(removeLink);
57 element.appendChild(document.createTextNode(' ' + whitelist[i]));
58 container.appendChild(element);
59 var br = document.createElement('br');
60 container.appendChild(br);
61 }
62
63 var whiteParent = document.getElementById('whitelist');
64 whiteParent.innerHTML = '';
65 whiteParent.appendChild(container);
66 }
67 }
68 whitelist.display();
69
70 }
OLDNEW
« background.js ('K') | « options/time.js ('k') | update_locales.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld