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.

1152 lines
22 KiB

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  4. <script language="javascript">
  5. // ==============================================================
  6. // Microsoft Server Appiance
  7. // Object Task Selector JavaScript functions
  8. //
  9. // Copyright (c) Microsoft Corporation. All rights reserved.
  10. //
  11. // ==============================================================
  12. var OTS_MESSAGE_BEGIN = "begin";
  13. var OTS_MESSAGE_ITEM = "item";
  14. var OTS_MESSAGE_END = "end";
  15. var lastItem = 0;
  16. var tabUrl;
  17. tabUrl = "Tab1=" +"<%=GetTab1()%>" + "&Tab2=" + "<%=GetTab2()%>";
  18. function SA_IsIE()
  19. {
  20. if ((navigator.userAgent.toLowerCase()).indexOf("msie") != -1)
  21. return true;
  22. else
  23. return false;
  24. }
  25. function SA_IsNav()
  26. {
  27. var sAgent = navigator.userAgent.toLowerCase();
  28. if (sAgent.indexOf("mozilla") != -1
  29. && sAgent.indexOf("compatible") == -1
  30. && sAgent.indexOf("spoofer") == -1
  31. && sAgent.indexOf("opera") == -1
  32. && sAgent.indexOf("webtv") == -1
  33. )
  34. return true;
  35. else
  36. return false;
  37. }
  38. function OTS_CompareEqual(item1, item2)
  39. {
  40. if ( item1 == item2 ) return true;
  41. else return false;
  42. }
  43. function OTS_Init(selectItem)
  44. {
  45. OTS_InitEx(selectItem, OTS_CompareEqual);
  46. }
  47. function OTS_InitEx(selectItem, CompareEqualFunction)
  48. {
  49. var nIndex;
  50. var objItemList;
  51. var objOTSForm;
  52. if ( document.forms.length <= 0 )
  53. {
  54. OTS_UpdateTaskList();
  55. return;
  56. }
  57. objOTSForm = eval("document.TVData")
  58. if ( objOTSForm == null || objOTSForm.length <= 0 )
  59. {
  60. OTS_UpdateTaskList();
  61. return;
  62. }
  63. objItemList = eval("document.TVData.TVItem_Table1")
  64. if ( objItemList == null || objItemList.length <= 0 )
  65. {
  66. OTS_UpdateTaskList();
  67. return;
  68. }
  69. //
  70. // Multi selection OTS does not support automatic item selection
  71. if (objItemList[0].type == "checkbox" ){
  72. OTS_UpdateTaskList();
  73. return;
  74. }
  75. //
  76. // Search the list for a matching item
  77. //
  78. for(nIndex = 0 ; nIndex < objItemList.length ; nIndex++)
  79. {
  80. if (CompareEqualFunction(objItemList[nIndex].value,selectItem))
  81. {
  82. objItemList[nIndex].checked = true;
  83. objItemList[nIndex].focus();
  84. document.TVData.tSelectedItem.value = selectItem ;
  85. document.TVData.tSelectedItemNumber.value = nIndex;
  86. OTS_UpdateTaskList();
  87. return;
  88. }
  89. }
  90. //
  91. // Item not found, check to see if the form's selected item is set
  92. if ( document.TVData.tSelectedItem.value.length > 0 )
  93. {
  94. for(nIndex = 0 ; nIndex < objItemList.length ; nIndex++)
  95. {
  96. if (CompareEqualFunction(objItemList[nIndex].value, document.TVData.tSelectedItem.value))
  97. {
  98. objItemList[nIndex].checked = true;
  99. objItemList[nIndex].focus();
  100. OTS_UpdateTaskList();
  101. return;
  102. }
  103. }
  104. }
  105. else
  106. {
  107. //
  108. // Default select first item
  109. //
  110. objItemList[0].checked = true;
  111. objItemList[0].focus();
  112. document.TVData.tSelectedItem.value = objItemList[0].value;
  113. document.TVData.tSelectedItemNumber.value = 0;
  114. }
  115. OTS_UpdateTaskList();
  116. return;
  117. }
  118. var g_bInMultiSelectMode=false;
  119. var g_iMouseDownStartingRow = 0;
  120. var g_bMultiStartingState = false;
  121. function OTS_IsMultiSelectKeyDown()
  122. {
  123. return true;
  124. }
  125. function OTS_OnMouseMove(iRowNumber, bMultiSelect)
  126. {
  127. //SA_TraceOut('OnMouseMove', 'Row: ' + iRowNumber);
  128. if ( g_bInMultiSelectMode )
  129. {
  130. objItemList = eval("document.TVData.TVItem_Table1");
  131. if ( objItemList == null )
  132. {
  133. return true;
  134. }
  135. objItemList[iRowNumber].checked = g_bMultiStartingState;
  136. }
  137. return true;
  138. }
  139. function OTS_OnMouseDown(iRowNumber, bMultiSelect)
  140. {
  141. //SA_TraceOut('OTS_OnMouseDown', 'Row: ' + iRowNumber);
  142. g_bInMultiSelectMode = false;
  143. if ( bMultiSelect )
  144. {
  145. if ( !OTS_IsMultiSelectKeyDown())
  146. {
  147. return true;
  148. }
  149. var objItemList;
  150. objItemList = eval("document.TVData.TVItem_Table1");
  151. if ( objItemList == null )
  152. {
  153. return true;
  154. }
  155. g_bMultiStartingState = !objItemList[iRowNumber].checked;
  156. g_iMouseDownStartingRow = iRowNumber;
  157. g_bInMultiSelectMode = true;
  158. }
  159. return true;
  160. }
  161. function OTS_OnMouseUp(iRowNumber, bMultiSelect)
  162. {
  163. //SA_TraceOut('OTS_OnMouseUp', 'Row: ' + iRowNumber);
  164. if ( g_bInMultiSelectMode && bMultiSelect && OTS_IsMultiSelectKeyDown())
  165. {
  166. g_bInMultiSelectMode = false;
  167. var x;
  168. var objItemList;
  169. objItemList = eval("document.TVData.TVItem_Table1");
  170. if ( objItemList == null )
  171. {
  172. return true;
  173. }
  174. for( x = g_iMouseDownStartingRow;
  175. x <= iRowNumber;
  176. x++ )
  177. {
  178. objItemList[x].checked = g_bMultiStartingState;
  179. }
  180. }
  181. return true;
  182. }
  183. var g_itemJustClicked=false;
  184. var g_iLastSelectedRow = 0;
  185. function OTS_RowClicked(rowNumber){
  186. var objItemList;
  187. //
  188. // Convert parameter to integer value
  189. rowNumber = parseInt(rowNumber);
  190. //SA_TraceOut('OTS_RowClicked', 'Row: ' + rowNumber);
  191. //
  192. // Verify that we have a valid OTS table
  193. objItemList = eval("document.TVData.TVItem_Table1");
  194. if ( objItemList == null )
  195. {
  196. SA_TraceOut('OTS_RowClicked', 'ERROR: eval(document.TVData.TVItem_Table1) returned null');
  197. OTS_UpdateTaskList();
  198. return true;
  199. }
  200. //
  201. // Check for shift-click, which is only supported in multi-select tables
  202. // for IE browsers.
  203. if (objItemList[0].type == "checkbox" )
  204. {
  205. if ( SA_IsIE() )
  206. {
  207. if (window.event.shiftKey)
  208. {
  209. var x;
  210. if ( g_iLastSelectedRow > rowNumber )
  211. {
  212. for ( x = rowNumber; x <= g_iLastSelectedRow; x++ )
  213. {
  214. objItemList[x].checked = true;
  215. }
  216. }
  217. else
  218. {
  219. for ( x = g_iLastSelectedRow; x <= rowNumber; x++ )
  220. {
  221. objItemList[x].checked = true;
  222. }
  223. }
  224. objItemList[rowNumber].focus();
  225. g_iLastSelectedRow = rowNumber;
  226. OTS_UpdateTaskList();
  227. return true;
  228. }
  229. }
  230. else
  231. {
  232. // Non-IE Browser
  233. }
  234. }
  235. g_iLastSelectedRow = rowNumber;
  236. //
  237. // If the input control was directly clicked then we don't need
  238. // to simulate selecting it, and we are out-of-here.
  239. if ( g_itemJustClicked )
  240. {
  241. g_itemJustClicked = false;
  242. return true;
  243. }
  244. //
  245. // Multi-selection Widget
  246. if (objItemList[0].type == "checkbox" )
  247. {
  248. //
  249. // If the row is checked, then un-check it
  250. if ( objItemList[rowNumber].checked == true )
  251. {
  252. objItemList[rowNumber].checked = false;
  253. objItemList[rowNumber].focus();
  254. OTS_UpdateTaskList();
  255. return true;
  256. }
  257. //
  258. // Else check the row
  259. else
  260. {
  261. objItemList[rowNumber].checked = true;
  262. objItemList[rowNumber].focus();
  263. OTS_UpdateTaskList();
  264. return true;
  265. }
  266. }
  267. //
  268. // Single selection OTS Widget
  269. else
  270. {
  271. document.TVData.tSelectedItem.value = objItemList[rowNumber].value;
  272. document.TVData.tSelectedItemNumber.value = rowNumber;
  273. objItemList[rowNumber].checked = true;
  274. objItemList[rowNumber].focus();
  275. }
  276. OTS_UpdateTaskList();
  277. return true;
  278. }
  279. function OTS_OnItemClicked(item, itemNumber)
  280. {
  281. //SA_TraceOut('OTS_OnItemClicked', 'Row: ' + itemNumber);
  282. g_itemJustClicked=true;
  283. document.TVData.tSelectedItem.value = item;
  284. document.TVData.tSelectedItemNumber.value = itemNumber;
  285. OTS_UpdateTaskList();
  286. return true;
  287. }
  288. function OTS_OnSelectTask(iTaskNo, pKeyName, objectName, actionName, taskTitle, taskPageType, bMultiSelect)
  289. {
  290. var oException;
  291. try
  292. {
  293. return OTS_OnSelectTaskInternal(iTaskNo, pKeyName, objectName, actionName, taskTitle, taskPageType, bMultiSelect)
  294. }
  295. catch(oException)
  296. {
  297. if ( SA_IsDebugEnabled() )
  298. {
  299. alert("Javascript exception in OTS_OnSelectTask. Error: " + oException.number + " Description: " + oException.description );
  300. }
  301. }
  302. }
  303. function OTS_OnSelectTaskInternal(iTaskNo, pKeyName, objectName, actionName, taskTitle, taskPageType, bMultiSelect)
  304. {
  305. //
  306. // Make sure task is enabled
  307. //
  308. if ( !OTS_IsTaskEnabled(iTaskNo) )
  309. {
  310. return;
  311. }
  312. actionName = SA_MungeURL(actionName, "<%=SAI_FLD_PAGEKEY%>", "<%=SAI_GetPageKey()%>");
  313. if ( parseInt(bMultiSelect) == 1 )
  314. {
  315. //alert("OTS_OnSelectTask(MultiSelect)");
  316. switch(''+taskPageType) {
  317. case '<%=OTS_PT_PROPERTY%>':
  318. case '<%=OTS_PT_TABBED_PROPERTY%>':
  319. case '<%=OTS_PT_WIZARD%>':
  320. OTS_PostPropertyPage(pKeyName, objectName, actionName, taskTitle);
  321. break;
  322. case '<%=OTS_PT_AREA%>':
  323. OTS_PostNormalPage(pKeyName, objectName, actionName, taskTitle);
  324. break;
  325. case '<%=OTS_PT_NEW_WINDOW%>':
  326. OTS_PostNewPage(pKeyName, objectName, actionName, taskTitle);
  327. break;
  328. case '<%=OTS_PT_RAW%>':
  329. OTS_PostRawPage(pKeyName, objectName, actionName, taskTitle);
  330. break;
  331. default:
  332. SA_TraceOut("OTS_OnSelectTask()", 'ISSUE: Invalid page type: ' + taskPageType );
  333. break;
  334. }
  335. }
  336. else
  337. {
  338. //alert("OTS_OnSelectTask(Single Select)");
  339. switch(taskPageType)
  340. {
  341. case '<%=OTS_PT_PROPERTY%>':
  342. case '<%=OTS_PT_TABBED_PROPERTY%>':
  343. case '<%=OTS_PT_WIZARD%>':
  344. OTS_OpenPropertyPage(pKeyName, objectName, actionName, taskTitle);
  345. break;
  346. case '<%=OTS_PT_AREA%>':
  347. OTS_OpenNormalPage(pKeyName, objectName, actionName, taskTitle);
  348. break;
  349. case '<%=OTS_PT_NEW_WINDOW%>':
  350. OTS_OpenNewPage(pKeyName, objectName, actionName, taskTitle);
  351. break;
  352. case '<%=OTS_PT_RAW%>':
  353. OTS_OpenRawPage(pKeyName, objectName, actionName, taskTitle);
  354. break;
  355. default:
  356. SA_TraceOut("OTS_OnSelectTask()", 'ISSUE: Invalid page type: ' + taskPageType );
  357. break;
  358. }
  359. }
  360. return true;
  361. }
  362. function OTS_PostPropertyPage(pKeyName, objectName, actionURL, taskTitle)
  363. {
  364. var vRoot = "<%=m_VirtualRoot%>"
  365. var sTaskURL = vRoot + "sh_taskframes.asp";
  366. var i;
  367. if ( vRoot == "" )
  368. {
  369. vRoot = "/"
  370. }
  371. var sReturnURL = top.location.href;
  372. if ( SA_GetVersion() >= 2 )
  373. {
  374. sReturnURL = OTS_MungeSearchSort(sReturnURL);
  375. }
  376. sReturnURL = SA_MungeURL(sReturnURL, "R", ""+Math.random());
  377. sTaskURL = SA_MungeURL(sTaskURL, "Title", taskTitle);
  378. sTaskURL = SA_MungeURL(sTaskURL, "URL", actionURL);
  379. sTaskURL = SA_MungeURL(sTaskURL, "ReturnURL", sReturnURL);
  380. sTaskURL = SA_MungeURL(sTaskURL, "R", ""+Math.random());
  381. document.TVData.action = sTaskURL;
  382. document.TVData.method = 'post';
  383. document.TVData.target = "";
  384. document.TVData.submit();
  385. return true;
  386. }
  387. function OTS_PostNormalPage(pKeyName, objectName, actionURL, taskTitle)
  388. {
  389. var vRoot = "<%=m_VirtualRoot%>";
  390. var sPageURL = vRoot + actionURL;
  391. var sReturnURL;
  392. var i;
  393. if ( vRoot == "" )
  394. {
  395. vRoot = "/"
  396. }
  397. sReturnURL = SA_MungeExtractURLParameter(sPageURL, "ReturnURL");
  398. if ( sReturnURL.length <= 0 )
  399. {
  400. //alert("Using default ReturnURL: " + sReturnURL);
  401. sReturnURL = top.location.href;
  402. }
  403. else
  404. {
  405. //alert("Using Task provided ReturnURL: " + sReturnURL);
  406. }
  407. if ( SA_GetVersion() >= 2 )
  408. {
  409. sReturnURL = OTS_MungeSearchSort(sReturnURL);
  410. }
  411. sReturnURL = SA_MungeURL(sReturnURL, "R", ""+Math.random());
  412. sPageURL = SA_MungeURL(sPageURL, "Title", taskTitle);
  413. sPageURL = SA_MungeURL(sPageURL, "ReturnURL", sReturnURL);
  414. sPageURL = SA_MungeURL(sPageURL, "R", ""+Math.random());
  415. //
  416. // Must disable toolbar when posting to an Area page.
  417. OTS_DisableToolbar();
  418. document.TVData.action = sPageURL;
  419. document.TVData.target = "";
  420. document.TVData.submit();
  421. return true;
  422. }
  423. function OTS_PostNewPage(pKeyName, objectName, actionURL, taskTitle)
  424. {
  425. var sPageURL;
  426. var vRoot = "<%=m_VirtualRoot%>"
  427. var i;
  428. if ( vRoot == "" )
  429. {
  430. vRoot = "/"
  431. }
  432. var sReturnURL = top.location.href;
  433. if ( SA_GetVersion() >= 2 )
  434. {
  435. sReturnURL = OTS_MungeSearchSort(sReturnURL);
  436. }
  437. sReturnURL = SA_MungeURL(sReturnURL, "R", ""+Math.random());
  438. sPageURL = vRoot + actionURL;
  439. sPageURL = SA_MungeURL(sPageURL, "Title", taskTitle);
  440. sPageURL = SA_MungeURL(sPageURL, "ReturnURL", sReturnURL);
  441. sPageURL = SA_MungeURL(sPageURL, "R", ""+Math.random());
  442. //
  443. // Must disable toolbar when posting to an Area page.
  444. OTS_DisableToolbar();
  445. document.TVData.action = sPageURL;
  446. document.TVData.target = "_blank";
  447. document.TVData.submit();
  448. // Change target back to empty value
  449. document.TVData.target = "";
  450. OTS_ResetSelections();
  451. return true;
  452. }
  453. function OTS_PostRawPage(pKeyName, objectName, actionURL, taskTitle)
  454. {
  455. var sPageURL;
  456. var vRoot = "<%=m_VirtualRoot%>"
  457. var i;
  458. if ( vRoot == "" )
  459. {
  460. vRoot = "/"
  461. }
  462. var sReturnURL = top.location.href;
  463. if ( SA_GetVersion() >= 2 )
  464. {
  465. sReturnURL = OTS_MungeSearchSort(sReturnURL);
  466. }
  467. sReturnURL = SA_MungeURL(sReturnURL, "R", ""+Math.random());
  468. sPageURL = vRoot + actionURL;
  469. sPageURL = SA_MungeURL(sPageURL, "Title", taskTitle);
  470. sPageURL = SA_MungeURL(sPageURL, "ReturnURL", sReturnURL);
  471. sPageURL = SA_MungeURL(sPageURL, "R", ""+Math.random());
  472. //
  473. // Must disable toolbar when posting to an Area page.
  474. OTS_DisableToolbar();
  475. document.TVData.action = sPageURL;
  476. document.TVData.target = "_blank";
  477. document.TVData.submit();
  478. // Change target back to empty value
  479. document.TVData.target = "";
  480. OTS_ResetSelections();
  481. return true;
  482. }
  483. function OTS_OpenPropertyPage(pKeyName, objectName, actionName, taskTitle)
  484. {
  485. var taskLink;
  486. var vRoot = "<%=m_VirtualRoot%>"
  487. var i;
  488. if ( vRoot == "" )
  489. {
  490. vRoot = "/"
  491. }
  492. if ( document.TVData.tSelectedItem.value == "" )
  493. {
  494. var e = document.TVData.elements[0];
  495. document.TVData.tSelectedItem.value = e.value;
  496. }
  497. i = actionName.indexOf('?');
  498. if (i == -1)
  499. {
  500. taskLink = actionName + "?" + tabUrl;
  501. }
  502. else
  503. {
  504. taskLink = actionName + "&" + tabUrl;
  505. }
  506. taskLink = SA_MungeURL(taskLink, pKeyName, document.TVData.tSelectedItem.value);
  507. //
  508. // Form a correct Return URL. This requires appending the PKey parameter to the
  509. // return URL.
  510. var sReturnURL = top.location.href;
  511. //
  512. // Strip off the random number query string parameter
  513. sReturnURL = SA_MungeURL(sReturnURL, "R", "");
  514. //
  515. // Strip off the previous PKey query string parameter
  516. // JK 1-16-01
  517. // Replaced following section with following line
  518. sReturnURL = SA_MungeURL(sReturnURL, pKeyName, document.TVData.tSelectedItem.value);
  519. //
  520. // Add OTS Search item and value if they are set
  521. if ( SA_GetVersion() >= 2 )
  522. {
  523. sReturnURL = OTS_MungeSearchSort(sReturnURL);
  524. }
  525. OpenPage(vRoot, taskLink, sReturnURL, taskTitle)
  526. return true;
  527. }
  528. function OTS_OpenNormalPage(pKeyName, objectName, actionName, taskTitle)
  529. {
  530. var taskLink;
  531. var vRoot = "<%=m_VirtualRoot%>"
  532. var sReturnURL
  533. var i;
  534. if ( vRoot == "" )
  535. {
  536. vRoot = "/"
  537. }
  538. if ( document.TVData.tSelectedItem.value == "" )
  539. {
  540. var e = document.TVData.elements[0];
  541. document.TVData.tSelectedItem.value = e.value;
  542. }
  543. i = actionName.indexOf('?');
  544. if (i == -1)
  545. {
  546. taskLink = actionName + "?" + tabUrl;
  547. }
  548. else
  549. {
  550. taskLink = actionName + "&" + tabUrl;
  551. }
  552. taskLink = SA_MungeURL(taskLink, pKeyName, document.TVData.tSelectedItem.value);
  553. //
  554. // Add ReturnURL param
  555. sReturnURL = SA_MungeExtractURLParameter(taskLink, "ReturnURL");
  556. //alert(sReturnURL);
  557. if ( sReturnURL.length <= 0 )
  558. {
  559. sReturnURL = top.location.href;
  560. }
  561. else
  562. {
  563. sReturnURL = unescape(sReturnURL);
  564. }
  565. //alert(sReturnURL);
  566. if ( SA_GetVersion() >= 2 )
  567. {
  568. //
  569. // Strip off the random number query string parameter
  570. sReturnURL = SA_MungeURL(sReturnURL, "R", "");
  571. sReturnURL = SA_MungeURL(sReturnURL, pKeyName, document.TVData.tSelectedItem.value);
  572. sReturnURL = OTS_MungeSearchSort(sReturnURL);
  573. taskLink = SA_MungeURL(taskLink, "ReturnURL", sReturnURL);
  574. }
  575. OpenNormalPage(vRoot, taskLink)
  576. return true;
  577. }
  578. function OTS_OpenNewPage(pKeyName, objectName, actionName, taskTitle)
  579. {
  580. var taskLink;
  581. var vRoot = "<%=m_VirtualRoot%>"
  582. var i;
  583. if ( vRoot == "" )
  584. {
  585. vRoot = "/"
  586. }
  587. if ( document.TVData.tSelectedItem.value == "" )
  588. {
  589. var e = document.TVData.elements[0];
  590. document.TVData.tSelectedItem.value = e.value;
  591. }
  592. i = actionName.indexOf('?');
  593. if (i == -1)
  594. {
  595. taskLink = actionName + "?" + tabUrl;
  596. }
  597. else
  598. {
  599. taskLink = actionName + "&" + tabUrl;
  600. }
  601. taskLink = SA_MungeURL(taskLink, pKeyName, document.TVData.tSelectedItem.value);
  602. OpenNewPage(vRoot, taskLink, "")
  603. return true;
  604. }
  605. function OTS_OpenRawPage(pKeyName, objectName, actionName, taskTitle)
  606. {
  607. OpenRawPage(actionName);
  608. return true;
  609. }
  610. function OTS_OnShowTaskDescription(description)
  611. {
  612. window.status = description;
  613. return true;
  614. }
  615. function OTS_OnMacroMultiSelect()
  616. {
  617. var nIndex;
  618. var objItemList;
  619. var objOTSForm;
  620. if ( document.forms.length <= 0 )
  621. {
  622. return;
  623. }
  624. objOTSForm = eval("document.TVData")
  625. if ( objOTSForm == null || objOTSForm.length <= 0 )
  626. {
  627. return;
  628. }
  629. objItemList = eval("document.TVData.TVItem_Table1")
  630. if ( objItemList == null || objItemList.length <= 0 )
  631. {
  632. return;
  633. }
  634. //
  635. // Only supported for multi selection OTS
  636. if (objItemList[0].type != "checkbox" ){
  637. return;
  638. }
  639. //
  640. // Two element list is special case. When we have two elements
  641. // we need to see if second is the hidden placeholder that's used
  642. // to ensure this guy is an array object.
  643. if ( objItemList.length == 2 )
  644. {
  645. var oException;
  646. objItemList[0].checked = objOTSForm.fldMacroMultiSelect.checked;
  647. try {
  648. if ( objItemList[1].value.lastIndexOf("2_RowHidden") < 0 )
  649. {
  650. objItemList[1].checked = objOTSForm.fldMacroMultiSelect.checked;
  651. }
  652. }
  653. catch(oException)
  654. {
  655. if ( SA_IsDebugEnabled() )
  656. {
  657. alert("Javascript exception in OTS_OnMacroMultiSelect. Number: " + oException.number + " Description: " + oException.description );
  658. }
  659. }
  660. OTS_UpdateTaskList();
  661. return;
  662. }
  663. //
  664. // Search the list for a matching item
  665. //
  666. for(nIndex = 0 ; nIndex < objItemList.length ; nIndex++)
  667. {
  668. objItemList[nIndex].checked = objOTSForm.fldMacroMultiSelect.checked;
  669. }
  670. OTS_UpdateTaskList();
  671. return;
  672. }
  673. function OTS_TaskObject(TaskFunctionIn)
  674. {
  675. this.TaskFunction = TaskFunctionIn;
  676. }
  677. var iTaskAny_ItemCount = 0;
  678. function OTS_TaskAny(sMessage, iTaskNo, iItemNo)
  679. {
  680. var rc = true;
  681. if ( sMessage.toLowerCase() == OTS_MESSAGE_BEGIN )
  682. {
  683. iTaskAny_ItemCount = 0;
  684. }
  685. else if ( sMessage.toLowerCase() == OTS_MESSAGE_ITEM )
  686. {
  687. //
  688. // Increment the item count
  689. iTaskAny_ItemCount += 1;
  690. //
  691. // No need to continue, we have at least one item
  692. rc = false;
  693. }
  694. else if ( sMessage.toLowerCase() == OTS_MESSAGE_END )
  695. {
  696. if ( iTaskAny_ItemCount > 0 )
  697. {
  698. OTS_SetTaskEnabled(iTaskNo, true);
  699. }
  700. else
  701. {
  702. OTS_SetTaskEnabled(iTaskNo, false);
  703. }
  704. }
  705. return rc;
  706. }
  707. var iTaskOne_ItemCount = 0;
  708. function OTS_TaskOne(sMessage, iTaskNo, iItemNo)
  709. {
  710. var rc = true;
  711. if ( sMessage.toLowerCase() == OTS_MESSAGE_BEGIN )
  712. {
  713. iTaskOne_ItemCount = 0;
  714. }
  715. else if ( sMessage.toLowerCase() == OTS_MESSAGE_ITEM )
  716. {
  717. //
  718. // Increment the item count
  719. iTaskOne_ItemCount += 1;
  720. }
  721. else if ( sMessage.toLowerCase() == OTS_MESSAGE_END )
  722. {
  723. if ( iTaskOne_ItemCount != 1 )
  724. {
  725. OTS_SetTaskEnabled(iTaskNo, false);
  726. }
  727. else
  728. {
  729. OTS_SetTaskEnabled(iTaskNo, true);
  730. }
  731. }
  732. return rc;
  733. }
  734. function OTS_TaskAlways(sMessage, iTaskNo, iItemNo)
  735. {
  736. var rc = true;
  737. if ( sMessage.toLowerCase() == OTS_MESSAGE_BEGIN )
  738. {
  739. }
  740. else if ( sMessage.toLowerCase() == OTS_MESSAGE_ITEM )
  741. {
  742. //
  743. // Don't need to see all the items
  744. rc = false;
  745. }
  746. else if ( sMessage.toLowerCase() == OTS_MESSAGE_END )
  747. {
  748. OTS_SetTaskEnabled(iTaskNo, true);
  749. }
  750. return rc;
  751. }
  752. function OTS_GetTaskObject(iTaskNo)
  753. {
  754. return window.document.getElementById("OTSTask"+iTaskNo);
  755. }
  756. function OTS_IsTaskEnabled(iTaskNo)
  757. {
  758. var rc = false;
  759. var oTask = OTS_GetTaskObject(iTaskNo);
  760. if ( oTask.className.toLowerCase().indexOf("disabled") > 0 )
  761. {
  762. rc = false;
  763. }
  764. else
  765. {
  766. rc = true;
  767. }
  768. return rc;
  769. }
  770. function OTS_OnTaskHover(iTaskNo, bEnter)
  771. {
  772. if ( OTS_IsTaskEnabled(iTaskNo) )
  773. {
  774. if ( bEnter )
  775. {
  776. OTS_SetTaskClass(iTaskNo, 'TasksTextHover');
  777. }
  778. else
  779. {
  780. OTS_SetTaskClass(iTaskNo, 'TasksText');
  781. }
  782. }
  783. else
  784. {
  785. OTS_SetTaskClass(iTaskNo, 'TasksTextDisabled');
  786. }
  787. }
  788. function OTS_SetTaskEnabled(iTaskNo, bEnabled)
  789. {
  790. if ( bEnabled == true )
  791. {
  792. OTS_SetTaskClass(iTaskNo, "TasksText");
  793. }
  794. else
  795. {
  796. OTS_SetTaskClass(iTaskNo, "TasksTextDisabled");
  797. }
  798. }
  799. function OTS_SetTaskClass(iTaskNo, sClassName)
  800. {
  801. var oTask = OTS_GetTaskObject(iTaskNo);
  802. oTask.className = sClassName;
  803. }
  804. function OTS_UpdateTaskList()
  805. {
  806. var x;
  807. var rc;
  808. var fn;
  809. var nIndex;
  810. var objItemList;
  811. var oException;
  812. objItemList = eval("document.TVData.TVItem_Table1")
  813. //alert("Entering OTS_UpdateTaskList");
  814. //
  815. // Fire messages to Task objects
  816. //
  817. for( x = 0; x < aTasks.length; x++)
  818. {
  819. //
  820. // Begin message
  821. //
  822. fn = aTasks[x].TaskFunction;
  823. fn += "('begin', "+ x + ", 0)";
  824. try {
  825. eval(fn);
  826. }catch(oException){
  827. if ( SA_IsDebugEnabled() )
  828. {
  829. alert("Error: Javascript function " + aTasks[x].TaskFunction + " does not exist." );
  830. }
  831. }
  832. //
  833. // Item selected message
  834. //
  835. if ( objItemList != null && objItemList.length > 0 )
  836. {
  837. for(nIndex = 0 ; nIndex < objItemList.length ; nIndex++)
  838. {
  839. if (objItemList[nIndex].checked == true)
  840. {
  841. fn = aTasks[x].TaskFunction;
  842. fn += "('item', "+ x + ", "+nIndex+")";
  843. try {
  844. rc = eval(fn);
  845. }catch(oException){
  846. rc = false;
  847. }
  848. if ( !rc ) break;
  849. }
  850. }
  851. }
  852. //
  853. // End message
  854. //
  855. fn = aTasks[x].TaskFunction;
  856. fn += "('end', "+ x + ", 0)";
  857. try {
  858. eval(fn);
  859. }catch(oException){
  860. }
  861. }
  862. }
  863. function OTS_ResetSelections()
  864. {
  865. var nIndex;
  866. var objItemList;
  867. var objOTSForm;
  868. var oException;
  869. if ( document.forms.length <= 0 )
  870. {
  871. OTS_UpdateTaskList();
  872. return;
  873. }
  874. objOTSForm = eval("document.TVData")
  875. if ( objOTSForm == null || objOTSForm.length <= 0 )
  876. {
  877. OTS_UpdateTaskList();
  878. return;
  879. }
  880. objItemList = eval("document.TVData.TVItem_Table1")
  881. if ( objItemList == null || objItemList.length <= 0 )
  882. {
  883. OTS_UpdateTaskList();
  884. return;
  885. }
  886. //
  887. // Only perform reset for Multi selection OTS
  888. if (objItemList[0].type != "checkbox" ){
  889. OTS_UpdateTaskList();
  890. return;
  891. }
  892. //
  893. // Unselect all items
  894. //
  895. for(nIndex = 0 ; nIndex < objItemList.length ; nIndex++)
  896. {
  897. objItemList[nIndex].checked = false;
  898. }
  899. try
  900. {
  901. objItemList = eval("document.TVData.fldMacroMultiSelect")
  902. if ( objItemList != null )
  903. {
  904. objItemList.checked = false;
  905. }
  906. }
  907. catch(oException)
  908. {
  909. }
  910. OTS_UpdateTaskList();
  911. return;
  912. }
  913. </script>
  914. </head>
  915. </html>