util.js
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 5k
Category:

Windows Kernel

Development Platform:

Visual C++

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