|
Page Updated: July 20, 2004
Latest Version: 0.1.375 |
|
Debug |
Install | File
I/O |
RDF |
Network |
Sound | Utils |
XUL | Zip
|
|
|
Home | Mailing List |
Install |
Source Code |
Downloads | Bugs
| docs
| clients |
Prefs
File: utils/prefs.js
Status: Up to Date
Module Identifier: jslib_prefs
Fuction List
- Constructor
- Prefs ()
- Creates the Prefs object.
- Members
- setBool (aPrefName, aBool)
- This sets a bool type pref.
- getBool (aPrefName)
- This gets the bool value for the specified pref.
- setChar (aPrefName, aString)
- Set a char type pref.
- getChar (aPrefName)
- Get a char type pref.
- setInt (aPrefName, aInt)
- Set a char type pref.
- getInt (aPrefName)
- Get a char type pref.
- getType (aPrefName)
- Get the type of Pref (bool, int, char) - returns undefined if
pref is not available.
- save (aFile)
- Save prefs to a file.
- aFile is an
optional argument.
- reset ()
- Completely flush and reload the preferences system.
- resetUser ()
- Flush all current user prefrences (resets all preferences to
the default values).
- clear (aPrefString)
- Clear the specified user pref.
Example
To use the Prefs library:// include the prefs library include (jslib_prefs); // constructor
var pref = new Prefs();
// enable dump output
const pref_str = "browser.dom.window.dump.enabled";
if (!pref.getBool(pref_str))
pref.setBool(pref_str, true);
// set a proxy host
const pref_proxy_host = "network.proxy.http";
pref.setChar(pref_proxy_host, "myserver");
// set proxy port
const pref_proxy_port = "network.proxy.http_port";
pref.setInt(pref_proxy_port, 3128);
// get the pref host
var host = pref.getChar(pref_proxy_host);
// get the pref port number
var port = pref.getInt(pref_proxy_port);
// save the prefs to a file
// there are three ways to do this
// save to the default prefs file
pref.save();
// save to a specified file
pref.save("/tmp/my_prefs_1_file.js");
// save using an nsIFile object
include (jslib_file);
var f = new File ("/tmp/my_prefs_2_file.js");
pref.save(f.nsIFile);