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

Unified Diff: files/preferences.js

Issue 8483154: Adding ABP core modules to ABP/Opera (Closed)
Patch Set: Created Oct. 9, 2012, 9:51 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
Index: files/preferences.js
===================================================================
deleted file mode 100644
--- a/files/preferences.js
+++ /dev/null
@@ -1,83 +0,0 @@
-const preferences = {
- string: function(key, value) { //Gets or sets a string value
- if(value == undefined) //Gets
- return widget.preferences.getItem(key);
- else //Sets
- widget.preferences.setItem(key, value);
- },
- bool: function(key, value) { //Gets or sets a bool value
- if(value == undefined) { //Gets
- switch(widget.preferences.getItem(key)) {
- case 'true':
- return true;
- break;
- default: //Returns false if the value doesn't exist
- return false;
- break;
- }
- }
- else { //Sets
- if(value)
- widget.preferences.setItem(key, 'true');
- else
- this.remove(key); //When set to false, remove the key to save space
- }
- },
- int: function(key, value) { //Gets or sets a int value
- if(value == undefined) { //Gets
- value = parseInt(widget.preferences.getItem(key));
- if(value == NaN)
- return 0; //On error return 0
- else
- return value;
- }
- else //Sets
- widget.preferences.setItem(key, value);
- },
- float: function(key, value) { //Gets or sets a float value
- if(value == undefined) { //Gets
- value = parseFloat(widget.preferences.getItem(key));
- if(value == NaN)
- return 0; //On error return 0
- else
- return value;
- }
- else //Sets
- widget.preferences.setItem(key, value);
- },
- array: function(key, value) { //Gets or sets an array in the preferences
- if(value == undefined) { //Gets
- if(this.exist(key)) {
- value = widget.preferences.getItem(key);
- if(value.indexOf("\n") > -1)
- return value.split("\n");
- else {
- return [value];
- }
- }
- return new Array(); //Returns an empty array when no value exists
- }
- else if(value instanceof Array) { //Sets
- value = value.join("\n");
- widget.preferences.setItem(key, value);
- }
- },
- invert: function(key) { //Inverts a true/false setting
- switch(widget.preferences.getItem(key)) {
- case 'true':
- widget.preferences.setItem(key, 'false');
- break;
- default:
- widget.preferences.setItem(key, 'true');
- break;
- }
- },
- exist: function(key) { //Says if a preference exists
- if(widget.preferences.getItem(key) != null && widget.preferences.getItem(key) != '')
- return true;
- return false;
- },
- remove: function(key) {
- widget.preferences.removeItem(key);
- }
-};

Powered by Google App Engine
This is Rietveld