home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / ProPlus.WW / ProPsWW2.cab / UTILITYFUNCTIONS.JS < prev    next >
Text File  |  2007-02-04  |  4KB  |  136 lines

  1. // ========================================================================
  2. // ===                       utilityfunctions.js                        ===
  3. // ========================================================================
  4.  
  5. // Global variable for the dispatch callback code.
  6. var g_objDispatch = getScriptDispatch(true);
  7.  
  8. // === grooveNavigate(url) ===================================
  9. // called by TextView to navigate to a url
  10. function grooveNavigate(i_URL)
  11. {
  12.     g_objDispatch.GrooveNavigate(i_URL);
  13. }
  14.  
  15. // === doCalendar(object) ====================================
  16. // called when button is clicked by user, creates the calendar
  17. function doCalendar(i_objClicked)
  18. {
  19.     try
  20.     {
  21.         // Get the INPUT object that the date value will be put into.
  22.         var objForm = i_objClicked.form;
  23.         var i = 0;
  24.         var iCount = objForm.elements.length;
  25.         while (i < iCount)
  26.         {
  27.             if (objForm.elements[i] == i_objClicked)
  28.                 objDate = objForm.elements[i - 1];
  29.             i++;
  30.         }
  31.  
  32.         // Clear any errors that the current date may have.
  33.         clearError(objDate.parentElement, "Required");
  34.         clearError(objDate.parentElement, "InvalidDate");
  35.         clearError(objDate.parentElement, "Date");
  36.  
  37.         // Get the date format string.
  38.         var intFormat = g_objDispatch.GrooveIntlDateFormatStyle_Short;
  39.         var strFormat = objDate.parentElement.getAttribute("FormatDateShortFormat");
  40.         if (strFormat == null || strFormat == "")
  41.         {
  42.             strFormat = objDate.parentElement.getAttribute("FormatDateLongFormat");
  43.             intFormat = g_objDispatch.GrooveIntlDateFormatStyle_Full;
  44.         }
  45.  
  46.         // Get the new date from the choose date sub-form.
  47.         var strDate = g_objDispatch.LoadChooseDateControl(objDate.value, strFormat, intFormat);
  48.         objDate.value = strDate;
  49.  
  50.         // Format the date to make sure it is in the proper format.
  51.         formatDate(objDate);
  52.  
  53.         // Call onblur to validate the date.
  54.         if (objDate.onblur != null)
  55.             objDate.onblur();
  56.     }
  57.     catch (error)
  58.     {
  59.         var objError = new Error("There was an error saving the date value, most likely caused by the form reloading in response to a design change. Please try choosing the date again.");
  60.         g_objDispatch.DisplayError(objError);
  61.     }
  62. }
  63.  
  64. // === doAddAttachments(object) ==============================
  65. // add attachments into the groove object for the current form
  66. function doAddAttachments(i_objClicked)
  67. {
  68.     try
  69.     {
  70.         var objForm = i_objClicked.form;
  71.         var DocumentShareView;
  72.  
  73.         var i = 0;
  74.         var iCount = objForm.elements.length;
  75.         while (i < iCount)
  76.         {
  77.             if (objForm.elements[i].getAttribute("DataType") == "Attachments")
  78.             {
  79.                 DocumentShareView = objForm.elements[i];
  80.                 break;
  81.             }
  82.             i++;
  83.         }
  84.  
  85.         if (typeof DocumentShareView != "undefined")
  86.         {
  87.             if (g_AttachmentsElement != null)
  88.                 g_objDispatch.AddAttachments(DocumentShareView, g_AttachmentsElement);
  89.         }
  90.     }
  91.     catch (error)
  92.     {
  93.         var objError = new Error("There was an error adding the attachment, most likely caused by the form reloading in response to a design change. Please try adding the attachment again.");
  94.         g_objDispatch.DisplayError(objError);
  95.     }
  96. }
  97.  
  98. // === doDeleteSelectedAttachments(object) ===============================
  99. // delete selected attachments from the groove object for the current form
  100. function doDeleteSelectedAttachments(i_objClicked)
  101. {
  102.     var objForm = i_objClicked.form;
  103.     var DocumentShareView;
  104.  
  105.     var i = 0;
  106.     var iCount = objForm.elements.length;
  107.     while (i < iCount)
  108.     {
  109.         if (objForm.elements[i].getAttribute("DataType") == "Attachments")
  110.         {
  111.             DocumentShareView = objForm.elements[i];
  112.             break;
  113.         }
  114.         i++;
  115.     }
  116.  
  117.     if (typeof DocumentShareView != "undefined")
  118.         g_objDispatch.DeleteAttachments(DocumentShareView);
  119. }
  120.  
  121. // === getScriptDispatch() ===============================
  122. // safely get the script dispatch from the forms glue code
  123. function getScriptDispatch(i_HideAlert)
  124. {
  125.     try
  126.     {
  127.         var objDispatch = window.external.Delegate.GetScriptDispatch();
  128.         return objDispatch;
  129.     }
  130.     catch (error)
  131.     {
  132.         if (typeof i_HideAlert == "undefined" || !i_HideAlert)
  133.             alert("This web page should only be opened from within Groove. Please close the window.");
  134.         return null;
  135.     }
  136. }