home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 September / PCO_0998.ISO / browser / ns405lyc / netcast.z / ncjs10.jar / layout.js < prev    next >
Encoding:
JavaScript  |  1998-03-06  |  2.7 KB  |  93 lines

  1. /*
  2.  * layout.js
  3.  * 
  4.  * Copyright (c) 1997 Netscape Communications Corporation, All Rights Reserved
  5.  * 
  6.  * Functions that manage the options->layout preference panel
  7.  */
  8.  
  9. /*
  10.  * These methods initializes and populate the options dialog.  It loops through the data
  11.  * model storing pointers to the items, creating the pulldown menus for option and default
  12.  * webtop selection
  13.  */
  14. function fillDefaultList(theForm, category, selector) {
  15.   //return;
  16.     var channelArray = selector.parent.titlebar.document.demo.getData(category);
  17.     var curOption;
  18.     var channelArrayLength;
  19.     var chanPrefsName;
  20.     var defaultChannelName = depth.GetNetscapePref("netcaster.defaultChannel", "", false);
  21.     var defaultChannelIndex = -1;
  22.  
  23.     // prevent JavaScript from accessing a null item list
  24.  
  25.     if ( null == channelArray ) {
  26.         channelArrayLength = 0;
  27.  
  28.         for (i = 0; i < theForm.defaultChannel.length; i++) {
  29.             if (i==0) {
  30.                 theForm.defaultChannel.options[i].text = "(No channels)";
  31.                 defaultChannelIndex = -1;
  32.             } else {
  33.                 theForm.defaultChannel.options[i] = null;
  34.             }
  35.         }
  36.  
  37.     } else
  38.         channelArrayLength = channelArray.length;
  39.  
  40.     // Lets loop through all the items storing pointers
  41.  
  42.     for (i = 0; i < channelArrayLength; i++) 
  43.     {
  44.         chanPrefsName = channelArray[i].getPrefsName();
  45.         if ((defaultChannelName != "") && (chanPrefsName == defaultChannelName)) {
  46.             defaultChannelIndex = i;
  47.         }
  48.  
  49.         curOption = new Option(channelArray[i].getItemName());
  50.             curOption.prototype = channelArray[i];
  51.         theForm.defaultChannel.options[i] = curOption;
  52.     }
  53.  
  54.     if (defaultChannelIndex == -1) {
  55.         // nothing selected:
  56.         theForm.onDefault[0].checked = true;
  57.         theForm.defaultChannel.selectedIndex = 0;
  58.     } else {
  59.         theForm.onDefault[1].checked = true;
  60.         theForm.defaultChannel.selectedIndex = defaultChannelIndex;
  61.     }
  62. }
  63.  
  64. function loadValues()
  65. {
  66.     var drawerDock = depth.GetNetscapePref("netcaster.drawer.dock", "right", false);
  67.  
  68.     if (drawerDock == "left") {
  69.         document.layout_form.drawerPos.selectedIndex = 1; 
  70.     } else {
  71.         document.layout_form.drawerPos.selectedIndex = 0; 
  72.     }
  73.  
  74. /*    var webDock = depth.GetNetscapePref("netcaster.webtopDock", "left", false);
  75.     if (webDock == "right") {
  76.         document.layout_form.webtopPos.selectedIndex = 0; 
  77.     } else {
  78.         document.layout_form.webtopPos.selectedIndex = 1; 
  79.     }
  80. */
  81.     var drawerHide = depth.GetNetscapePref("netcaster.drawer.autoHide", "true", false);
  82.     if (drawerHide == "false") {
  83.         document.layout_form.autoHide.checked = false; 
  84.     } else {
  85.         document.layout_form.autoHide.checked = true; 
  86.     }
  87.  
  88.     fillDefaultList(document.layout_form, depth.getDefaultContainer(), opener);
  89.  
  90.     window.layoutLoaded = true;
  91. }
  92.  
  93. void(0);