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

  1. // Global variable decalarations for page objects.
  2. var g_objDispatch = getScriptDispatch();
  3. var g_BasePath = g_objDispatch.GetBasePath();
  4. var g_objDataList = null;
  5. var g_AllowCreate = null;
  6. var g_AllowEdit = null;
  7. var g_AllowDelete = null;
  8. // Global variable used in enabledatalist call.
  9. var g_CalledInitialized = false;
  10. var g_DataListInitialized = false;
  11. // Global variables to keep the current and previous record info.
  12. var g_CurrentRecordID = null;
  13. var g_CurrentFormURL = null;
  14. var g_PreviousRecordID = null;
  15. var g_PreviousFormURL = null;
  16. // Global variables to be used for button image hovering.
  17. var g_imgButtonLeft = null;
  18. var g_imgButtonMid = null;
  19. var g_imgButtonRight = null;
  20. var g_imgButtonLeftOver = null;
  21. var g_imgButtonMidOver = null;
  22. var g_imgButtonRightOver = null;
  23. var g_TimeoutIncrement = 1;
  24.  
  25. // Include the stylesheet code as it was broken with the IE security patch.
  26. document.write("<STYLE TYPE=\"text/css\">");
  27. document.write("BODY, TD, DIV, A, SELECT { font-family:arial,verdana,sans-serif; font-size:11px; color:rgb(0,0,0); }");
  28. document.write("BODY { margin:4px 8px 8px 8px; background-color:rgb(134,152,175); }");
  29. document.write("INPUT { width:75px; }");
  30. document.write(".button, .button TD { font-family:tahoma,sans-serif; color:rgb(255,255,255); cursor:default; }");
  31. document.write(".heading { font-family:tahoma,sans-serif; font-size:18px; font-weight:bold; color:rgb(10,53,108); }");
  32. document.write("#divViewNavBase { height:28px; }");
  33. document.write("#divSearchCount, #divViewCount { font-family:tahoma,sans-serif; font-style:italic; color:rgb(255,255,255); }");
  34. document.write("</STYLE>");
  35.  
  36. // Capture keydown and contextmenu events for the document.
  37. document.onkeydown = keyDownEvent;
  38. document.oncontextmenu = contextMenuEvent;
  39.  
  40. // === keyDownEvent() ==============
  41. // event handler for key down action
  42. function keyDownEvent()
  43. {
  44.     // Capture Backspace, Ctrl+N, and Ctrl+P keystrokes to disable them.
  45.     if (event.ctrlKey && (event.keyCode == 78 || event.keyCode == 80))
  46.         event.returnValue = false;
  47. }
  48.  
  49. // === contextMenuEvent() ==============
  50. // event handler for context menu action
  51. function contextMenuEvent()
  52. {
  53.     // Right-click context menu will only appear if 'Ctrl' key is held down.
  54.     if (!event.ctrlKey)
  55.         event.returnValue = false;
  56. }
  57.  
  58. // === initDataList(bool) ======================
  59. // data view initialization, sets up event sinks
  60. function initDataList(i_blnHideButtons)
  61. {
  62.     if (g_objDispatch == null)
  63.         return false;
  64.  
  65.     // Set forms glue global variable for command bar.
  66.     g_objDispatch.SetOnFormPage(false);
  67.  
  68.     // Pass out document to be used by glue code.
  69.     g_objDispatch.SetCurrentDocument(document);
  70.  
  71.     // Find the data view object in the page.
  72.     var arrObject = document.getElementsByTagName("OBJECT");
  73.     if (arrObject.length > 0)
  74.         g_objDataList = arrObject[0];
  75.     
  76.     if (g_objDataList)
  77.     {
  78.         // Set up the event sinks for the data view object.
  79.         document.getElementById("ViewDblClickScript").htmlFor = g_objDataList.name;
  80.         document.getElementById("ViewSelectionChangedScript").htmlFor = g_objDataList.name;
  81.     }
  82.  
  83.     if (g_objDataList)
  84.     {
  85.         g_CalledInitialized = false;
  86.         try
  87.         {
  88.             if (!g_objDataList.IGrooveDataListDisplay.Initialized)
  89.             {
  90.                 window.setTimeout("enableDataList()", 10);
  91.             }
  92.             else
  93.             {
  94.                 enableDataList();
  95.             }
  96.         }
  97.         catch (error)
  98.         {
  99.             g_objDispatch.ActiveXMessageBox();
  100.         }
  101.     }
  102.  
  103.     if (i_blnHideButtons)
  104.     {
  105.         // Hide the view buttons if they should not be displayed.
  106.         var objDivViewNavBase = document.getElementById("divViewNavBase");
  107.         objDivViewNavBase.style.display = "none";
  108.     }
  109.     else
  110.     {
  111.         // Set-up the buttons to be displayed on the view.
  112.         setupViewButtons();
  113.         // Make the buttons disabled by default, they will be re-enabled when a record is selected.
  114.         canEditOrDelete(-1);
  115.     }
  116. }
  117.  
  118.  
  119. // === enableDataList() ===========================================
  120. // make sure a record is selected when the data list is initialized
  121. function enableDataList()
  122. {
  123.     try
  124.     {
  125.         if (g_objDataList.IGrooveDataListDisplay.Initialized)
  126.         {
  127.             g_DataListInitialized = true;
  128.             var intFocusRowID = g_objDataList.IGrooveDataListDisplay.FocusRow;
  129.             var intCurrentRowID = g_objDispatch.GetSelectedRecordID();
  130.  
  131.             if (intCurrentRowID == null || intCurrentRowID == -1 || intFocusRowID == intCurrentRowID)
  132.             {
  133.                 goPreview(intFocusRowID);
  134.                 goSetSelectedRecordID(intFocusRowID);
  135.             }
  136.             else
  137.             {
  138.                 g_objDataList.IGrooveDataListDisplay.SetFocusRow(intCurrentRowID);
  139.             }
  140.  
  141.             g_objDispatch.ShowUICommands(true);
  142.             g_objDispatch.ShowMenuCommands();
  143.         }
  144.         else
  145.         {
  146.             if (!g_CalledInitialized)
  147.             {
  148.                 g_objDispatch.InitializeRunTimeSettings(true);
  149.                 g_CalledInitialized = true;
  150.             }
  151.             window.setTimeout("enableDataList()", 10);
  152.         }
  153.         
  154.     }
  155.     catch (error)
  156.     {
  157.         window.setTimeout("enableDataList()", 10)
  158.     }
  159. }
  160.  
  161. // === goEdit() ======================================================
  162. // open the selected record in the form it was created in for updating
  163. function goEdit()
  164. {
  165.     if (g_CurrentRecordID >= 0 && g_AllowEdit)
  166.     {
  167.         var FormUrl = g_CurrentFormURL + "?RecordID=" + g_CurrentRecordID;
  168.         if (FormUrl != "")
  169.         {
  170.             g_objDispatch.WebBrowserViewNavigate(FormUrl);
  171.             g_objDispatch.HideUICommands();
  172.         }
  173.     }
  174. }
  175.  
  176. // === goOpen(integer) =============================
  177. // open the record for the passed in id for updating
  178. function goOpen(i_RowID)
  179. {
  180.     if (typeof i_RowID == "undefined" || i_RowID == null)
  181.     {
  182.         if (g_CurrentRecordID > 0)
  183.             i_RowID = g_CurrentRecordID;
  184.         else
  185.             return;
  186.     }
  187.  
  188.     var FormUrl = g_objDispatch.GetFormUrlByRecordID(i_RowID);
  189.     if (g_objDispatch.CanEdit(i_RowID))
  190.         g_objDispatch.WebBrowserViewNavigate(FormUrl + "?RecordID=" + i_RowID);
  191.     else 
  192.         g_objDispatch.WebBrowserViewNavigate(FormUrl + "?RecordID=" + i_RowID + "&noedit=true");
  193.  
  194.     g_objDispatch.HideUICommands();
  195. }
  196.  
  197. // === goDelete() =======================================
  198. // delete the selected record and clear the preview frame
  199. function goDelete()
  200. {
  201.     try
  202.     {
  203.         if (g_CurrentRecordID >= 0 && g_AllowDelete)
  204.         {
  205.             if (g_objDispatch.YesNoMessageBox("This operation cannot be undone. Are you sure you want to delete the selected record?", "Delete Record"))
  206.             {
  207.                 g_objDispatch.DeleteRecord(g_CurrentRecordID);
  208.                 resetPreviewPane();
  209.                 if (g_objDispatch.GetRecordCount() <= 0)
  210.                 {
  211.                     doButtonDisable("EditButton");
  212.                     doButtonDisable("DeleteButton");
  213.                 }
  214.             }
  215.         }
  216.         if(g_objDataList)
  217.             g_objDataList.focus();
  218.     }
  219.     catch(error)
  220.     {
  221.     }
  222. }
  223.  
  224. // === goSearch() ============================
  225. // perform a search of the data using any form
  226. function goSearch()
  227. {
  228.     g_objDispatch.LoadFormSearchControl();
  229. }
  230.  
  231. // === goClear() ==============
  232. // clear the search result data
  233. function goClear()
  234. {
  235.     g_objDispatch.ClearSearchResults();
  236. }
  237.  
  238. // === goPreview(integer) =========================
  239. // preview the selected record in the preview frame
  240. function goPreview(i_RowID)
  241. {
  242.     var RecordID = i_RowID;
  243.     if (RecordID != null && RecordID != -1)
  244.     {
  245.         g_PreviousRecordID = RecordID;
  246.  
  247.         g_PreviousFormURL = g_CurrentFormURL;
  248.         g_CurrentFormURL = g_objDispatch.GetFormUrlByRecordID(RecordID);
  249.  
  250.         if (g_PreviousFormURL == g_CurrentFormURL && g_PreviousFormURL != null)
  251.         {
  252.             var PreviewValid = g_objDispatch.DisplayPreviewForRecordID(RecordID)
  253.             // If we get a 'Permission Denied' error, timeout then try again.
  254.             if (PreviewValid == -2146828218)
  255.             {
  256.                 if ((50 * (2 * g_TimeoutIncrement)) >= 2000)
  257.                 {
  258.                     g_objDispatch.OKMessageBox("Groove was unable to properly update the preview pane due to an error, but will refresh the Forms tool when you close this message. This should resolve the problem.", "Alert");
  259.                     g_objDispatch.LoadHomePage();
  260.                     return;
  261.                 }
  262.                 else
  263.                 {
  264.                     g_objDispatch.GrooveDebugFunctions.OutputString("\n Received Permission denied error - current backoff is: " + 50 * (2 * g_TimeoutIncrement) + "\n\n");
  265.                     window.setTimeout("goPreview(" + i_RowID + ")", 50 * (2 * g_TimeoutIncrement++));
  266.                     return;
  267.                 }
  268.             }
  269.             else if (PreviewValid == -1)
  270.             {
  271.                 g_TimeoutIncrement = 1;
  272.                 g_objDispatch.WebBrowserViewNavigatePreview(g_CurrentFormURL + "?RecordID=" + RecordID + "&preview=true");
  273.             }
  274.         }
  275.         else if (g_CurrentFormURL != null && g_CurrentFormURL != "")
  276.         {
  277.             g_TimeoutIncrement = 1;
  278.             g_objDispatch.WebBrowserViewNavigatePreview(g_CurrentFormURL + "?RecordID=" + RecordID + "&preview=true")
  279.         }
  280.         else
  281.             resetPreviewPane();
  282.     }
  283.     else
  284.         resetPreviewPane();
  285. }
  286.  
  287. // === goSetSelectedRecordID(integer) =========
  288. // sets the selected record id in the glue code
  289. function goSetSelectedRecordID(i_RowID)
  290. {
  291.     var RecordID = i_RowID;
  292.     if (RecordID != null)
  293.     {
  294.         g_CurrentRecordID = RecordID;
  295.         g_objDispatch.SetSelectedRecordID(RecordID);
  296.         if (RecordID != -1)
  297.             g_objDataList.IGrooveDataListDisplay.ScrollToRow(RecordID);
  298.  
  299.         // Enable or disable buttons depending on permissions.
  300.         canEditOrDelete(RecordID);
  301.     }
  302. }
  303.  
  304. // === goSearchComplete() ==================
  305. // called when a record search has completed
  306. function goSearchComplete()
  307. {
  308.     var intDataListCount = g_objDispatch.GetDataListCollectionCount();
  309.  
  310.     if (intDataListCount != null)
  311.     {
  312.         if (intDataListCount == 0)
  313.         {
  314.             resetPreviewPane();
  315.             window.setTimeout("g_objDispatch.OKMessageBox('Search is complete. There are no results to display.', 'Search Complete')", 500);
  316.         }
  317.  
  318.         displaySearchCount();
  319.     }
  320. }
  321.  
  322. // === displaySearchCount() ====================================
  323. // display the number of records in the data list after a search
  324. function displaySearchCount()
  325. {
  326.     var intDataListCount = g_objDispatch.GetDataListCollectionCount();
  327.     var intToolCount = g_objDispatch.GetToolCollectionCount();
  328.  
  329.     if (intDataListCount != null && intToolCount != null)
  330.     {
  331.         var strCount = intDataListCount + " of " + intToolCount + " records in view";
  332.         if (intToolCount == 1)
  333.             strCount = intDataListCount + " of " + intToolCount + " record in view";
  334.  
  335.         var objDivSearchCount = document.getElementById("divSearchCount");
  336.         if (objDivSearchCount != null)
  337.             objDivSearchCount.innerHTML = strCount;
  338.     }
  339. }
  340.  
  341. // === displayViewCount() =======================
  342. // display the number of records in the data list
  343. function displayViewCount()
  344. {
  345.     var intToolCount = g_objDispatch.GetToolCollectionCount();
  346.  
  347.     if (intToolCount != null)
  348.     {
  349.         var strCount = intToolCount + " records in view";
  350.         if (intToolCount == 1)
  351.             strCount = intToolCount + " record in view";
  352.  
  353.         var objDivViewCount = document.getElementById("divViewCount");
  354.         if (objDivViewCount != null)
  355.             objDivViewCount.innerHTML = strCount;
  356.     }
  357. }
  358.  
  359. // === canEditOrDelete(integer) =====================
  360. // enable or disable buttons depending on permissions
  361. function canEditOrDelete(i_RecordID)
  362. {
  363.     if (typeof i_RecordID == "undefined" || i_RecordID == null)
  364.     {
  365.         i_RecordID = g_objDataList.IGrooveDataListDisplay.FocusRow;
  366.         if (typeof i_RecordID == "undefined" || i_RecordID == null)
  367.             i_RecordID = -1;
  368.     }
  369.  
  370.     g_AllowCreate = g_objDispatch.CanCreate();
  371.     g_AllowEdit = g_objDispatch.CanEdit(i_RecordID);
  372.     g_AllowDelete = g_objDispatch.CanDelete(i_RecordID);
  373.  
  374.     if (g_AllowEdit)
  375.         doButtonOut("EditButton");
  376.     else
  377.         doButtonDisable("EditButton");
  378.  
  379.     if (g_AllowDelete)
  380.         doButtonOut("DeleteButton");
  381.     else
  382.         doButtonDisable("DeleteButton");
  383. }
  384.  
  385. // === resetPreviewPane() ====================
  386. // clear the preview pane and global variables
  387. function resetPreviewPane()
  388. {
  389.     g_objDispatch.WebBrowserViewNavigatePreview(g_BasePath + "FormsBlankPage.html");
  390.     g_CurrentRecordID = -1;
  391.     g_PreviousRecordID = -1;
  392.     g_CurrentFormURL = null;
  393.     g_PreviousFormURL = null;
  394.     g_TimeoutIncrement = 1;
  395. }
  396.  
  397. // === addDocument() =================================
  398. // add the current document to the HTMLComponentBridge
  399. function addDocument()
  400. {
  401.     g_objDispatch.AddHTMLDocument(document);
  402.     /*if (!g_objDataList.IGrooveDataListDisplay.Initialized)
  403.     {
  404.         g_objDispatch.SetupBridge();
  405.         window.setTimeout("initDataList()", 10);
  406.     }
  407.     */
  408. }
  409.  
  410. // === removeDocument() ===================================
  411. // remove the current document from the HTMLComponentBridge
  412. function removeDocument()
  413. {
  414.     g_objDispatch.RemoveHTMLDocument(document);
  415. }
  416.  
  417. // === enableUICommands() ==============
  418. // enable the buttons in the command bar
  419. function enableUICommands()
  420. {
  421.     g_objDispatch.SetUICommandEnabled("GUIC_FormsTool_Search", true);
  422.     g_objDispatch.SetUICommandContainerEnabled("GUIC_FormsTool_FormMenu", true);
  423.     g_objDispatch.SetUICommandContainerEnabled("GUIC_FormsTool_ViewMenu", true);
  424. }
  425.  
  426. // === getButton(string, string, string, string) =====
  427. // creates an html button from the passed in variables
  428. function getButton(i_Name, i_Label, i_Tooltip, i_OnMouseUp)
  429. {
  430.     var strButton = "<div id=\"" + i_Name + "\" title=\"" + i_Tooltip + "\" class=\"button\" onmouseup=\"" + i_OnMouseUp + "\" onmouseover=\"doButtonOver('" + i_Name + "')\" onmouseout=\"doButtonOut('" + i_Name + "')\">";
  431.     strButton += "    <table cellpadding=0 cellspacing=0 border=0 width=\"100%\">";
  432.     strButton += "    <tr>";
  433.     strButton += "        <td width=11 height=22><img src=\"" + g_BasePath + "button_left.gif\" width=11 height=22 id=\"" + i_Name + "Left\"></td>";
  434.     strButton += "        <td height=22 background=\"" + g_BasePath + "button_mid.gif\" align=\"center\" nowrap id=\"" + i_Name + "Mid\" unselectable=\"on\">" + i_Label + "</td>";
  435.     strButton += "        <td width=11 height=22><img src=\"" + g_BasePath + "button_right.gif\" width=11 height=22 id=\"" + i_Name + "Right\"></td>";
  436.     strButton += "    </tr>";
  437.     strButton += "</table>";
  438.     strButton += "</div>";
  439.     return strButton;
  440. }
  441.  
  442. // === doButtonOver(string) =======================
  443. // highlight button images when user mouses over it
  444. function doButtonOver(i_Name)
  445. {
  446.     if ((i_Name == "DeleteButton" && !g_AllowDelete) || (i_Name == "EditButton" && !g_AllowEdit) || ((i_Name == "DeleteButton" || i_Name == "EditButton") && g_objDispatch.GetRecordCount() <= 0))
  447.         return;
  448.     changeButtonImages(i_Name, g_imgButtonLeftOver.src, g_imgButtonMidOver.src, g_imgButtonRightOver.src);
  449. }
  450.  
  451. // === doButtonOut(string) ==============================
  452. // reset the button images when the user mouses out of it
  453. function doButtonOut(i_Name)
  454. {
  455.     if (i_Name == "EditButton" && g_objDispatch.GetRecordCount() <= 0)
  456.         doButtonDisable("EditButton");
  457.     else if (i_Name == "DeleteButton" && g_objDispatch.GetRecordCount() <= 0)
  458.         doButtonDisable("DeleteButton");
  459.     else if (i_Name == "EditButton" && g_AllowEdit)
  460.         changeButtonImages(i_Name, g_imgButtonLeft.src, g_imgButtonMid.src, g_imgButtonRight.src);
  461.     else if (i_Name == "EditButton" && g_AllowEdit!= null && g_AllowEdit== false)
  462.         doButtonDisable("EditButton");
  463.     else if (i_Name == "DeleteButton" && g_AllowDelete)
  464.         changeButtonImages(i_Name, g_imgButtonLeft.src, g_imgButtonMid.src, g_imgButtonRight.src);
  465.     else if (i_Name == "DeleteButton" && g_AllowDelete != null && g_AllowDelete == false)
  466.         doButtonDisable("DeleteButton");
  467.     else
  468.         changeButtonImages(i_Name, g_imgButtonLeft.src, g_imgButtonMid.src, g_imgButtonRight.src);
  469. }
  470.  
  471. // === doButtonDisable(string) =====================================
  472. // disable the button images when it shouldn't be able to be clicked
  473. function doButtonDisable(i_Name)
  474. {
  475.     changeButtonImages(i_Name, g_imgButtonLeftDisable.src, g_imgButtonMidDisable.src, g_imgButtonRightDisable.src);
  476. }
  477.  
  478. // === setupViewButtons() ======================
  479. // pre-load the images for the button mouseovers
  480. function setupViewButtons()
  481. {
  482.     // Pre-load the images for the button mouseovers.
  483.     g_imgButtonLeft = new Image(11, 22);
  484.     g_imgButtonLeft.src = g_BasePath + "button_left.gif";
  485.     g_imgButtonMid = new Image(11, 22);
  486.     g_imgButtonMid.src = g_BasePath + "button_mid.gif";
  487.     g_imgButtonRight = new Image(11, 22);
  488.     g_imgButtonRight.src = g_BasePath + "button_right.gif";
  489.     g_imgButtonLeftOver = new Image(11, 22);
  490.     g_imgButtonLeftOver.src = g_BasePath + "button_left_over.gif";
  491.     g_imgButtonMidOver = new Image(11, 22);
  492.     g_imgButtonMidOver.src = g_BasePath + "button_mid_over.gif";
  493.     g_imgButtonRightOver = new Image(11, 22);
  494.     g_imgButtonRightOver.src = g_BasePath + "button_right_over.gif";
  495.     g_imgButtonLeftDisable = new Image(11, 22);
  496.     g_imgButtonLeftDisable.src = g_BasePath + "button_left_disable.gif";
  497.     g_imgButtonMidDisable = new Image(11, 22);
  498.     g_imgButtonMidDisable.src = g_BasePath + "button_mid_disable.gif";
  499.     g_imgButtonRightDisable = new Image(11, 22);
  500.     g_imgButtonRightDisable.src = g_BasePath + "button_right_disable.gif";
  501.  
  502.     // Get the current view name to preset in the default button set.
  503.     var ViewName = g_objDispatch.GetCurrentWebView();
  504.  
  505.     // Edit and delete buttons that are common to both search and default headings.
  506.     var EditDeleteButtons = "<td width=72>" + getButton("EditButton", "Edit...", "Edit currently selected record.", "goEdit()") + "</td><td width=72>" + getButton("DeleteButton", "Delete", "Delete currently selected record", "goDelete()") + "</td>";
  507.  
  508.     // Create the default and search result button sets.
  509.     var DefaultButtons = "<table width=\"100%\"><tr>" + EditDeleteButtons + "<td width=10> </td><td width=106>" + getButton("ImportExportButton", "Import/Export  <img src=\"" + g_BasePath + "menu_arrow.gif\" width=7 height=7 align=absmiddle>", "Import or export data currently displayed in the view", "createImportExportMenu(ImportExportButton)") + "</td><td width=10> </td><td><div id=\"divViewCount\"></div></td><td align=right class=\"heading\"><img src=\"" + g_BasePath + "viewby.gif\" width=24 height=24 align=absmiddle>  " + ViewName + "</td></tr></table>";
  510.     var SearchButtons = "<table width=\"100%\"><tr>" + EditDeleteButtons + "<td width=10> </td><td><div id=\"divSearchCount\"></div></td><td align=right class=\"heading\"><img src=\"" + g_BasePath + "search.gif\" width=24 height=24 align=absmiddle>  Search Results</td><td width=10> </td><td width=144>" + getButton("ClearButton", "Clear Search Results", "Clear the search results from the view", "goClear()") + "</td></tr></table>";
  511.  
  512.     // Pass button HTML string to glue code, which will determine what to display.
  513.     g_objDispatch.SetButtonsHTML(DefaultButtons, SearchButtons);
  514.     g_objDispatch.DisplayViewNavButtons();
  515. }
  516.  
  517. // === changeButtonImages(string, string, string, string) ====================
  518. // change the look of a button with the passed in name by replacing the images
  519. function changeButtonImages(i_Name, i_strLeft, i_strMid, i_strRight)
  520. {
  521.     var objButtonLeft = document.getElementById(i_Name + "Left");
  522.     var objButtonMid = document.getElementById(i_Name + "Mid");
  523.     var objButtonRight = document.getElementById(i_Name + "Right");
  524.     if (objButtonLeft && objButtonMid && objButtonRight)
  525.     {
  526.         objButtonLeft.src = i_strLeft;
  527.         objButtonMid.background = i_strMid;
  528.         objButtonRight.src = i_strRight;
  529.     }
  530. }
  531.  
  532. // === createImportExportMenu(object) ===================
  533. // create and set up the menu for import/export functions
  534. function createImportExportMenu(i_objRef)
  535. {
  536.     var blnExportEnabled = false;
  537.     if (g_objDispatch.GetToolCollectionCount() > 0)
  538.         blnExportEnabled = true;
  539.  
  540.     var objImportExportMenu = new Menu();
  541.     objImportExportMenu.AddMenuItem("Export as Binary XML...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ExportData(0);", blnExportEnabled);
  542.     objImportExportMenu.AddMenuItem("Export as Tabular Text...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ExportData(1);", blnExportEnabled);
  543.     objImportExportMenu.AddMenuItem("Export as Structured Text...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ExportData(2);", blnExportEnabled);
  544.     objImportExportMenu.AddMenuItem("Export as XML (without attachments)...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ExportData(3);", blnExportEnabled);
  545.     objImportExportMenu.AddSeparator();
  546.     objImportExportMenu.AddMenuItem("Import...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ImportData();", g_AllowCreate);
  547.     objImportExportMenu.Create();
  548.     MenuPopup(i_objRef, objImportExportMenu);
  549. }
  550.  
  551. // === getScriptDispatch() ===============================
  552. // safely get the script dispatch from the forms glue code
  553. function getScriptDispatch()
  554. {
  555.     try
  556.     {
  557.         var objDispatch = window.external.Delegate.GetScriptDispatch();
  558.         return objDispatch;
  559.     }
  560.     catch (error)
  561.     {
  562.         alert("This web page should only be opened from within Groove. Please close the window.");
  563.         return null;
  564.     }
  565. }