2006-05-17 02:29:03 +00:00
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
*/
|
2006-05-17 02:22:45 +00:00
|
|
|
|
2006-05-17 02:29:03 +00:00
|
|
|
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
|
|
|
const nsIWindowMediator = Components.interfaces.nsIWindowMediator;
|
2006-05-17 02:32:42 +00:00
|
|
|
const nsIPrefService = Components.interfaces.nsIPrefService;
|
|
|
|
const nsIPrefLocalizedString = Components.interfaces.nsIPrefLocalizedString;
|
2006-05-17 02:22:45 +00:00
|
|
|
|
2006-05-17 02:29:03 +00:00
|
|
|
const FILEPICKER_CONTRACTID = "@mozilla.org/filepicker;1";
|
2006-05-17 02:29:07 +00:00
|
|
|
const WINDOWMEDIATOR_CONTRACTID = "@mozilla.org/appshell/window-mediator;1";
|
2006-05-17 02:32:42 +00:00
|
|
|
const PREFSERVICE_CONTRACTID = "@mozilla.org/preferences-service;1";
|
2006-05-17 02:24:52 +00:00
|
|
|
|
2006-05-17 02:29:03 +00:00
|
|
|
function selectFile()
|
2006-05-17 02:24:52 +00:00
|
|
|
{
|
2006-05-17 02:29:03 +00:00
|
|
|
var fp = Components.classes[FILEPICKER_CONTRACTID]
|
|
|
|
.createInstance(nsIFilePicker);
|
|
|
|
|
|
|
|
var prefutilitiesBundle = document.getElementById("bundle_prefutilities");
|
|
|
|
var title = prefutilitiesBundle.getString("choosehomepage");
|
|
|
|
fp.init(window, title, nsIFilePicker.modeOpen);
|
|
|
|
fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText |
|
|
|
|
nsIFilePicker.filterXML | nsIFilePicker.filterHTML |
|
|
|
|
nsIFilePicker.filterImages);
|
|
|
|
|
|
|
|
var ret = fp.show();
|
|
|
|
if (ret == nsIFilePicker.returnOK) {
|
|
|
|
var folderField = document.getElementById("browserStartupHomepage");
|
|
|
|
folderField.value = fp.fileURL.spec;
|
|
|
|
}
|
2006-05-17 02:24:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-17 02:29:03 +00:00
|
|
|
function setHomePageToCurrentPage()
|
2006-05-17 02:24:52 +00:00
|
|
|
{
|
2006-05-17 02:29:03 +00:00
|
|
|
var windowManager = Components.classes[WINDOWMEDIATOR_CONTRACTID]
|
|
|
|
.getService(nsIWindowMediator);
|
|
|
|
|
|
|
|
var browserWindow = windowManager.getMostRecentWindow("navigator:browser");
|
|
|
|
if (browserWindow) {
|
|
|
|
var browser = browserWindow.document.getElementById("content");
|
|
|
|
var url = browser.webNavigation.currentURI.spec;
|
|
|
|
if (url) {
|
|
|
|
var homePageField = document.getElementById("browserStartupHomepage");
|
|
|
|
homePageField.value = url;
|
|
|
|
}
|
|
|
|
}
|
2006-05-17 02:24:52 +00:00
|
|
|
}
|
2006-05-17 02:32:42 +00:00
|
|
|
|
|
|
|
function setHomePageToDefaultPage()
|
|
|
|
{
|
|
|
|
var prefService = Components.classes[PREFSERVICE_CONTRACTID]
|
|
|
|
.getService(nsIPrefService);
|
|
|
|
var pref = prefService.getDefaultBranch(null);
|
|
|
|
var url = pref.getComplexValue("browser.startup.homepage",
|
|
|
|
nsIPrefLocalizedString).data;
|
|
|
|
var homePageField = document.getElementById("browserStartupHomepage");
|
|
|
|
homePageField.value = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
|