home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2006 October
/
wn148cd2.iso
/
Windows
/
S'informer
/
Netcraft
/
netcrafttoolbar.xpi
/
chrome
/
netcrafttoolbar.jar
/
content
/
options.js
< prev
next >
Wrap
Text File
|
2005-08-04
|
3KB
|
141 lines
/*
* NetcraftToolbar - Options Window
*
* Copyright (C) 2005 Netcraft Ltd
* http://toolbar.netcraft.com/
*
* $Id: chrome:content:options.js,v 1.28 2005/06/10 00:52:02 jez Exp $
*/
const PT_VERSION = "1.0.3.3";
const PT_BRANCHNAME = "netcrafttoolbar.";
const PT_VERSIONPREF = "version";
const PT_IDPREF = "id";
const PT_EXTLASTUPDATE = "extensions.update.lastUpdateDate";
const PT_BROWSEROFFLINE = "browser.offline";
const PT_BROWSEROPEN = "browser.link.open_external";
const PT_BROWSERBG = "browser.tabs.loadBookmarksInBackground";
const PT_ABOUTWINDOWURI = "chrome://netcrafttoolbar/content/about.xul";
const PT_ABOUTWINDOWTITLE = "About NetcraftToolbar";
const PT_ABOUTWINDOWPARAMS = "chrome,centerscreen";
const PT_BUILDHEX = "123C710F44FA";
var ptPrefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);
function PtPreferences(node) {
this.branch = ptPrefs.getBranch(node);
}
PtPreferences.prototype.setIntPref = function (pref, i) {
try {
this.branch.setIntPref(pref, i);
}
catch (e) {
}
}
PtPreferences.prototype.getIntPref = function (pref,dflt) {
var i;
try {
i = this.branch.getIntPref(pref);
}
catch (e) {
this.branch.setIntPref(pref, dflt);
i = this.branch.getIntPref(pref);
}
return i;
}
PtPreferences.prototype.setCharPref = function (pref, s) {
try {
this.branch.setCharPref(pref, s);
}
catch (e) {
}
}
PtPreferences.prototype.getCharPref = function (pref,dflt) {
var s;
try {
s = this.branch.getCharPref(pref);
}
catch (e) {
this.branch.setCharPref(pref, dflt);
s = this.branch.getCharPref(pref);
}
return s;
}
PtPreferences.prototype.setBoolPref = function (pref, b) {
try {
this.branch.setBoolPref(pref, b);
}
catch (e) {
}
}
PtPreferences.prototype.getBoolPref = function (pref,dflt) {
var b;
try {
b = this.branch.getBoolPref(pref);
}
catch (e) {
this.branch.setBoolPref(pref, dflt);
b = this.branch.getBoolPref(pref);
}
return b;
}
PtPreferences.prototype.deletePrefsBranch = function () {
this.branch.deleteBranch("");
}
var ptToolbarPrefs = {
_root: (new PtPreferences(null)),
_tree: (new PtPreferences(PT_BRANCHNAME)),
getUpdateInterval: function () {
return this._root.setIntPref(PT_EXTLASTUPDATE, 0);
},
setUpdateInterval: function () {
this._root.setIntPref(PT_EXTLASTUPDATE, 0);
},
isOffline: function () {
return this._root.getBoolPref(PT_BROWSEROFFLINE);
},
_genid: function () {
var datepart = new Date().getTime().toString(16).toUpperCase();
var randpart =
("000000000" + (Math.floor(Math.random() * 1e17)).toString(16)).
substr(-9).toUpperCase();
return(randpart + PT_BUILDHEX + datepart);
},
newWindow: function () {
return this._root.getIntPref(PT_BROWSEROPEN);
},
bg: function () {
return this._root.getBoolPref(PT_BROWSERBG);
},
getVersion: function () {
return this._tree.getCharPref(PT_VERSIONPREF);
},
setVersion: function (vers) {
this._tree.setCharPref(PT_VERSIONPREF,vers);
}
};
ptToolbarPrefs.uuid =
ptToolbarPrefs._tree.getCharPref(PT_IDPREF,ptToolbarPrefs._genid());
function PtOpenToolbarAboutWindow() {
window.openDialog(PT_ABOUTWINDOWURI, PT_ABOUTWINDOWTITLE, PT_ABOUTWINDOWPARAMS);
}
ptToolbarPrefs.setVersion(PT_VERSION);