var $Prefs = { _getBranch : Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch), _getService : Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService), set : function(pref_name, pref_value) { var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); str.data = pref_value.replace(/^\s*|\s*$/g,''); (this._getBranch).setComplexValue(pref_name, Components.interfaces.nsISupportsString, str); }, get : function(pref_name){ try{ return (this._getBranch).getComplexValue(pref_name,Components.interfaces.nsISupportsString).data; } catch(e){ return false;} }, remove : function(pref_name){ try{ (this._getBranch).clearUserPref(pref_name) } catch(e){} }, remove_all : function(pref_name){ try{ (this._getBranch).deleteBranch(pref_name,'') } catch(e){} }, branch : function(pref_name){ var serialBranch = (this._getService).getBranch(pref_name+'.'); return serialBranch.getChildList("",{}); } }
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Mozilla Preferences helper library (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Sqlite helper library for Mo... in javascript mozilla sqlite xul
» Dynamically adding XUL elements in javascript mozilla dom xul
» Opening window/tab helper li... in javascript mozilla dom xul
» Mozilla export coordinates t... in google javascript mozilla xml convert maps kml geo
» Javascript todo-list sorter in javascript
» proxy.pac file for Firefox /... in proxy firefox mozilla proxy.pac
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails