home *** CD-ROM | disk | FTP | other *** search
/ ftp.swcp.com / ftp.swcp.com.zip / ftp.swcp.com / mac / mozilla-macos9-1.3.1.sea.bin / Mozilla1.3.1 / Chrome / comm.jar / content / communicator / pref / pref-search.js < prev    next >
Text File  |  2003-06-08  |  2KB  |  71 lines

  1. /*
  2.  * The contents of this file are subject to the Netscape Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/NPL/
  6.  *
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  *
  12.  * The Original Code is Mozilla Communicator client code, released
  13.  * March 31, 1998.
  14.  *
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation. Portions created by Netscape are
  17.  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  *
  20.  * Contributor(s):
  21.  *   Robert John Churchill <rjc@netscape.com>
  22.  *   Mark Olson <maolson@earthlink.net>
  23.  */
  24.  
  25.  
  26. function checkEngine()
  27. {
  28.   var engineList = document.getElementById("engineList");
  29.   var engineValue = engineList.label;
  30.   
  31.   //nothing is selected
  32.   if (!engineValue)
  33.   {
  34.  
  35.     try
  36.     {
  37.         var prefInt =   null; //Preferences Interface
  38.         var strDefaultSearchEngineName;
  39.  
  40.         prefInt     =   Components.classes["@mozilla.org/preferences;1"];
  41.         if (prefInt) 
  42.         {
  43.             prefInt = prefInt.getService(Components.interfaces.nsIPref);
  44.             strDefaultSearchEngineName = prefInt.getLocalizedUnicharPref("browser.search.defaultenginename");
  45.         }
  46.  
  47.         var engineListSelection = engineList.getElementsByAttribute( "label", strDefaultSearchEngineName );
  48.         var selectedItem = engineListSelection.length ? engineListSelection[0] : null;
  49.     
  50.         if (selectedItem)
  51.         {
  52.             //select a locale-dependent predefined search engine in absence of a user default
  53.             engineList.selectedItem = selectedItem;
  54.         }
  55.         else
  56.         {
  57.             //select the first listed search engine
  58.             engineList.selectedIndex = 1;
  59.         }
  60.     }
  61.  
  62.     catch(e)
  63.     {
  64.         //select the first listed search engine
  65.         engineList.selectedIndex = 1;
  66.     }
  67.  
  68.   }
  69. }
  70.  
  71.