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

Delta Between Two Patch Sets: options/whitelist.js

Issue 8493027: Acquired Opera AdBlock code (Closed)
Left Patch Set: Created Oct. 2, 2012, 1:15 p.m.
Right Patch Set: Created Oct. 8, 2012, 5:58 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « options/time.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 var section = document.createElement('h3'); 1 if(opera.version() >= 12.1) { //Whitelist is only supported above Opera 12.1
2 section.appendChild(document.createTextNode(translate.get('whitelist')));
3 listsParent.appendChild(section);
4 2
5 var descript = document.createElement('p'); 3 » var section = document.createElement('h3');
6 descript.innerHTML = translate.get('whitelist_descript'); 4 » section.appendChild(document.createTextNode(translate.get('whitelist'))) ;
7 listsParent.appendChild(descript); 5 » listsParent.appendChild(section);
8 6
9 var element = document.createElement('div'); 7 » var descript = document.createElement('p');
10 element.setAttribute('id', 'whitelist'); 8 » descript.innerHTML = translate.get('whitelist_descript');
11 element.setAttribute('class', 'section'); 9 » listsParent.appendChild(descript);
12 listsParent.appendChild(element);
13 10
14 var element = document.createElement('input'); 11 » var element = document.createElement('div');
15 element.setAttribute('id', 'newWhitelist'); 12 » element.setAttribute('id', 'whitelist');
16 element.setAttribute('type', 'text'); 13 » element.setAttribute('class', 'section');
17 element.setAttribute('placeholder', translate.get('whitelist_holder')); 14 » listsParent.appendChild(element);
18 listsParent.appendChild(element);
19 15
20 var elementParent = document.createElement('div'); 16 » var element = document.createElement('input');
21 elementParent.setAttribute('class', 'button_parent'); 17 » element.setAttribute('id', 'newWhitelist');
22 var element = document.createElement('button'); 18 » element.setAttribute('type', 'text');
23 element.setAttribute('onClick', 'whitelist.add()'); 19 » element.setAttribute('placeholder', translate.get('whitelist_holder'));
24 element.appendChild(document.createTextNode(translate.get('save_apply'))); 20 » listsParent.appendChild(element);
25 elementParent.appendChild(element)
26 listsParent.appendChild(elementParent);
27 21
28 const whitelist = { 22 » var elementParent = document.createElement('div');
29 » add: function() { 23 » elementParent.setAttribute('class', 'button_parent');
30 » » var rule = document.getElementById('newWhitelist').value; 24 » var element = document.createElement('button');
31 » » if(rule != "") { 25 » element.setAttribute('onClick', 'whitelist.add()');
32 » » » lists.whitelist.add(rule, true); 26 » element.appendChild(document.createTextNode(translate.get('save_apply')) );
33 » » » document.getElementById('newWhitelist').value = ""; 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);
34 opera.extension.postMessage({request: 'ping', type: 'css '}); 42 opera.extension.postMessage({request: 'ping', type: 'css '});
35 this.display(); 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);
36 } 66 }
37 },
38 remove: function(rule) {
39 lists.whitelist.remove(rule, true);
40 opera.extension.postMessage({request: 'ping', type: 'css'});
41 this.display();
42 },
43 display: function() {
44 var container = document.createElement('div');
45 var whitelist = lists.whitelist.get();
46 for(i in whitelist) {
47 var element = document.createElement('span');
48 var removeLink = document.createElement('a');
49 var removeButton = document.createElement('img');
50 removeButton.setAttribute('src', '/images/remove14.png') ;
51 removeButton.setAttribute('style', 'vertical-align: midd le;');
52 removeLink.appendChild(removeButton);
53 removeLink.setAttribute('onClick', 'whitelist.remove("' + whitelist[i] +'")');
54 element.appendChild(removeLink);
55 element.appendChild(document.createTextNode(' ' + whitel ist[i]));
56 container.appendChild(element);
57 var br = document.createElement('br');
58 container.appendChild(br);
59 }
60
61 var whiteParent = document.getElementById('whitelist');
62 whiteParent.innerHTML = '';
63 whiteParent.appendChild(container);
64 } 67 }
65 } 68 » whitelist.display();
66 whitelist.display(); 69
70 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld