home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 April / VPR9804B.ISO / Netscape / NETCAST.Z / ncjs10.jar / titlebar.js < prev    next >
Text File  |  1997-09-03  |  13KB  |  510 lines

  1. //**************************************************************************************************
  2. //
  3. // Netcaster 1.0 Copyright (c) 1997 Netcape Communications Corp.
  4. // titlebar.js
  5. //
  6. //**************************************************************************************************
  7.  
  8. var gLayerName    = null;
  9. var gLayerNum     = 0;
  10. var theDesktopMgr = new WebtopManager();
  11. var gAddObject    = null;
  12. var gChannelURL    = null;
  13. var finishedLoading = 0;
  14. var preview_chan  = null;
  15. var default_chan  = null;
  16. //**************************************************************************************************
  17. // This method is called from the applet after it has finished loading.  This is done
  18. // to prevent JavaScript is selector.html from calling a null applet
  19. //**************************************************************************************************
  20.  
  21. function setDefaultChannel(item)
  22. {
  23.     default_chan = item;
  24. }
  25.  
  26. function setAppletReady()
  27. {
  28.     parent.genericcontrols.location = "gencon.htm";
  29.     parent.selectorTab.ShowSelector();
  30.     parent.selectorTab.removeSplash();
  31.  
  32.     parent.selectorTab.setVersion();
  33.  
  34.     setFinishedLoading(1);
  35.     parent.selector.finishLoading();
  36.  
  37.     compromisePrincipals();
  38.  
  39.     // launch the default channel
  40.     if (default_chan != null) {
  41.         OpenSiteData(default_chan, false);
  42.     }
  43. }
  44.  
  45. function setFinishedLoading(inVal)
  46. {
  47.     finishedLoading = inVal;
  48. }
  49.  
  50. function getFinishedLoading()
  51. {
  52.     return finishedLoading;
  53. }
  54.  
  55. //**************************************************************************************************
  56. // This is the shutdown method.  It calls into the applet requesting it
  57. // to clean up its resources, and save its state
  58. //**************************************************************************************************
  59.  
  60. function closeNetCast() 
  61. {
  62.     var canClose = document.demo.close();
  63.  
  64.     if (!canClose) {
  65.         return;
  66.     }
  67.  
  68.     if ((preview_chan != null) && (preview_chan.closed == false)) {
  69.         preview_chan.close();
  70.     }
  71.  
  72.     parent.selectorTab.closeNetCast();
  73. }
  74.  
  75.  
  76. //**************************************************************************************************
  77. // This method gets called if the Java applet throws a security exception
  78. // (usually due to Marimba issues).
  79. // FIXME: We should late-bind the Marimba startup so the user only gets a single exception
  80. //**************************************************************************************************
  81.  
  82. function handleSecurityException()
  83. {
  84.     alert(depth.getLocalString("Netcaster requires certain privileges in order to run. ") +
  85.           depth.getLocalString("In order to use Netscape Netcaster, you must grant privileges for netcasting programs. ") +
  86.           depth.getLocalString("To grant privileges and avoid this message in the future, check the \"Remember this decision ") +
  87.           depth.getLocalString("each time I start Communicator\" box before clicking Grant."));
  88.     closeNetCast();
  89. }
  90.  
  91.  
  92. function GetDesktopManager()
  93. {
  94.     return theDesktopMgr;
  95. }
  96.  
  97.  
  98. function SetDesktopManager()
  99. {
  100.     return theDesktopMgr;
  101. }
  102.  
  103. function GetSelector()
  104. {
  105.     return theSelector;
  106. }
  107.  
  108. function contextSetChannelStatus(layer, statusCode) {
  109.     // for pre-4.02 Communicators, we want to switch contexts first
  110.  
  111.     setTimeout(setChannelStatus, 10, layer, statusCode);
  112. }
  113.  
  114. function setChannelStatus(layer, statusCode) {
  115.     layer.channelSetStatus(statusCode);
  116.  
  117. }
  118.  
  119. function contextSetWebtopStatus(layer, statusCode) {
  120.     // for pre-4.02 Communicators, we want to switch contexts first
  121.     if(statusCode + "" == "true") {
  122.         setTimeout(setWebtopStatus, 10, layer, true);
  123.     }
  124.     else {
  125.         setTimeout(setWebtopStatus, 10, layer, false);
  126.     }
  127. }
  128.  
  129. function setWebtopStatus(layer, statusCode) {
  130.     layer.channelSetWebtopStatus(statusCode);
  131.  
  132. }
  133.  
  134. function animateGo(layer) {
  135.     layer.channelProgressAnimate();
  136.  
  137. }
  138.  
  139. function animatePercent(layer, percent) {
  140.     layer.channelProgressPercent(percent);
  141.  
  142. }
  143.  
  144. function animateStop(layer) {
  145.     layer.channelProgressStop();
  146.  
  147. }
  148.  
  149.  
  150. function animateStop(layer) {
  151.     layer.channelProgressStop();
  152.  
  153. }
  154.  
  155. function confirmQuit(busy, confirmation) {
  156.     return confirm("" + confirmation);
  157. }
  158.  
  159. /* Preference callbacks */
  160.  
  161. function getPrefOnline() 
  162. {
  163.     return depth.GetNetscapePrefBool("network.online", true, false);
  164. }
  165.  
  166. function getNavigatorPrefStr(prefKey) 
  167. {
  168.     return depth.GetNetscapePref(prefKey, null, false)
  169. }
  170.  
  171. function getNavigatorBatchPrefs(keys, values) 
  172. {
  173.     return depth.batchNetscapePrefs(keys, values, false, false);
  174. }
  175.  
  176. function setNavigatorPrefStr(prefKey, prefValue) 
  177. {
  178.     depth.SetNetscapePref(prefKey, prefValue)
  179. }
  180.  
  181. function setNavigatorBatchPrefs(keys, values) 
  182. {
  183.     return depth.batchNetscapePrefs(keys, values, false, true);
  184. }
  185.  
  186. function delNavigatorPref(prefKey) 
  187. {
  188.     netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite"); 
  189.     navigator.preference(prefKey, null);
  190.     navigator.savePreferences();
  191. }
  192.  
  193. function handleProperties(dataItem)
  194. {
  195.  
  196.     parent.selector.handleProperties(dataItem);
  197. }
  198.  
  199. function PropertiesCallback(propsWindow)
  200. {
  201.         var general = propsWindow.document.layers['general'].document.scheduler;
  202.         var cache   = propsWindow.document.layers['cache'].document.cache;
  203.         var display = propsWindow.document.layers['display'];
  204.  
  205.     propsWindow.selector  = parent;
  206.     propsWindow.container = depth.getDefaultContainer();
  207.  
  208.      general.index.value  = -1;
  209.     general.name.value   = gAddObject.name;
  210.     general.url.value    = gAddObject.url;
  211.     general.type.value   = gAddObject.type;
  212.     general.freq.value   = gAddObject.intervalTime;
  213.     general.interval.value = gAddObject.intervalTime;
  214.  
  215.     propsWindow.parseTimeForFrontend(propsWindow.document.layers['general'], general, gAddObject.absoluteTime);
  216.  
  217.     //REMIND stupid code -- FIX ME
  218.     if (gAddObject.type == "2")  // castanet
  219.     {
  220.         cache.depth.value        = 0;
  221.         cache.size.value         = " ";
  222.     }
  223.     else {
  224.         cache.depth.value        = gAddObject.depth;
  225.         cache.size.value         = Math.ceil(gAddObject.maxCacheSize / 1024);
  226.         if (gAddObject.crawlExtLinks) {
  227.             cache.external.value     = "1";
  228.         } else {
  229.             cache.external.value     = "0";
  230.         }
  231.     }
  232.  
  233.     var mode = gAddObject.mode;
  234.     switch (mode) {
  235.         case "webtop":
  236.             display.document.forms["winType"].mode[1].checked = true;
  237.              break;
  238.         case "full":
  239.             display.document.forms["winType"].mode[0].checked = true;
  240.             break;
  241.         case "window":
  242.             display.document.forms["winType"].mode[0].checked = true;
  243.             break;
  244.     }
  245.     display.ChangeThumbnail();
  246.  
  247. }
  248.  
  249. function OpenSite(fullscreen, siteURL, hide)
  250. {
  251.     netscape.security.PrivilegeManager.enablePrivilege("Netcaster"); 
  252.  
  253.     document.demo.openAllCaches();
  254.  
  255.     if (fullscreen) 
  256.     {
  257.         var channelWindow = depth.SecureWindowOpen(window, siteURL, 
  258.                 'channel', 
  259.                 "screenX=" +
  260.                 screen.availLeft + ",screenY=" +
  261.                 screen.availTop + ",outerWidth=" +
  262.                 screen.availWidth + ",outerHeight=" +
  263.                 screen.availHeight + ",titlebar=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,alwaysLowered=no,z-lock=no,resizable=no,dependent=no");
  264.  
  265.         channelWindow.focus();
  266.         channelWindow.opener = null;
  267.     }
  268.     else 
  269.     {
  270.         var winHeight = screen.availHeight - 50;
  271.         var channelWindow = depth.SecureWindowOpen(window, siteURL, 
  272.                 'channel', 
  273.                 'left=150,top=30,outerWidth=500,outerHeight=" + winHeight + ",titlebar=yes,toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,alwaysLowered=no,z-lock=no,resizable=yes,dependent=no');
  274.  
  275.         channelWindow.focus();
  276.         channelWindow.opener = null;
  277.  
  278.     }
  279.  
  280.     if (hide) {
  281.         AutoHide();
  282.     }
  283. }
  284.  
  285.  
  286. function OpenSiteData(siteData, hide)
  287. {
  288.  
  289.     var chanType = siteData.getType();
  290.     var chanMode = "" + siteData.getMode();
  291.     var chanURL = siteData.getURL();
  292.  
  293.     if (!siteData.opening())
  294.         return;
  295.     
  296.     if (chanType == 2) {
  297. //        document.demo.openCastanetURL(chanURL);
  298.         siteData.openCastanetURL(chanURL);
  299.     } else {
  300.         if (chanMode == "webtop") {
  301.             OpenWebtop(chanURL, siteData, hide);
  302.         } else if (chanMode == "full") {
  303.             OpenSite(true, chanURL, hide);
  304.         } else {
  305.             OpenSite(false, chanURL, hide);
  306.         }
  307.     }
  308. }
  309.  
  310. function OpenWebtop(siteURL, dataItem, hide)
  311. {
  312.     if (arguments.length < 3) {
  313.         hide = true;
  314.     }
  315.  
  316.     if (arguments.length < 2) {
  317.         dataItem = null;
  318.     }
  319.  
  320.  
  321.     if (theDesktopMgr) {
  322.         theDesktopMgr.setWebtop(siteURL);
  323.  
  324.         if (dataItem != null) {
  325.             theDesktopMgr.setWebtopItem(dataItem);
  326.         }
  327.         theDesktopMgr.startLogoStatusTimer(theDesktopMgr, false);
  328.     }
  329.     else if (depth.debug)
  330.         alert("theDesktopMgr is null");
  331.  
  332.     if (hide) {
  333.         AutoHide();
  334.     }
  335.  
  336. }
  337.  
  338. function AutoHide()
  339. {
  340.     var autoHide = depth.GetNetscapePref("netcaster.drawer.autoHide", "true", false)
  341.  
  342.     if (autoHide == "true") {
  343.         parent.selectorTab.HideSelector();
  344.     }
  345.  
  346. }
  347.  
  348. function ToggleWebtop()
  349. {
  350.     if (theDesktopMgr) 
  351.         theDesktopMgr.toggle();
  352.     else if (depth.debug)
  353.         alert(depth.getLocalString("theDeksktopMgr is null"));
  354.  
  355.     parent.opener.HideSelector();
  356. }
  357.  
  358.  
  359. function ToggleFront()
  360. {
  361.     if (theDesktopMgr) 
  362.         theDesktopMgr.toggleTop();
  363.     else if (depth.debug)
  364.         alert(depth.getLocalString("theDeksktopMgr is null"));
  365.  
  366.     parent.opener.HideSelector();
  367. }
  368.  
  369.  
  370. function AddChannel(chanObj)
  371. {
  372.     if (chanObj.type == "2") {
  373.         AddNewCastanetChannel(chanObj.url);
  374.         return;
  375.     }
  376.  
  377.     gAddObject=chanObj;
  378.     
  379.     var addWindow = depth.SecureWindowOpen(window, 'addc.htm', 
  380.                 'prefs', 
  381.                 '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');
  382.  
  383.     addWindow.depth = depth;
  384. }
  385.  
  386. function AddNewCastanetChannel(chanURL)
  387. {
  388.     gChannelURL=chanURL;
  389.     
  390.     var addWindow =    depth.SecureWindowOpen(window, 'quickAdd.htm', 
  391.                     'prefs', 
  392.                     'left=100,top=100,width=430,height=120,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');
  393.  
  394.     addWindow.depth = depth;
  395.  
  396. }
  397.  
  398. function AddInfoblock(ibObj)
  399. {
  400.     gChannelURL=ibObj;
  401.     
  402.     depth.SecureWindowOpen(window, 'quickAdd.htm', 
  403.                     'prefs', 
  404.                     'left=100,top=100,width=430,height=120,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');
  405. }
  406.  
  407.  
  408. /***************** Selector Initialization Routines *******************/
  409.  
  410. function createContainerLayer(dataItem)
  411. {
  412.     parent.selector.createCategoryLayer(dataItem);
  413. }
  414.  
  415. function createItemLayer(dataItem)
  416. {
  417. // for pre-4.02 Communicators, we want to switch contexts on adds
  418. //    parent.selector.contextCreateItemLayer(dataItem);
  419.  
  420.     parent.selector.createItemLayer(dataItem);
  421. }
  422.  
  423. function createPageLayer(dataItem, url)
  424. {
  425.     parent.selector.createPageLayer(dataItem, url);
  426. }
  427.  
  428. function deleteItemLayer(dataItem, layer)
  429. {
  430. // for pre-4.02 Communicators, we want to switch contexts on deletes
  431. //    parent.selector.contextDeleteItemLayer(dataItem, layer);
  432.  
  433.     parent.selector.deleteItemLayer(dataItem, layer);
  434. }
  435.  
  436. function refreshItemLayer(dataItem, layer)
  437. {
  438. // for pre-4.02 Communicators, we want to switch contexts on deletes
  439. //    parent.selector.contextRefreshItemLayer(dataItem, layer);
  440.  
  441.     parent.selector.refreshItemLayer(dataItem, layer);
  442. }
  443.  
  444. function containerIsReady(expectedSize, layer)
  445. {
  446. //    alert("Layer count is " + layer.container.itemCount + " expected is " + expectedSize);
  447.  
  448.     if (!layer.container || !layer.container.itemCount) {
  449.         return true;        // we seem to get into this state every so often
  450.     }
  451.         
  452.     if (expectedSize <= layer.container.itemCount)
  453.         return true;
  454.     else 
  455.         return false;
  456. }
  457.  
  458.  
  459. /* Deletion callbacks */
  460.  
  461. function confirmDelete(name, item) {
  462. //    FIXME: Need to int'l
  463. //  depth.getLocalString("Are you sure you want to delete this item?")
  464.  
  465.     return confirm("Are you sure you want to delete " + name + "?");
  466.     
  467. }
  468.  
  469. function cantDelete(name, item) {
  470.     var addTail = depth.getLocalString("deleteBlocked");
  471.     alert(name + addTail);
  472.     
  473.     return;
  474. }
  475.  
  476. function showError(error) {
  477.     parent.selector.showError(error);    
  478. }
  479.  
  480.  
  481. /*
  482.  * This method will launch a new window with the url for the Netcaster start up channel
  483.  */
  484. function showAnimation(url) {
  485.   var screenHeight = screen.availHeight - 30;
  486.  
  487.   finalURL = "file://" + url; 
  488.   preview_chan = window.open(finalURL,'NC_Preview','left='+screen.availLeft+',top='+screen.availTop+',titlebar=yes,scrollbars=no,width='+screen.availWidth+',height='+screenHeight+',hotkeys=no');
  489. }
  490.  
  491. function showSplashText(index) {
  492.     parent.selectorTab.setSplashText(index);
  493. }
  494.  
  495.  
  496.  
  497. function showExpiration() {
  498.     alert(depth.getLocalString("This pre-release copy of Netscape Netcaster has expired.\rTo obtain a more recent version, go to http://home.netscape.com/"));
  499.  
  500.     closeNetCast();
  501. }
  502.  
  503.  
  504. function whineExpiration(date) {
  505.     alert(depth.getLocalString("This is a pre-release copy of Netscape Netcaster that will expire at ") + date +
  506.         depth.getLocalString(".  To obtain a newer pre-release version or the latest full release of Netscape Netcaster (which will not expire), go to http://home.netscape.com/"));
  507. }
  508.  
  509. void(0);
  510.