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.

192 lines
5.7 KiB

  1. function LoadWrapperParams(oSEMgr)
  2. {
  3. var regBase = g_NAVBAR.GetSearchEngineConfig();
  4. // Load the number of results
  5. var iNumResults = parseInt( pchealth.RegRead( regBase + "NumResults" ) );
  6. if(isNaN( iNumResults ) == false && iNumResults >= 0)
  7. {
  8. oSEMgr.NumResult = iNumResults;
  9. }
  10. else
  11. {
  12. if (pchealth.UserSettings.IsDesktopVersion)
  13. oSEMgr.NumResult = 15;
  14. else
  15. oSEMgr.NumResult = 50;
  16. }
  17. // Load the number of results
  18. if(pchealth.RegRead( regBase + "SearchHighlight" ) == "false")
  19. {
  20. g_NAVBAR.g_SearchHighlight = false;
  21. }
  22. else
  23. {
  24. g_NAVBAR.g_SearchHighlight = true;
  25. }
  26. // Initialize search eng and get data
  27. var g_oEnumEngine = oSEMgr.EnumEngine();
  28. for(var oEnumEngine = new Enumerator(g_oEnumEngine); !oEnumEngine.atEnd(); oEnumEngine.moveNext())
  29. {
  30. var oSearchEng = oEnumEngine.item();
  31. // Load enable flag
  32. var strBoolean = pchealth.RegRead( regBase + oSearchEng.ID + "\\" + "Enabled");
  33. if ((strBoolean) && (strBoolean.toLowerCase() == "false"))
  34. oSearchEng.Enabled = false;
  35. else
  36. oSearchEng.Enabled = true;
  37. // Loop through all the variables
  38. for(var v = new Enumerator(oSearchEng.Param()); !v.atEnd(); v.moveNext())
  39. {
  40. oParamItem = v.item();
  41. // If parameter is not visible, skip
  42. if (oParamItem.Visible == true)
  43. {
  44. try
  45. {
  46. var strParamName = oParamItem.Name;
  47. // Read the value from the registry
  48. var vValue = pchealth.RegRead( regBase + oSearchEng.ID + "\\" + strParamName );
  49. // Load it into the wrapper
  50. if(vValue)
  51. {
  52. var Type = oParamItem.Type;
  53. // if boolean value
  54. if (Type == pchealth.PARAM_BOOL)
  55. {
  56. if (vValue.toLowerCase() == "true")
  57. oSearchEng.AddParam(strParamName, true);
  58. else
  59. oSearchEng.AddParam(strParamName, false);
  60. }
  61. // if floating numbers
  62. else if (Type == pchealth.PARAM_R4 || // float
  63. Type == pchealth.PARAM_R8 ) // double
  64. {
  65. oSearchEng.AddParam(strParamName, parseFloat(vValue));
  66. }
  67. // if integer numbers
  68. else if (Type == pchealth.PARAM_UI1 || // Byte
  69. Type == pchealth.PARAM_I2 || // Short
  70. Type == pchealth.PARAM_I4 || // long
  71. Type == pchealth.PARAM_INT || // int
  72. Type == pchealth.PARAM_UI2 || // unsigned short
  73. Type == pchealth.PARAM_UI4 || // unsigned long
  74. Type == pchealth.PARAM_UINT) // unsigned int
  75. {
  76. oSearchEng.AddParam(strParamName, parseInt(vValue));
  77. }
  78. else if(Type == pchealth.PARAM_LIST)
  79. {
  80. LoadListItemToDisplay(oSearchEng, oParamItem.Data, strParamName, vValue);
  81. }
  82. // if date, string, selection, etc
  83. else
  84. {
  85. oSearchEng.AddParam(strParamName, vValue);
  86. }
  87. }
  88. else
  89. {
  90. if(oParamItem.Type == pchealth.PARAM_LIST)
  91. {
  92. LoadListItemToDisplay(oSearchEng, oParamItem.Data, strParamName, "");
  93. }
  94. }
  95. }
  96. catch(e)
  97. { ; }
  98. }
  99. }
  100. }
  101. }
  102. function SaveWrapperParams(wrapperID, strParamName, vValue)
  103. {
  104. var reg = g_NAVBAR.GetSearchEngineConfig();
  105. if(wrapperID != "") reg += wrapperID + "\\";
  106. pchealth.RegWrite( reg + strParamName, vValue );
  107. }
  108. function LoadListItemToDisplay(oWrapper, strXML, strParameterName, strPrevValue)
  109. {
  110. try
  111. {
  112. var strDefaultItemValue = "";
  113. // Load the xml file
  114. var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
  115. xmldoc.async = false;
  116. xmldoc.loadXML(strXML);
  117. // Generate each item
  118. var ElemList = xmldoc.getElementsByTagName("PARAM_VALUE");
  119. for (var i=0; i < ElemList.length; i++)
  120. {
  121. var strItemValue = ElemList.item(i).getAttribute("VALUE");
  122. var strDisplay = ElemList.item(i).getElementsByTagName("DISPLAYSTRING").item(0).text;
  123. var strDefault = ElemList.item(i).getAttribute("DEFAULT");
  124. if(strDefault == null) strDefault = "";
  125. strItemValue = pchealth.TextHelpers.QuoteEscape( strItemValue, "'" );
  126. // Restore the previous value
  127. if ((!strPrevValue) || (strPrevValue == ""))
  128. {
  129. // Check if default value
  130. if(strDefault.toLowerCase() == "true")
  131. {
  132. // set the default value so that the search wrapper gets this value
  133. oWrapper.AddParam( strParameterName, strItemValue );
  134. return;
  135. }
  136. }
  137. else
  138. {
  139. // Check for previous value
  140. if(strPrevValue == strItemValue)
  141. {
  142. // set the prev value so that the search wrapper gets this value
  143. oWrapper.AddParam( strParameterName, strItemValue );
  144. return;
  145. }
  146. else
  147. {
  148. if(strDefault.toLowerCase() == "true")
  149. {
  150. strDefaultItemValue = strItemValue;
  151. }
  152. }
  153. }
  154. }
  155. // Either add the default value or the first item in the list
  156. if(strDefaultItemValue.length > 0)
  157. {
  158. // set the default value so that the search wrapper gets this value
  159. oWrapper.AddParam( strParameterName, strDefaultItemValue );
  160. }
  161. // Add the first item in the list to wrapper because no default value is present and no prev value is present
  162. else if(ElemList.length > 0)
  163. {
  164. oWrapper.AddParam( strParameterName, ElemList.item(0).getAttribute("VALUE") );
  165. }
  166. }
  167. catch(e)
  168. {
  169. }
  170. }