home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 January / 01_02.iso / software / netscape62win / browser.xpi / bin / chrome / toolkit.jar / content / global / config.js < prev    next >
Encoding:
JavaScript  |  2001-09-01  |  4.6 KB  |  130 lines

  1. /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  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.  
  21. var arr = new Array();
  22.  
  23. var view = ({
  24.     rowCount : 0, 
  25.     getCellText : function(k, col) 
  26.         {    
  27.             if ( !arr[k] )
  28.                 return;
  29.             return arr[k][col];
  30.         },
  31.     getRowProperties : function(index, prop) {},
  32.     getCellProperties : function(index, col, prop) {},
  33.     getColumnProperties : function(col, elt, prop) {},
  34.     outlinerbox : null,
  35.     selection : null,
  36.     isContainer : function(index) { return false; },
  37.     isContainerOpen : function(index) { return false; },
  38.     isContainerEmpty : function(index) { return false; },
  39.     isSorted : function() { },
  40.     canDropOn : function(index) { return false; },
  41.     canDropBeforeAfter : function(index,before) { return false; },
  42.     drop : function(row,orientation) {},
  43.     setOutliner : function(out) { this.outlinerbox = out; },
  44.     getParentIndex: function(rowIndex) { return -1 },
  45.     hasNextSibling: function(rowIndex, afterIndex) { return false },
  46.     getLevel: function(index) { return 1},
  47.     toggleOpenState : function(index) {},
  48.     cycleHeader: function(colID, elt) {},
  49.     selectionChanged : function() {},
  50.     cycleCell: function(row, colID) {},
  51.     isEditable: function(row, valueCol) {return true},
  52.     isEditable: function(row, colID) {return false},
  53.     setCellText: function(row, colID, value) {},
  54.     performAction: function(action) {},
  55.     performActionOnRow: function(action, row) {},
  56.     performActionOnCell: function(action, row, colID) {},
  57. });
  58.  
  59. function onConfigLoad()
  60. {
  61.     var prefCount = {value:0};
  62.     var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  63.     var prefBranch = prefService.getBranch(null);
  64.     var prefArray = prefBranch.getChildList("" , prefCount);
  65.     var prefName, prefType, prefTypeName, prefValue, prefIndex, prefLockState;
  66.  
  67.     var i = 0;
  68.     var j = 0;   // This is used to avoid counting the "capability" preferences
  69.     var k = 0;     // This is to maintain a count of prefs (not including the "capability" prefs);
  70.  
  71.     prefArray.sort();
  72.     for (i = 0; i < prefCount.value; i++) 
  73.     {
  74.         if((prefArray[i].indexOf("capability", 0) + 1) > 0)    // avoid displaying "private" preferences
  75.         {
  76.             j++;
  77.             continue;
  78.         }
  79.  
  80.         k = (i - j);   // avoid numbering "capability" prefs
  81.  
  82.         prefIndex = k + 1;
  83.         prefLockState = "default";
  84.     
  85.         if(prefBranch.prefIsLocked(prefArray[i]))  // 0 = false
  86.             prefLockState = "locked";
  87.         else if(prefBranch.prefHasUserValue(prefArray[i]))    // 0 = false
  88.             prefLockState = "user set";
  89.  
  90.         prefType = prefBranch.getPrefType(prefArray[i]);
  91.         switch(prefType)
  92.         {
  93.             case 32:
  94.                 prefTypeName = "string";
  95.                 prefValue = prefBranch.getCharPref(prefArray[i]);
  96.                 prefValue = htmlEscape(prefValue);
  97.                 break;
  98.             case 64:
  99.                 prefTypeName = "int";
  100.                 prefValue = prefBranch.getIntPref(prefArray[i]);
  101.                 break;
  102.             case 128:
  103.                 prefTypeName = "bool";
  104.                 prefValue = prefBranch.getBoolPref(prefArray[i]);
  105.                 break;
  106.             default: 
  107.                 prefTypeName = "unknown";
  108.                 break;
  109.         }
  110.  
  111.         arr[k] = {indexCol:prefIndex, prefCol:prefArray[i], lockCol:prefLockState, typeCol:prefTypeName, valueCol:prefValue};
  112.     }
  113.   
  114.     view.rowCount = k + 1;
  115.  
  116.     var outliner = document.getElementById("out");
  117.     outliner.outlinerBoxObject.view = view;
  118.  
  119. }
  120.  
  121. function htmlEscape(s) 
  122.     s = s.replace(/\&/g, "&"); 
  123.     s = s.replace(/\>/g, ">"); 
  124.     s = s.replace(/\</g, "<"); 
  125.     return s; 
  126. }
  127.  
  128.  
  129.