home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mozil06.zip / bin / chrome / toolkit.jar / content / global / charsetDetectorsOverlay.js < prev    next >
Text File  |  2001-02-14  |  2KB  |  72 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public
  4.  * License Version 1.1 (the "License"); you may not use this file
  5.  * except in compliance with the License. You may obtain a copy of
  6.  * the License at http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the License is distributed on an "AS
  9.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10.  * implied. See the License for the specific language governing
  11.  * rights and limitations under the License.
  12.  *
  13.  * The Original Code is mozilla.org code.
  14.  *
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation.  Portions created by Netscape are
  17.  * Copyright (C) 1998 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  *
  20.  * Contributor(s): 
  21.  */
  22. function debug(str)
  23. {
  24.   dump( str );
  25. }
  26. function LoadDetectorsMenu()
  27.   {
  28.     debug("run LoadDetectorsMenu()\n");
  29.     var Registry = Components.classes['@mozilla.org/registry-viewer;1'].createInstance();
  30.     Registry = Registry.QueryInterface(Components.interfaces.nsIRegistryDataSource);
  31.  
  32.     Registry.openWellKnownRegistry(Registry.ApplicationComponentRegistry);
  33.  
  34.     Registry = Registry.QueryInterface(Components.interfaces.nsIRDFDataSource);
  35.  
  36.     var menu = document.getElementById('CharsetDetectorsMenu');
  37.     if (menu) {
  38.       menu.database.AddDataSource(Registry);
  39.       menu.setAttribute('ref', 'urn:mozilla-registry:key:/software/netscape/intl/charsetdetector');
  40.     }
  41.   }
  42. function SelectDetectors( event )
  43.   {
  44.    uri =  event.target.getAttribute("id");
  45.    debug(uri + "\n");
  46.    pref = Components.classes['@mozilla.org/preferences;1'];
  47.    prefvalue = uri.substring(
  48.                      'urn:mozilla-registry:key:/software/netscape/intl/charsetdetector/'.length
  49.                      ,uri.length);
  50.    if("off" == prefvalue) { // "off" is special value to turn off the detectors
  51.       prefvalue = "";
  52.    }
  53.    debug(prefvalue + "\n");
  54.  
  55.    // if all else fails, use trusty "about:blank" as the start page
  56.    if (pref) {
  57.         debug("get pref\n");
  58.         pref = pref.getService();
  59.         pref = pref.QueryInterface(Components.interfaces.nsIPref);
  60.    }
  61.  
  62.  
  63.    if (pref) {
  64.        debug("get pref 2\n");
  65.        pref.SetCharPref("intl.charset.detector", prefvalue);
  66.        window._content.location.reload();
  67.    }
  68.   }
  69.  
  70. /* this is really hacky, but waterson say it will work */
  71. setTimeout("LoadDetectorsMenu()", 10000);
  72.