1999-08-10 02:48:56 +00:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*/
|
|
|
|
|
1999-06-08 20:57:54 +00:00
|
|
|
var prefwindow = null;
|
1999-06-04 23:28:56 +00:00
|
|
|
|
|
|
|
function StartUp(windowName)
|
|
|
|
{
|
|
|
|
dump("\nDoing " + windowName + " startup...\n");
|
1999-06-08 20:57:54 +00:00
|
|
|
dump("Looking up prefwindow object...\n");
|
1999-10-30 00:14:52 +00:00
|
|
|
|
1999-06-08 20:57:54 +00:00
|
|
|
if (prefwindow == null)
|
1999-06-04 23:28:56 +00:00
|
|
|
{
|
1999-06-08 20:57:54 +00:00
|
|
|
dump("Creating prefwindow object...\n");
|
1999-10-22 21:05:31 +00:00
|
|
|
prefwindow = Components.classes['component://netscape/prefwindow'].getService(Components.interfaces.nsIPrefWindow);
|
1999-06-04 23:28:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-06-08 20:57:54 +00:00
|
|
|
dump("prefwindow has already been created! Hurrah!\n");
|
1999-06-04 23:28:56 +00:00
|
|
|
}
|
1999-06-08 20:57:54 +00:00
|
|
|
if (prefwindow != null && windowName != "Top" && windowName != "Bottom")
|
1999-06-04 23:28:56 +00:00
|
|
|
{
|
1999-06-10 19:55:08 +00:00
|
|
|
prefwindow.panelLoaded(window);
|
1999-06-04 23:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
1999-08-10 02:48:56 +00:00
|
|
|
|
1999-10-30 00:14:52 +00:00
|
|
|
function OnLoadPref()
|
|
|
|
{
|
|
|
|
doSetOKCancel(handleOKButton, handleCancelButton);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleOKButton()
|
|
|
|
{
|
|
|
|
if ( prefwindow )
|
|
|
|
{
|
|
|
|
prefwindow.savePrefs();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleCancelButton()
|
|
|
|
{
|
|
|
|
if ( prefwindow )
|
|
|
|
{
|
|
|
|
prefwindow.cancelPrefs();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
1999-08-10 02:48:56 +00:00
|
|
|
|
1999-10-21 19:53:19 +00:00
|
|
|
//function to open and close the manual prefs
|
|
|
|
function openit() {
|
|
|
|
|
|
|
|
var manualProxy = document.getElementById('manual-proxy');
|
|
|
|
var formStyle = manualProxy.getAttribute('style');
|
|
|
|
if (!(formStyle == "display: block; "))
|
|
|
|
{
|
|
|
|
manualProxy.setAttribute("style", "display: block;");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
manualProxy.setAttribute("style", "display: none;");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:48:56 +00:00
|
|
|
function choose() {
|
|
|
|
var toolkit;
|
|
|
|
var browser;
|
|
|
|
/* Use existing browser "open" logic. */
|
|
|
|
browser.openWindow();
|
|
|
|
toolkit.CloseWindow( window );
|
|
|
|
}
|
1999-09-15 05:08:22 +00:00
|
|
|
|
|
|
|
function SetHomePageToCurrentPage()
|
|
|
|
{
|
|
|
|
dump("SetHomePageToCurrentPage() \n ");
|
|
|
|
var windowManager = Components.classes['component://netscape/rdf/datasource?name=window-mediator'].getService();
|
|
|
|
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
|
|
|
|
|
|
|
|
|
|
|
|
var topWindowOfType = windowManagerInterface.GetMostRecentWindow( "navigator:browser" );
|
|
|
|
if ( topWindowOfType )
|
|
|
|
{
|
|
|
|
var inputfield = document.getElementById("pref:string:browser.startup.homepage");
|
|
|
|
dump( "window found "+inputfield+"\n");
|
|
|
|
if ( inputfield )
|
|
|
|
{
|
|
|
|
dump("setting home page to "+topWindowOfType.content.location.href+"\n");
|
|
|
|
inputfield.value = topWindowOfType.content.location.href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dump(" No browser window. Should be disabling this button \n");
|
|
|
|
}
|
|
|
|
}
|
1999-09-18 01:17:32 +00:00
|
|
|
|
|
|
|
function createInstance( progid, iidName ) {
|
|
|
|
var iid = eval( "Components.interfaces." + iidName );
|
|
|
|
return Components.classes[ progid ].createInstance( iid );
|
|
|
|
}
|
|
|
|
|
|
|
|
function PrefNavSelectFile() {
|
|
|
|
// Get filespecwithui component.
|
|
|
|
var fileSpec = createInstance( "component://netscape/filespecwithui", "nsIFileSpecWithUI" );
|
|
|
|
try {
|
|
|
|
var url = fileSpec.chooseFile( "" );
|
|
|
|
var field = document.getElementById( "pref:string:browser.startup.homepage" );
|
1999-11-22 23:15:02 +00:00
|
|
|
field.setAttribute( "value", fileSpec.nativePath );
|
1999-09-18 01:17:32 +00:00
|
|
|
}
|
|
|
|
catch( exception ) {
|
|
|
|
// Just a cancel, probably.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function PrefCacheSelectFolder() {
|
|
|
|
// Get filespecwithui component.
|
|
|
|
var fileSpec = createInstance( "component://netscape/filespecwithui", "nsIFileSpecWithUI" );
|
|
|
|
try {
|
|
|
|
var url = fileSpec.chooseDirectory( "" );
|
|
|
|
var field = document.getElementById( "pref:string:browser.cache.directory" );
|
1999-11-22 23:15:02 +00:00
|
|
|
field.setAttribute( "value", fileSpec.nativePath );
|
1999-09-18 01:17:32 +00:00
|
|
|
}
|
|
|
|
catch( exception ) {
|
|
|
|
// Just a cancel, probably.
|
|
|
|
}
|
|
|
|
}
|
1999-09-20 10:28:52 +00:00
|
|
|
|
|
|
|
function OpenProxyManualDialog() {
|
|
|
|
var dialog = window.openDialog("chrome://pref/content/pref-proxy-manual.xul", "", "chrome", {});
|
|
|
|
}
|
1999-10-21 19:53:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//dialog function that is not being called yet
|
|
|
|
function onOK()
|
|
|
|
{
|
|
|
|
//dump("\nDoing " + windowName + " startup...\n");
|
|
|
|
dump("Looking up prefwindow object...\n");
|
|
|
|
if (prefwindow == null)
|
|
|
|
{
|
|
|
|
dump("Creating prefwindow object...\n");
|
|
|
|
prefwindow = Components.classes['component://netscape/prefwindow'].createInstance(Components.interfaces.nsIPrefWindow);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dump("prefwindow has already been created! Hurrah!\n");
|
|
|
|
}
|
|
|
|
if (prefwindow)
|
|
|
|
{
|
|
|
|
prefwindow.changePanel("chrome://prefs/content/pref-proxies.xul");
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
1999-10-30 00:14:52 +00:00
|
|
|
function startUpProxy()
|
|
|
|
{
|
1999-10-21 19:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function manualSelected() {
|
|
|
|
manualSelect = document.getElementById('pref:1:int:network.proxy.type');
|
|
|
|
manualProxy = document.getElementById('manual-proxy');
|
|
|
|
dump("\n" + manualSelect);
|
|
|
|
dump("\n" + manualSelect.checked);
|
|
|
|
if (manualSelect.checked)
|
|
|
|
manualProxy.setAttribute("style", "display: block");
|
|
|
|
|
1999-10-30 00:14:52 +00:00
|
|
|
}
|
|
|
|
|
1999-12-20 16:01:36 +00:00
|
|
|
function setColorWell(menu,otherId,setbackground)
|
|
|
|
{
|
|
|
|
// Find the colorWell and colorPicker in the hierarchy.
|
|
|
|
var colorWell = menu.firstChild.nextSibling;
|
|
|
|
var colorPicker = menu.firstChild.nextSibling.nextSibling.firstChild;
|
|
|
|
|
|
|
|
// Extract color from colorPicker and assign to colorWell.
|
|
|
|
var color = colorPicker.getAttribute('color');
|
|
|
|
setColorFromPicker(colorWell,color,otherId,setbackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setColorFromPicker(colorWell,color,otherId,setbackground)
|
|
|
|
{
|
|
|
|
if (colorWell) {
|
|
|
|
colorWell.style.backgroundColor = color;
|
|
|
|
}
|
|
|
|
if (otherId) {
|
|
|
|
otherElement=document.getElementById(otherId);
|
|
|
|
if (setbackground) {
|
|
|
|
var basestyle = otherElement.getAttribute('basestyle');
|
|
|
|
var newstyle = basestyle + "background-color:" + color + ";";
|
|
|
|
otherElement.setAttribute('style',newstyle);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
otherElement.style.color = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|