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

Side by Side Diff: files/css.js

Issue 8483154: Adding ABP core modules to ABP/Opera (Closed)
Patch Set: Created Oct. 11, 2012, 9:35 a.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 const css = {
2 get: function(key) {
3 return preferences.array(key + '-content');
4 },
5 personal: function() {
6 return preferences.array('css-perso-content');
7 },
8 refresh: function() {
9 var success = true;
10 for(key in sources.css) {
11 if(preferences.bool(key)){ //If the list is enabled, upd ate it
12 if(!this.update(key)) //In case of error with th e update
13 success = false;
14 }
15 else //If the list is disabled, remove it
16 this.disable(key, false);
17 }
18 //opera.extension.postMessage({request: 'ping', type: 'css'}); / /Make all webpages update
19 return success;
20 },
21 time: function(key) {
22 return preferences.int(key + '-time');
23 },
24 update: function(key) {
25 //opera.postError('Update called for ' + key);
26 var value = download(sources.css[key]).replace(/\/\*(.|\n)*?\*\/ (\n)?/gm, '').split('\n');
27 //opera.postError(value.join("\n"));
28 if(value instanceof Array) {
29 preferences.array(key + '-content', value);
30 preferences.int(key + '-time', getTime());
31 return true;
32 }
33 else
34 return false;
35 },
36 status: function(key) {
37 return preferences.bool(key);
38 },
39 disable: function(key, ping) { //Disables a source
40 preferences.remove(key + '-time');
41 preferences.remove(key + '-content');
42 preferences.bool(key, false);
43 if(ping)
44 opera.extension.postMessage({request: 'ping', type: 'css '});
45 return true;
46 },
47 enable: function(key, ping) { //Enables a source
48 this.update(key);
49 preferences.bool(key, true);
50 if(ping)
51 opera.extension.postMessage({request: 'ping', type: 'css '});
52 }
53 };
OLDNEW

Powered by Google App Engine
This is Rietveld