Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1131 lines
29 KiB

  1. // ==============================================================
  2. // Microsoft Server Appliance
  3. // Task-level JavaScript functions
  4. //
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. //
  7. // ==============================================================
  8. <!-- Copyright (c) Microsoft Corporation. All rights reserved.-->
  9. //-------------------------------------------------------------------------
  10. // Global Variables
  11. //-------------------------------------------------------------------------
  12. var id = 0;
  13. var sid =0;
  14. var retrys = 0;
  15. var maxRetrys = 5;
  16. var bFooterIsLoaded;
  17. var bPageInitialized = false;
  18. ClearOkayToLeavePage();
  19. //-------------------------------------------------------------------------
  20. //
  21. // Function : Task
  22. //
  23. // Synopsis : Initialize the Task class
  24. //
  25. // Arguments: None
  26. //
  27. // Returns : None
  28. //
  29. //-------------------------------------------------------------------------
  30. function TaskObject() {
  31. // static JScript properties
  32. NavClick = false;
  33. KeyPress = false;
  34. PageType = false;
  35. BackDisabled = false;
  36. NextDisabled = false;
  37. FinishDisabled = false;
  38. CancelDisabled = false;
  39. }
  40. var Task = new TaskObject();
  41. Task.NavClick = false;
  42. Task.KeyPress = false;
  43. Task.PageType = false;
  44. Task.BackDisabled = false;
  45. Task.NextDisabled = false;
  46. Task.FinishDisabled = false;
  47. Task.CancelDisabled = false;
  48. //-------------------------------------------------------------------------
  49. //
  50. // Function: SA_SignalFooterIsLoaded
  51. //
  52. // Synopsis: Signal that the Footer frameset page is loaded. This function is
  53. // called by the footer page after it has been loaded. Calling this
  54. // function signals to the main page that the navigation bar has
  55. // loaded and completed initialization.
  56. //
  57. // Arguments: None
  58. //
  59. // Returns : None
  60. //
  61. //-------------------------------------------------------------------------
  62. function SA_SignalFooterIsLoaded()
  63. {
  64. bFooterIsLoaded=true;
  65. //SA_TraceOut("SH_TASK", "Footer signaled it was loaded")
  66. }
  67. //-------------------------------------------------------------------------
  68. //
  69. // Function: SA_WaitForFooter
  70. //
  71. // Synopsis: Wait for the Footer frameset page to load and initialize.
  72. //
  73. // Arguments: None
  74. //
  75. // Returns: None
  76. //
  77. //-------------------------------------------------------------------------
  78. function SA_WaitForFooter()
  79. {
  80. //SA_TraceOut("SH_TASK::SA_WaitForFooter()", "Entering")
  81. //
  82. // If the footer has not loaded then sleep for 1/2 second and check again.
  83. if ( !bFooterIsLoaded )
  84. {
  85. window.setTimeout("SA_WaitForFooter()",500);
  86. //SA_TraceOut("SH_TASK::SA_WaitForFooter()", "Exiting, not ready")
  87. return;
  88. }
  89. //
  90. // Footer has loaded, complete initialization of this page
  91. CompletePageInit();
  92. //SA_TraceOut("SH_TASK::SA_WaitForFooter()", "Exiting, Ready")
  93. }
  94. //-------------------------------------------------------------------------
  95. //
  96. // Function: PageInit
  97. //
  98. // Synopsis: Initialize a web page in the client browser.
  99. //
  100. // 1) Load the Footer frameset with the correct navigation
  101. // bar. Property and Tabbed property pages require
  102. // a nav bar with an OK and Cancel button. Wizard
  103. // pages require Back, Next | Finish, and Cancel.
  104. // 2) Call WaitForFooter which then waits for the Footer frameset
  105. // page to load.
  106. //
  107. //
  108. // Arguments: None
  109. //
  110. // Returns: None
  111. //
  112. //-------------------------------------------------------------------------
  113. function PageInit()
  114. {
  115. //SA_TraceOut("SH_Task::PageInit", "Entering")
  116. //
  117. // Clear the Footer Frameset is loaded flag. This flag is set by the Footer
  118. // Frameset (SA_SignalFooterIsLoaded) inside the footer frameset page after
  119. // it has completed it's initialization.
  120. bFooterIsLoaded = false;
  121. //
  122. // Need to know what type of page we are serving.
  123. var taskType = document.frmTask.TaskType.value;
  124. var wizardPageType = document.frmTask.PageType.value;
  125. //SA_TraceOut("SH_Task::PageInit", "TaskType : " + document.frmTask.TaskType.value);
  126. //SA_TraceOut("SH_Task::PageInit", "WizardPageType: " + wizardPageType);
  127. //SA_TraceOut("SH_Task::PageInit", "Forms count: " + document.forms.length );
  128. var oFooter = eval("top.footer");
  129. if ( oFooter == null )
  130. {
  131. if ( SA_IsDebugEnabled() )
  132. {
  133. var msg = "Error: The current page will not work correctly because it's being opened without frameset.\n\n";
  134. msg += "The current page is either a Property, Tabbed Property, or a Wizard page. ";
  135. msg += "These pages only work within frameset's. Normally this error indicates that the call to ";
  136. msg += "OTS_CreateTask was made using the incorrect PageType parameter. The correct PageType ";
  137. msg += "value this page is either OTS_PT_PROPERTY, OTS_PT_TABBED, or OTS_PT_WIZARD depending upon ";
  138. msg += "which page type this page is. ";
  139. alert(msg);
  140. }
  141. return;
  142. }
  143. //
  144. // Property page
  145. if ( taskType == "prop" )
  146. {
  147. top.footer.location = GetVirtualRoot()+"sh_propfooter.asp";
  148. }
  149. //
  150. // Tabbed Property page
  151. else if ( taskType == "TabPropSheet" )
  152. {
  153. top.footer.location = GetVirtualRoot()+"sh_propfooter.asp";
  154. }
  155. //
  156. // Wizard page
  157. else if ( taskType == "wizard" )
  158. {
  159. if ( wizardPageType == "intro" )
  160. {
  161. top.footer.location = GetVirtualRoot()+"sh_wizardfooter.asp?PT=Intro" +
  162. "&" + SAI_FLD_PAGEKEY + "=" + g_strSAIPageKey;
  163. }
  164. else if ( wizardPageType == "finish" )
  165. {
  166. top.footer.location = GetVirtualRoot()+"sh_wizardfooter.asp?PT=Finish" +
  167. "&" + SAI_FLD_PAGEKEY + "=" + g_strSAIPageKey;
  168. }
  169. else
  170. {
  171. top.footer.location = GetVirtualRoot()+"sh_wizardfooter.asp?PT=Standard" +
  172. "&" + SAI_FLD_PAGEKEY + "=" + g_strSAIPageKey;
  173. }
  174. }
  175. //
  176. // Unknown page
  177. else
  178. {
  179. SA_TraceOut("SH_Task::PageInit()", "Unrecognized TaskType: " + taskType);
  180. top.footer.location = GetVirtualRoot()+"sh_propfooter.asp";
  181. }
  182. //
  183. // Wait for the Footer Frameset to load
  184. SA_WaitForFooter();
  185. //SA_TraceOut("SH_Task::PageInit", "Leaving")
  186. }
  187. //-------------------------------------------------------------------------
  188. //
  189. // Function: CompletePageInit
  190. //
  191. // Synopsis: Finish initialization of the web page running in the client browser.
  192. // This function is executed after the Footer Frameset page has
  193. // completed initialization.
  194. //
  195. // Arguments: None
  196. //
  197. // Returns: None
  198. //
  199. //-------------------------------------------------------------------------
  200. function CompletePageInit()
  201. {
  202. //SA_TraceOut("SH_TASK", "CompletePageInit")
  203. document.onkeypress = HandleKeyPress;
  204. Task.NavClick = false;
  205. Task.KeyPress = false;
  206. Task.PageType = document.frmTask.PageType.value;
  207. //
  208. // Set initial state of Footer Frameset buttons
  209. SetTaskButtons();
  210. //
  211. // Call the Init function for this Web Page. This function must be implemented
  212. // for any task (Property, Tabbed Property, or Wizard) page.
  213. var oException;
  214. try
  215. {
  216. Init();
  217. }
  218. catch(oException)
  219. {
  220. if ( SA_IsDebugEnabled() )
  221. {
  222. alert("Unexpected exception while attempting to execute Init() function.\n\n" +
  223. "Error: " + oException.number + "\n" +
  224. "Description: " + oException.description + "\n");
  225. }
  226. }
  227. //
  228. // Store the initial state of all form fields on this page. The initial state is
  229. // later checked when the user attempts to tab away from this page. The framework
  230. // checks to see if any of the form fields have changed and if changes are detected
  231. // a confirm dialog is presented to warn the user.
  232. SA_StoreInitialState();
  233. SA_SetPageInitialized();
  234. }
  235. function SA_IsPageInitialized()
  236. {
  237. return bPageInitialized;
  238. }
  239. function SA_SetPageInitialized()
  240. {
  241. bPageInitialized = true;
  242. }
  243. //-------------------------------------------------------------------------
  244. //
  245. // Function : SetTaskButtons
  246. //
  247. // Synopsis : Sets task wizard button state
  248. //
  249. // Arguments: None
  250. //
  251. // Returns : None
  252. //
  253. //-------------------------------------------------------------------------
  254. function SetTaskButtons()
  255. {
  256. var oFooter = top.footer.document.getElementById("frmFooter");
  257. if(oFooter != null)
  258. {
  259. switch (document.frmTask.TaskType.value)
  260. {
  261. case "wizard" :
  262. switch (document.frmTask.PageType.value)
  263. {
  264. case "intro":
  265. if (!Task.NextDisabled)
  266. {
  267. DisableBack();
  268. EnableNext();
  269. oFooter.butNext.focus();
  270. }
  271. break;
  272. case "finish":
  273. if (!Task.FinishDisabled)
  274. {
  275. EnableFinish();
  276. oFooter.butFinish.focus();
  277. }
  278. break;
  279. default:
  280. if((document.frmTask.PageType.value).indexOf("finish") !=-1)
  281. {
  282. if (!Task.FinishDisabled)
  283. {
  284. EnableFinish();
  285. oFooter.butFinish.focus();
  286. }
  287. }
  288. else
  289. {
  290. if (!Task.NextDisabled)
  291. {
  292. EnableNext();
  293. oFooter.butNext.focus();
  294. }
  295. }
  296. break;
  297. }
  298. break;
  299. default:
  300. break;
  301. }
  302. }
  303. }
  304. //-------------------------------------------------------------------------
  305. //
  306. // Function : SetupEmbedValues
  307. //
  308. // Synopsis : Extracts form values for the current embedded page.
  309. // Uses values to set current form elements,
  310. // e.g., sets a radio button to its state when the page
  311. // was last posted.
  312. //
  313. // Arguments: None
  314. //
  315. // Returns : None
  316. //
  317. //-------------------------------------------------------------------------
  318. //
  319. //function SetupEmbedValues() {
  320. // var arrName = new Array;
  321. // var arrValue = new Array;
  322. // var i;
  323. // var intIndex = document.frmTask.EmbedPageIndex.value;
  324. // var strInput = document.frmTask.elements['EmbedValues'+intIndex].value;
  325. // var strNameD = ";;"; // name delimiter
  326. // var strValueD = ";"; // value delimiter
  327. // if (strInput != "") {
  328. // if (strInput.substring(0, 2) == strNameD)
  329. // strInput = strInput.substring(2, strInput.length + 1);
  330. // intIndex = 0;
  331. // intPos1 = strInput.indexOf(strValueD);
  332. // intPos2 = -2;
  333. // do {
  334. // arrName[intIndex] = Trim(strInput.substring(intPos2+2, intPos1));
  335. // intPos2 = strInput.indexOf(strNameD, intPos1);
  336. // if (intPos2 == -1)
  337. // intPos2 = strInput.length + 1; // assumes no end delimiter
  338. // arrValue[intIndex] = Trim(strInput.substring(intPos1+1, intPos2));
  339. // if (intPos2+1 < strInput.length)
  340. // intPos1 = strInput.indexOf(strValueD, intPos2 + 2);
  341. // else
  342. // break;
  343. // intIndex = intIndex+1;
  344. // }
  345. // while (intPos1 != 0);
  346. // for (i=0;i<arrName.length;i++) {
  347. // if (document.frmTask.elements[arrName[i]] != null)
  348. // document.frmTask.elements[arrName[i]].value = arrValue[i];
  349. // }
  350. // }
  351. //}
  352. //-------------------------------------------------------------------------
  353. //
  354. // Function : HandleKeyPress
  355. //
  356. // Synopsis : Event handler for key presses
  357. //
  358. // Arguments: evnt(IN) - event describing the key pressed
  359. //
  360. // Returns : None
  361. //
  362. //-------------------------------------------------------------------------
  363. function HandleKeyPress(evnt) {
  364. var intKeyCode;
  365. var Task1 = top.main.Task
  366. if (Task1 == null)
  367. {
  368. return;
  369. }
  370. if (Task1.KeyPress==true || Task1.NavClick==true) {
  371. return;
  372. }
  373. if (IsIE())
  374. intKeyCode = window.event.keyCode;
  375. else
  376. intKeyCode = evnt.which;
  377. if (intKeyCode == 13)
  378. {
  379. //alert("HandleKeyPress ENTER key logic");
  380. Task1.KeyPress = true;
  381. if (Task1.PageType != "finish") {
  382. if(document.all && (top.footer.frmFooter.butOK !=null ||top.footer.frmFooter.butNext !=null))
  383. top.main.Next();
  384. if (document.layers && (parent.frames[1].window.document.layers[0].document.forms[0].elements[1] != null || parent.frames[1].window.document.layers[2].document.forms[0].elements[1] != null))
  385. top.main.Next();
  386. } else {
  387. if(document.all && (top.footer.frmFooter.butFinish!=null))
  388. top.main.FinishShell();
  389. if (document.layers && parent.frames[1].window.document.layers[1].document.forms[0].elements[1] != null)
  390. top.main.FinishShell();
  391. }
  392. }
  393. if (intKeyCode == 27)
  394. {
  395. Task1.KeyPress = true;
  396. top.main.Cancel();
  397. }
  398. //
  399. // JK - 2-6-01 Removed
  400. //if ( (intKeyCode==98 ||intKeyCode==66) && Task1.PageType == "standard")//key code for "B"
  401. //{
  402. // Task1.KeyPress = true;
  403. // top.main.Back();
  404. //}
  405. //if ( (intKeyCode==110 ||intKeyCode==78) && (Task1.PageType == "intro" ||Task1.PageType == "standard"))//key code for "N"
  406. //{
  407. // Task1.KeyPress = true;
  408. // top.main.Next();
  409. //}
  410. //if ((intKeyCode==102 ||intKeyCode==70) && Task1.PageType == "finish")//key code for "F"
  411. //{
  412. // Task1.KeyPress = true;
  413. // top.main.FinishShell();
  414. //}
  415. }
  416. //-------------------------------------------------------------------------
  417. //
  418. // Function : DisplayErr
  419. //
  420. // Synopsis : Display error msg
  421. //
  422. // Arguments: ErrMsg(IN) - error msg to display
  423. //
  424. // Returns : None
  425. //
  426. //-------------------------------------------------------------------------
  427. function SA_DisplayErr(ErrMsg) {
  428. DisplayErr(ErrMsg);
  429. }
  430. function DisplayErr(ErrMsg) {
  431. var strErrMsg = '<table class="ErrMsg"><tr><td><img src="' + VirtualRoot + 'images/critical_error.gif" border=0></td><td>' + ErrMsg + '</td></tr></table>'
  432. if (IsIE()) {
  433. document.all("divErrMsg").innerHTML = strErrMsg;
  434. }
  435. else {
  436. alert(ErrMsg);
  437. }
  438. }
  439. function SA_OnClickTab(tabNumber)
  440. {
  441. var oException;
  442. var bValid = false;
  443. try
  444. {
  445. bValid = ValidatePage();
  446. }
  447. catch(oException)
  448. {
  449. if ( SA_IsDebugEnabled() )
  450. {
  451. alert("Unexpected exception while attempting to execute ValidatePage()\n\nError:"+oException.number+"\nDescription: " + oException.description);
  452. }
  453. }
  454. if (bValid)
  455. {
  456. try
  457. {
  458. SetData();
  459. }
  460. catch(oException)
  461. {
  462. if ( SA_IsDebugEnabled() )
  463. {
  464. alert("Unexpected exception while attempting to execute SetData()\n\nError:"+oException.number+"\nDescription: " + oException.description);
  465. }
  466. }
  467. top.main.document.forms['frmTask'].TabSelected.value=tabNumber;
  468. top.main.document.forms['frmTask'].submit();
  469. }
  470. }
  471. //-------------------------------------------------------------------------
  472. //
  473. // Function : Next
  474. //
  475. // Synopsis : Handle next button being clicked
  476. //
  477. // Arguments: None
  478. //
  479. // Returns : None
  480. //
  481. //-------------------------------------------------------------------------
  482. function Next() {
  483. if (Task.NavClick != true && !Task.NextDisabled) {
  484. var bValid;
  485. try {
  486. bValid = ValidatePage();
  487. if (bValid) {
  488. DisableNext();
  489. DisableBack();
  490. DisableCancel();
  491. DisableFinish();
  492. DisableOK();
  493. Task.NavClick = true;
  494. SetData();
  495. document.frmTask.Method.value = "NEXT";
  496. document.frmTask.submit();
  497. return true;
  498. }
  499. else {
  500. Task.NavClick = false;
  501. Task.KeyPress = false;
  502. return false;
  503. }
  504. }
  505. catch(oException)
  506. {
  507. if ( SA_IsDebugEnabled() )
  508. {
  509. alert("Unexpected exception while attempting to execute ValidatePage()\n\nError:"+oException.number+"\nDescription: " + oException.description);
  510. }
  511. }
  512. }
  513. else {
  514. return false;
  515. }
  516. }
  517. //-------------------------------------------------------------------------
  518. //
  519. // Function : Back
  520. //
  521. // Synopsis : Handle back button being clicked
  522. //
  523. // Arguments: None
  524. //
  525. // Returns : None
  526. //
  527. //-------------------------------------------------------------------------
  528. function Back() {
  529. if (Task.NavClick == false && Task.PageType != "intro" && !Task.BackDisabled) {
  530. DisableNext();
  531. DisableBack();
  532. DisableCancel();
  533. DisableFinish();
  534. DisableOK();
  535. Task.NavClick = true;
  536. document.frmTask.Method.value = "BACK";
  537. document.frmTask.submit();
  538. }
  539. }
  540. //-------------------------------------------------------------------------
  541. //
  542. // Function : Cancel
  543. //
  544. // Synopsis : Handle cancel button being clicked
  545. //
  546. // Arguments: None
  547. //
  548. // Returns : None
  549. //
  550. //-------------------------------------------------------------------------
  551. function Cancel() {
  552. if (Task.NavClick != true && !Task.CancelDisabled) {
  553. Task.NavClick = true;
  554. DisableCancel();
  555. DisableNext();
  556. DisableBack();
  557. DisableFinish();
  558. DisableOK();
  559. document.frmTask.target= "_top";
  560. document.frmTask.Method.value = "CANCEL";
  561. document.frmTask.submit();
  562. }
  563. }
  564. //-------------------------------------------------------------------------
  565. //
  566. // Function : FinishShell
  567. //
  568. // Synopsis : Handle finish button being clicked
  569. //
  570. // Arguments: None
  571. //
  572. // Returns : None
  573. //
  574. //-------------------------------------------------------------------------
  575. function FinishShell() {
  576. if (Task.NavClick == false && !Task.FinishDisabled) {
  577. Task.NavClick = true;
  578. DisableCancel();
  579. DisableNext();
  580. DisableBack();
  581. DisableFinish();
  582. DisableOK();
  583. SetData();
  584. document.frmTask.Method.value = "FINISH";
  585. document.frmTask.submit();
  586. }
  587. }
  588. //-------------------------------------------------------------------------
  589. //
  590. // Function : DisableNext
  591. //
  592. // Synopsis : Disables the next button
  593. //
  594. // Arguments: None
  595. //
  596. // Returns : None
  597. //
  598. //-------------------------------------------------------------------------
  599. function SA_DisableNext()
  600. {
  601. DisableNext();
  602. }
  603. function DisableNext() {
  604. var oFooter = SAI_GetFooterForm('DisableNext();');
  605. if ( oFooter == null ) return;
  606. if (oFooter.butNext != null)
  607. {
  608. oFooter.butNext.disabled = true;
  609. oFooter.butNext.value = oFooter.butNext.value;
  610. var oImage = top.footer.document.getElementById("btnNextImage");
  611. if ( oImage != null )
  612. {
  613. oImage.src = GetVirtualRoot()+'images/butGreenArrowDisabled.gif';
  614. }
  615. }
  616. Task.NextDisabled = true;
  617. }
  618. //-------------------------------------------------------------------------
  619. //
  620. // Function : EnableNext
  621. //
  622. // Synopsis : Enables the next button
  623. //
  624. // Arguments: None
  625. //
  626. // Returns : None
  627. //
  628. //-------------------------------------------------------------------------
  629. function SA_EnableNext()
  630. {
  631. EnableNext();
  632. }
  633. function EnableNext() {
  634. var oFooter = SAI_GetFooterForm('EnableNext();');
  635. if ( oFooter == null ) return;
  636. if (oFooter.butNext != null)
  637. {
  638. oFooter.butNext.disabled = false;
  639. var oImage = top.footer.document.getElementById("btnNextImage");
  640. if ( oImage != null )
  641. {
  642. oImage.src = GetVirtualRoot()+'images/butGreenArrow.gif';
  643. }
  644. }
  645. Task.NextDisabled = false;
  646. }
  647. //-------------------------------------------------------------------------
  648. //
  649. // Function : DisableBack
  650. //
  651. // Synopsis : Disables the back button
  652. //
  653. // Arguments: None
  654. //
  655. // Returns : None
  656. //
  657. //-------------------------------------------------------------------------
  658. function SA_DisableBack()
  659. {
  660. DisableBack();
  661. }
  662. function DisableBack() {
  663. var oFooter = SAI_GetFooterForm('DisableBack();');
  664. if ( oFooter == null ) return;
  665. if (oFooter.butBack != null)
  666. {
  667. oFooter.butBack.disabled = true;
  668. oFooter.butBack.value = oFooter.butBack.value;
  669. var oImage = top.footer.document.getElementById("btnBackImage");
  670. if ( oImage != null )
  671. {
  672. oImage.src = GetVirtualRoot()+'images/butGreenArrowLeftDisabled.gif';
  673. }
  674. }
  675. Task.BackDisabled = true;
  676. }
  677. //-------------------------------------------------------------------------
  678. //
  679. // Function : EnableBack
  680. //
  681. // Synopsis : Enables the back button
  682. //
  683. // Arguments: None
  684. //
  685. // Returns : None
  686. //
  687. //-------------------------------------------------------------------------
  688. function SA_EnableBack()
  689. {
  690. EnableBack();
  691. }
  692. function EnableBack() {
  693. var oFooter = SAI_GetFooterForm('EnableBack();');
  694. if ( oFooter == null ) return;
  695. if (oFooter.butBack != null)
  696. {
  697. oFooter.butBack.disabled = false;
  698. var oImage = top.footer.document.getElementById("btnBackImage");
  699. if ( oImage != null )
  700. {
  701. oImage.src = GetVirtualRoot()+'images/butGreenArrowLeft.gif';
  702. }
  703. }
  704. Task.BackDisabled = false;
  705. }
  706. //-------------------------------------------------------------------------
  707. //
  708. // Function : DisableFinish
  709. //
  710. // Synopsis : Disables the finish button
  711. //
  712. // Arguments: None
  713. //
  714. // Returns : None
  715. //
  716. //-------------------------------------------------------------------------
  717. function SA_DisableFinish()
  718. {
  719. DisableFinish();
  720. }
  721. function DisableFinish() {
  722. var oFooter = SAI_GetFooterForm('DisableFinish();');
  723. if ( oFooter == null ) return;
  724. if (oFooter.butFinish != null)
  725. {
  726. oFooter.butFinish.disabled = true;
  727. oFooter.butFinish.value = oFooter.butFinish.value;
  728. var oImage = top.footer.document.getElementById("btnFinishImage");
  729. if ( oImage != null )
  730. {
  731. oImage.src = GetVirtualRoot()+'images/butGreenArrowDisabled.gif';
  732. }
  733. }
  734. Task.FinishDisabled = true;
  735. }
  736. //-------------------------------------------------------------------------
  737. //
  738. // Function : EnableFinish
  739. //
  740. // Synopsis : Enables the finish button
  741. //
  742. // Arguments: None
  743. //
  744. // Returns : None
  745. //
  746. //-------------------------------------------------------------------------
  747. function SA_EnableFinish()
  748. {
  749. EnableFinish();
  750. }
  751. function EnableFinish() {
  752. var oFooter = SAI_GetFooterForm('EnableFinish();');
  753. if ( oFooter == null ) return;
  754. if (oFooter.butFinish != null)
  755. {
  756. oFooter.butFinish.disabled = false;
  757. var oImage = top.footer.document.getElementById("btnFinishImage");
  758. if ( oImage != null )
  759. {
  760. oImage.src = GetVirtualRoot()+'images/butGreenArrow.gif';
  761. }
  762. }
  763. Task.FinishDisabled = false;
  764. }
  765. //-------------------------------------------------------------------------
  766. //
  767. // Function : DisableCancel
  768. //
  769. // Synopsis : Disables the cancel button
  770. //
  771. // Arguments: None
  772. //
  773. // Returns : None
  774. //
  775. //-------------------------------------------------------------------------
  776. function SA_DisableCancel()
  777. {
  778. DisableCancel();
  779. }
  780. function DisableCancel() {
  781. var oFooter = SAI_GetFooterForm('DisableCancel();');
  782. if ( oFooter == null ) return;
  783. if (oFooter.butCancel != null)
  784. {
  785. oFooter.butCancel.disabled = true;
  786. oFooter.butCancel.value = oFooter.butCancel.value;
  787. var oImage = top.footer.document.getElementById("btnCancelImage");
  788. if ( oImage != null )
  789. {
  790. oImage.src = GetVirtualRoot()+'images/butRedXDisabled.gif';
  791. }
  792. }
  793. Task.CancelDisabled = true;
  794. }
  795. //-------------------------------------------------------------------------
  796. //
  797. // Function : EnableCancel
  798. //
  799. // Synopsis : Enables the cancel button
  800. //
  801. // Arguments: None
  802. //
  803. // Returns : None
  804. //
  805. //-------------------------------------------------------------------------
  806. function SA_EnableCancel()
  807. {
  808. EnableCancel();
  809. }
  810. function EnableCancel() {
  811. var oFooter = SAI_GetFooterForm('EnableCancel();');
  812. if ( oFooter == null ) return;
  813. if (oFooter.butCancel != null)
  814. {
  815. oFooter.butCancel.disabled = false;
  816. var oImage = top.footer.document.getElementById("btnCancelImage");
  817. if ( oImage != null )
  818. {
  819. oImage.src = GetVirtualRoot()+'images/butRedX.gif';
  820. }
  821. }
  822. Task.CancelDisabled = false;
  823. }
  824. //-------------------------------------------------------------------------
  825. //
  826. // Function : DisableOK
  827. //
  828. // Synopsis : Disables the OK button
  829. //
  830. // Arguments: None
  831. //
  832. // Returns : None
  833. //
  834. //-------------------------------------------------------------------------
  835. function SA_DisableOK()
  836. {
  837. DisableOK();
  838. }
  839. function DisableOK() {
  840. var oFooter = SAI_GetFooterForm('DisableOK();');
  841. if ( oFooter == null ) return;
  842. if (oFooter.butOK != null)
  843. {
  844. oFooter.butOK.disabled = true;
  845. oFooter.butOK.value = oFooter.butOK.value;
  846. var oImage = top.footer.document.getElementById("btnOKImage");
  847. if ( oImage != null )
  848. {
  849. oImage.src = GetVirtualRoot()+'images/butGreenArrowDisabled.gif';
  850. }
  851. }
  852. Task.FinishDisabled = true;
  853. }
  854. //-------------------------------------------------------------------------
  855. //
  856. // Function : EnableOK
  857. //
  858. // Synopsis : Enables the OK button
  859. //
  860. // Arguments: None
  861. //
  862. // Returns : None
  863. //
  864. //-------------------------------------------------------------------------
  865. function SA_EnableOK()
  866. {
  867. EnableOK();
  868. }
  869. function EnableOK() {
  870. var oFooter = SAI_GetFooterForm('EnableOK();');
  871. if ( oFooter == null ) return;
  872. if (oFooter.butOK != null)
  873. {
  874. oFooter.butOK.disabled = false;
  875. var oImage = top.footer.document.getElementById("btnOKImage");
  876. if ( oImage != null )
  877. {
  878. oImage.src = GetVirtualRoot()+'images/butGreenArrow.gif';
  879. }
  880. }
  881. Task.NextDisabled = false;
  882. }
  883. //-------------------------------------------------------------------------
  884. //
  885. // Function : isValidFileName
  886. //
  887. // Synopsis : validates that file name has correct syntax
  888. //
  889. // Arguments: filePath(IN) - file name with path to validate
  890. //
  891. // Returns : true/false
  892. //
  893. //-------------------------------------------------------------------------
  894. function isValidFileName(filePath)
  895. {
  896. reInvalid = /[\/\*\?"<>\|]/;
  897. if (reInvalid.test(filePath))
  898. return false;
  899. reColomn2 = /:{2,}/;
  900. reColomn1 = /:{1,}/;
  901. if ( reColomn2.test(filePath) || ( filePath.charAt(1) != ':' && reColomn1.test(filePath) ))
  902. return false;
  903. reEndSlash = /\\ *$/;
  904. if (reEndSlash.test(filePath))
  905. return false;
  906. reEndColomn = /: *$/;
  907. if (reEndColomn.test(filePath))
  908. return false;
  909. reAllSpaces = /[^ ]/;
  910. if (!reAllSpaces.test(filePath))
  911. return false;
  912. return true;
  913. }
  914. //-------------------------------------------------------------------------
  915. //
  916. // Function : HandleKeyPressIFrame
  917. //
  918. // Synopsis : key press event handler for IFRAME
  919. //
  920. // Arguments: evnt(IN) - event describing the key pressed
  921. //
  922. // Returns : None
  923. //
  924. //-------------------------------------------------------------------------
  925. function HandleKeyPressIFrame(evnt) {
  926. var intKeyCode;
  927. var frameMain = window.top.main;
  928. if (Task.KeyPress==true || Task.NavClick==true) {
  929. return;
  930. }
  931. Task.KeyPress = true;
  932. if (IsIE())
  933. intKeyCode = window.event.keyCode;
  934. else
  935. intKeyCode = evnt.which;
  936. if (intKeyCode == 13)
  937. {
  938. frameMain.Next();
  939. }
  940. if (intKeyCode == 27) {
  941. frameMain.Cancel();
  942. }
  943. }
  944. function IsOkayToChangeTabs()
  945. {
  946. return confirm('Click OK to discard any changes.');
  947. }
  948. function SAI_GetFooterForm(CallingFunction)
  949. {
  950. var oFooter = top.footer.document.getElementById("frmFooter");
  951. if (oFooter == null) {
  952. retrys++;
  953. if ( retrys < maxRetrys ) {
  954. //SA_TraceOut("SH_TASK::DisableNext()", "Footer not ready, waiting for footer")
  955. window.setTimeout(CallingFunction,500);
  956. }
  957. else {
  958. if (SA_IsDebugEnabled())
  959. {
  960. SA_TraceOut("Unable to locate footer.frmFooter for function: ", CallingFunction);
  961. }
  962. retrys = 0;
  963. }
  964. }
  965. else
  966. {
  967. retrys = 0;
  968. }
  969. return oFooter;
  970. }