Source code of Windows XP (NT5)
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.

197 lines
4.9 KiB

  1. // util.js
  2. // Keycode values
  3. var KC_ESCAPE = 27; // Escape key
  4. var KC_RETURN = 13; // return key
  5. // App capability flags
  6. // (these values match the APPACTION_* values in shappmgr.idl)
  7. var APPCAP_INSTALL = 0x0001;
  8. var APPCAP_UNINSTALL = 0x0002;
  9. var APPCAP_MODIFY = 0x0004;
  10. var APPCAP_REPAIR = 0x0008;
  11. var APPCAP_UPGRADE = 0x0010;
  12. var APPCAP_CANGETSIZE = 0x0020;
  13. // var APPCAP_??? = 0x0040;
  14. var APPCAP_MODIFYREMOVE = 0x0080;
  15. var APPCAP_ADDLATER = 0x0100;
  16. var APPCAP_UNSCHEDULE = 0x0200;
  17. /*-------------------------------------------------------------------------
  18. Purpose: Apply the right styles to the expanded property table that is
  19. databound.
  20. */
  21. function ApplyExtraStyles(tblElem, bFocus)
  22. {
  23. var szFocusClass;
  24. if (bFocus)
  25. szFocusClass = "Focus";
  26. else
  27. szFocusClass = "";
  28. // Apply the selection class to the extended property table
  29. // that is inserted by databinding.
  30. // NOTE: there's something to keep in mind here. When Trident
  31. // databinds this span, the inserted table wipes out any class
  32. // settings that we may set to the existing table. This means
  33. // that this function may be called and the class set, and then
  34. // the whole table is wiped away by a fresh new table (inserted
  35. // by the databound span element). The end result is you don't
  36. // see the effects you want.
  37. //
  38. // Currently, the work-around is to make sure the inserted table
  39. // has the class already set. This requires the DSO to provide
  40. // that class name.
  41. var tblProps = tblElem.all('idTblExtendedProps');
  42. if (tblProps)
  43. {
  44. tblProps.className = szFocusClass;
  45. }
  46. // Set the right styles for the anchors
  47. var rganchor = tblElem.all.tags("A");
  48. var canchor = rganchor.length;
  49. for (i = 0; i < canchor; i++)
  50. {
  51. rganchor[i].className = szFocusClass;
  52. }
  53. }
  54. /*-------------------------------------------------------------------------
  55. Purpose: Return the control given the named string
  56. */
  57. function Dso_GetCtl(szDso)
  58. {
  59. return g_docAll.idCtlAppsDso;
  60. /* Fake version
  61. var ctl = null;
  62. switch (szDso)
  63. {
  64. case "Remove":
  65. ctl = g_docAll.idCtlRemoveApps;
  66. break;
  67. case "Add":
  68. ctl = g_docAll.idCtlAddApps;
  69. break;
  70. case "Categories":
  71. ctl = g_docAll.idCtlCategory;
  72. break;
  73. case "ocsetup":
  74. ctl = g_docAll.idCtlOcsetup;
  75. break;
  76. }
  77. return ctl;
  78. */
  79. }
  80. /*-------------------------------------------------------------------------
  81. Purpose: Retrieves the recordset of the given DSO.
  82. */
  83. function Dso_GetRecordset(szDso)
  84. {
  85. return g_docAll.idCtlAppsDso.namedRecordset(szDso);
  86. /* Fake version
  87. var ctl = Dso_GetCtl(szDso);
  88. return ctl.recordset;
  89. */
  90. }
  91. /*-------------------------------------------------------------------------
  92. Purpose: Sorts the given DSO.
  93. */
  94. function Dso_Sort(szDso, szKey)
  95. {
  96. g_docAll.idCtlAppsDso.Sort = szKey;
  97. g_docAll.idCtlAppsDso.Reset(szDso);
  98. /* Fake version
  99. var ctl = Dso_GetCtl(szDso);
  100. ctl.Sort = szKey;
  101. ctl.Reset();
  102. */
  103. }
  104. /*-------------------------------------------------------------------------
  105. Purpose: Filters the given DSO.
  106. */
  107. function Dso_Filter(szDso, szFilter)
  108. {
  109. g_docAll.idCtlAppsDso.Category = szFilter;
  110. g_docAll.idCtlAppsDso.Reset(szDso);
  111. /* Fake version
  112. var ctl = Dso_GetCtl(szDso);
  113. ctl.Filter = "cat_id = " + szFilter;
  114. ctl.Reset();
  115. */
  116. }
  117. /*-------------------------------------------------------------------------
  118. Purpose: Set the feedback for the add page
  119. */
  120. function _SetPubWaitingFeedback()
  121. {
  122. // set the feedback in the addpage.
  123. var L_RetrievingApps_Text = "Searching the network for available programs...";
  124. g_docAll.idAddListbox.feedBack = L_RetrievingApps_Text;
  125. }
  126. /*-------------------------------------------------------------------------
  127. Purpose: Triggers the DSO to refresh (reenumerate list and so on)
  128. */
  129. function Dso_Refresh(szDso)
  130. {
  131. g_docAll.idCtlAppsDso.Dirty = true;
  132. if ("Add" == szDso)
  133. _SetPubWaitingFeedback();
  134. g_docAll.idCtlAppsDso.Reset(szDso); // Now reenumerate
  135. /* Fake version
  136. var ctl = Dso_GetCtl(szDso);
  137. // Reset the enumarea to itself, this will make the list dirty
  138. ctl.DataURL = ctl.DataURL;
  139. ctl.Reset(); // Now reenumerate
  140. */
  141. }
  142. /*-------------------------------------------------------------------------
  143. Purpose: Set the feedBack property on the given listbox control if
  144. the dataset is empty.
  145. */
  146. function Dso_FeedbackIfEmpty(szDso, idListbox, szEmptyFeedback)
  147. {
  148. // If there is no record available, show the user. Otherwise,
  149. // set the feedback feature to nothing.
  150. var rs = Dso_GetRecordset(szDso);
  151. if (rs && rs.state != 0 && rs.RecordCount > 0)
  152. idListbox.feedBack = "";
  153. else
  154. idListbox.feedBack = szEmptyFeedback;
  155. }