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

  1. var container = "channel";
  2.  
  3.  
  4. function handleCancel() {
  5.     self.close();
  6. }
  7.  
  8. function handleOK(form) {
  9.     if ((form.url.value.length > 0) && (form.name.value.length > 0)) {
  10.  
  11.         var oldData = opener.document.demo.findItemByName(form.name.value);
  12.         if (oldData != null) {
  13.               if (!confirm(window.depth.getLocalString("A channel with the name ") + form.name.value + window.depth.getLocalString(" already exists.")))
  14.                 return;
  15.         }
  16.  
  17.         var newName = opener.document.demo.getEncodedName(form.name.value, container);
  18.         if (newName == null || newName == "") {
  19.             alert("An error occurred while saving the item");
  20.         }
  21.  
  22.         var prefName = "netcaster.channel." + newName;
  23.  
  24.         props = opener.document.demo.newDataItem(form.url.value);
  25.         props.setPrefsKey(prefName);
  26.         props.setItemName(form.name.value);
  27.  
  28.         opener.document.demo.addItem(props, container);
  29. //        opener.parent.selector.document.layers[eval(container)].fillMe();
  30.         self.close();
  31.     }
  32.     else 
  33.         alert(depth.getLocalString("Please enter a valid Name and URL."));
  34. }
  35.  
  36. function fillEdits() {
  37.     var tempName    = opener.gChannelURL;
  38.     var start        = tempName.lastIndexOf("/");
  39.     var end            = tempName.lastIndexOf("?");
  40.     var finalName;
  41.  
  42.     // after we've filled the item, for additions, make sure that we
  43.     // are allowed to add before going further.
  44.  
  45.     var containerObject = opener.document.demo.findContainerByName(container);
  46.  
  47.     if (containerObject != null) {
  48.         if (!containerObject.getCanAddItems()) {
  49.             alert(depth.getLocalString("addBlocked"));
  50.             self.close();
  51.             return;
  52.         }
  53.     }
  54.     
  55.     if ((start > 0) && (end > 0)) {
  56.         finalName = opener.document.demo.unEncodeName(tempName.substring(start+1, end));
  57.         window.document.forms['scheduler'].name.value = finalName;
  58.     }
  59.     else {
  60.         window.document.forms['scheduler'].name.value = opener.gChannelURL;
  61.     }
  62.     window.document.forms['scheduler'].url.value = opener.gChannelURL;
  63. }
  64. /*
  65. function PropertiesCallback(which) {
  66.     which.selector = opener;
  67.  
  68.     which.document.layers['general'].document.scheduler.index.value = -1;
  69.  
  70.     which.document.layers['general'].document.scheduler.name.value = document.scheduler.name.value;
  71.     which.document.layers['general'].document.scheduler.url.value = document.scheduler.url.value;
  72.  
  73.     self.close();
  74. }
  75. */
  76.  
  77. function handleLoad() {
  78.  
  79. /*
  80.     // on enter for the dialog, set the focus to the dialog
  81.     window.focus();
  82.     window.document.layers['general'].document.scheduler.name.focus();
  83. */
  84. }
  85.  
  86.  
  87. // These function can be called before onLoad
  88. function suppressFalse(e) {
  89.     return false;    
  90. }
  91. function suppressRight(e) {
  92.     if (e.which > 1)
  93.         return false;
  94.     return routeEvent(e);
  95. }
  96.  
  97. window.ondragdrop = suppressFalse;
  98. window.onmousedown = suppressRight;
  99. window.onerror = depth.SupressError;
  100. captureEvents(Event.MOUSEDOWN | Event.DRAGDROP | Event.ERROR);
  101.  
  102. void(0);