home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Spanish 3 / ProOne-MultimediaSpanishIII-WinMac.bin / pc / winextra / Netscape / SETUP / WIN32 / NETCAST.Z / ncjs10.jar / prefpane.js < prev    next >
Text File  |  1997-10-20  |  5KB  |  215 lines

  1. /*
  2.  * prefpane.js
  3.  * 
  4.  * Copyright (c) 1997 Netscape Communications Corporation, All Rights Reserved
  5.  * 
  6.  * Preference panel utilities
  7.  */
  8.  
  9. var        defaultWebtop = 0;
  10. var        editing = 0;
  11. var        applet = null;
  12. var        propID;
  13. var        propContainer;
  14. var        propSelector;
  15. var        previouslySelected = 0;
  16. var        defaultContainer = null;
  17. var        siteList = null;
  18. var        channelArray = null;
  19. var        layoutLoaded = false;
  20.  
  21. function onLoad() {
  22.     siteList = document.layers['channelList'].document.web_form;
  23.     applet = opener.selectorWindow.titlebar.document.demo;
  24.     propSelector = opener;
  25.     fillOptionDialog(siteList, depth.getDefaultContainer(), applet);
  26. }
  27.  
  28.  
  29. /*
  30.  * These methods initializes and populate the options dialog.  It loops through the data
  31.  * model storing pointers to the items, creating the list of channels.
  32.  */
  33. function fillOptionDialog(form, category, applet) {
  34.     var curOption;
  35.     var channelArrayLength;
  36.  
  37.     channelArray = applet.getData(category);
  38.  
  39.     // prevent JavaScript from accessing a null item list
  40.     if ( null == channelArray ) {
  41.         channelArrayLength = 0;
  42.  
  43.         curOption = new Option("------------ none ------------");
  44.         form.sitelist.options[0] = curOption;
  45.  
  46.     } else
  47.         channelArrayLength = channelArray.length;
  48.  
  49.       // Lets loop through all the items storing pointers
  50.     for (i = 0; i < channelArrayLength; i++) 
  51.     {
  52.         // Fill in the channel selection box
  53.         curOption = new Option(channelArray[i].getItemName());
  54.         curOption.prototype = channelArray[i];
  55.         form.sitelist.options[i] = curOption;
  56.  
  57.     }
  58.  
  59.     if (previouslySelected < channelArrayLength) {
  60.         form.sitelist.selectedIndex = previouslySelected
  61.     } else {
  62.         // Mark the first channel as selected
  63.         form.sitelist.selectedIndex = 0;
  64.     }
  65.  
  66.     if (defaultContainer == null) {
  67.         var containerName = depth.getDefaultContainer();
  68.         defaultContainer = applet.findContainerByName(containerName);
  69.     }
  70.  
  71.     adjustButtons();
  72. }
  73.  
  74.  
  75. function PropertiesCallback(propsWindow)
  76. {
  77.     propsWindow.selector  = propSelector;
  78.     propsWindow.container = propContainer;
  79.  
  80.     if (editing == 1)
  81.         propsWindow.editItem(propID);
  82.  
  83.     propsWindow.callback = self;
  84.  
  85. }
  86.  
  87. function EditCallback()
  88. {
  89.   // Fix me, I should pass in a second arg, really I should
  90.     fillOptionDialog(siteList, propContainer, applet);
  91. }
  92.  
  93.  
  94. function adjustButtons() {
  95.     var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
  96.     var online = applet.isOnline();
  97.  
  98.     if (defaultContainer.getCanAddItems()) {
  99.         enableButton("new");
  100.     } else {
  101.         disableButton("new");
  102.     }
  103.  
  104.     if ((item!= null) && (item.isDeletable())) {
  105.         enableButton("delete");
  106.     } else {
  107.         disableButton("delete");
  108.     }
  109.  
  110.     if ((item!= null) && (item.getStatus() == 1)) {
  111.         document.layers['stopupdate'].visibility="inherit";
  112.         document.layers['update'].visibility="hide";
  113.     } else {
  114.         document.layers['stopupdate'].visibility="hide";
  115.         document.layers['update'].visibility="inherit";
  116.  
  117.         if (online) {
  118.             enableButton("update");
  119.         } else {
  120.             disableButton("update");
  121.         }
  122.     }
  123. }
  124.  
  125. function goDown(layer) {
  126.     layer.background.src ="images/i_btnbg.gif";
  127.     return false;
  128. }
  129.  
  130. function goUp(layer) {
  131.     layer.background.src ="images/o_btnbg.gif";
  132.     return false;
  133. }
  134.  
  135. function disableButton(buttonName) {
  136.     document.layers[buttonName+'_d'].visibility="inherit";
  137. }
  138.  
  139. function enableButton(buttonName) {
  140.     document.layers[buttonName+'_d'].visibility="hide";
  141. }
  142.  
  143. function handleAdd()
  144. {
  145.     editing = 0;
  146.  
  147.     var propWin = depth.SecureWindowOpen(window, 'addc.htm', 
  148.                 'prefs', 
  149.                 'left=150,top=200,width=427,height=247,titlebar=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,modal=yes,alwaysRaised=yes,z-lock=no,dependent=yes,hotkeys=no');
  150.  
  151.     propWin.depth = depth;
  152.     propContainer = depth.getDefaultContainer();
  153. }
  154.  
  155. function handleProperties()
  156. {
  157.     previouslySelected = siteList.sitelist.selectedIndex;
  158.     var item = siteList.sitelist.options[previouslySelected].prototype;
  159.  
  160.     if ( null != item ) 
  161.     {
  162.         editing = 1;
  163.         var propWin = depth.SecureWindowOpen (window, 'addc.htm', 
  164.                 'prefs', 
  165.                 'left=150,top=200,width=427,height=247,titlebar=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,modal=yes,alwaysRaised=yes,z-lock=no,dependent=yes,hotkeys=no');
  166.  
  167.         propID = item;
  168.         propWin.depth = depth;
  169.         propContainer = depth.getDefaultContainer();
  170.     }
  171.  
  172. }
  173.  
  174. function stopSelectedUpdate()
  175. {
  176.     var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
  177.  
  178.     if (null != item) {
  179.         item.cancelUpdate();
  180.     }
  181. }
  182.  
  183. function deleteSelected()
  184. {
  185.     var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
  186.  
  187.     if (null != item) {
  188.         item.deleteMe();
  189.  
  190.         siteList.sitelist.options.length -= 1;
  191.         fillOptionDialog(siteList, depth.getDefaultContainer(), applet);
  192.     }
  193. }
  194.  
  195. function startSelectedUpdate()
  196. {
  197.     var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
  198.  
  199.     if ( null != item ) {
  200.         item.update();
  201.     }
  202. }
  203.  
  204. function stopSelectedUpdate()
  205. {
  206.     var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
  207.  
  208.     if ( null != item ) {
  209.         item.cancelUpdate();
  210.     }
  211. }
  212.  
  213.  
  214. void(0);
  215.