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.

596 lines
17 KiB

  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  2. <!--------------------------------------------------------------------------
  3. //
  4. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  5. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  6. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  7. // PARTICULAR PURPOSE.
  8. //
  9. // Copyright 1998-1999 Microsoft Corporation. All Rights Reserved.
  10. //
  11. // PROGRAM: CiDHtml.htm
  12. //
  13. // PURPOSE: Illustrates use of Dynamic HTML to build a client-side
  14. // query page used to access Indexing Service.
  15. //
  16. // PLATFORM: Windows 2000
  17. //
  18. //-------------------------------------------------------------------------->
  19. <HTML>
  20. <HEAD>
  21. <TITLE>Indexing Service Dynamic HTML Sample</TITLE>
  22. <META NAME="DESCRIPTION" CONTENT="Indexing Service client-side query form">
  23. <META NAME="AUTHOR" CONTENT="Indexing Service Team">
  24. <META NAME="KEYWORDS" CONTENT="Indexing Service, query, content, hit">
  25. <META NAME="SUBJECT" CONTENT="Sample form">
  26. <META NAME="MS.CATEGORY" CONTENT="Internet">
  27. <META NAME="MS.LOCALE" CONTENT="EN-US">
  28. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
  29. <base target="_blank">
  30. </HEAD>
  31. <BODY OnLoad="Init()" LANGUAGE="VBScript">
  32. <center>
  33. <DIV ID="idTransDiv"
  34. ALIGN=CENTER
  35. STYLE="position:0; top:0; height:0; width:500; filter:revealTrans(duration=3.0, transition=5);">
  36. <H2 id="idHead" STYLE="position:0; visibility:visible; margin-bottom:0;">
  37. <font color=Blue>
  38. Indexing&nbsp;Service Query&nbsp;Form
  39. </font></H2>
  40. </DIV>
  41. </center>
  42. <br>
  43. <!-- This table contains the user-entry form. -->
  44. <div align=center>
  45. <TABLE bgcolor=ffffcc cellpadding=2 cellspacing=3 Border=3 WIDTH=400>
  46. <TR><td>
  47. <div id="QueryHeader"><b><LABEL FOR=SrchStrCtrl NAME="UserSearchString">Enter your free text query below:</LABEL></b></div>
  48. <INPUT ID="SrchStrCtrl" TYPE="TEXT" NAME="UserSearchString" SIZE="50" MAXLENGTH="100" TABINDEX=1>&nbsp;
  49. <BUTTON TYPE=SUBMIT ID="CmdGo">&nbsp;<FONT SIZE=-1>Search</FONT>&nbsp;</BUTTON>&nbsp;<br>
  50. <INPUT TYPE="RADIO" ID = StdQryButton NAME="radioQueryType" VALUE="0" checked onclick="StandardSelected()">
  51. <LABEL FOR=StdQryButton> Standard query (free text) </LABEL> <br>
  52. <INPUT TYPE="RADIO" ID = AdvQryButton NAME="radioQueryType" VALUE="1" onclick="AdvancedSelected()">
  53. <LABEL FOR=AdvQryButton> Advanced query </LABEL> <br>
  54. <div align=right> <A HREF="ixqlang.htm" target=_self>Tips for searching</A></div>
  55. <LABEL FOR=SortCtrl> <b>Sort by: </b> </LABEL> <SELECT ID = SortCtrl NAME="selectSort" onchange="SortOrderSelected()">
  56. <OPTION SELECTED VALUE="Rank"> Rank
  57. <OPTION VALUE="DocTitle">Title
  58. <OPTION VALUE="Path">Path
  59. <OPTION VALUE="Size">Size
  60. <OPTION VALUE="Write">Date
  61. </SELECT>
  62. <LABEL FOR=OrderCtrl> <b>Order by: </b> </LABEL>
  63. <SELECT ID = OrderCtrl NAME="selectOrder" onchange="SortOrderSelected()">
  64. <OPTION SELECTED VALUE="[d]"> Descending
  65. <OPTION VALUE="[a]">Ascending
  66. </SELECT>
  67. <P><table ID=idUnfiltered cellspacing=0 cellpadding=0><tr><td> To see a list of unfiltered documents click:&nbsp;
  68. </td><td id="UnfilteredRequest" onmouseover="mouseoverUnfiltered()" onmouseout="mouseoutUnfiltered()" onclick="UnfilteredSelected()" bgcolor=ffffcc><FONT color=blue><u> Unfiltered Docs</u></FONT></td></a></tr></table>
  69. </TD></TR>
  70. </TABLE>
  71. <p>
  72. <HR WIDTH=80% ALIGN=center SIZE=3>
  73. <p>
  74. <!-- A couple of navigation buttons, initially disabled. -->
  75. <a id=JumpPoint name="ResultPart"></a>
  76. <table width=775 ID=TopButt>
  77. <tr><td>
  78. <FORM NAME=Navigation ALIGN=RIGHT>
  79. <INPUT TYPE="BUTTON" NAME="CmdPrevious" VALUE="Previous">
  80. <INPUT TYPE="BUTTON" NAME="CmdNext" VALUE="Next">
  81. </FORM>
  82. <BR>
  83. <P ID=Counter><EM>No results</EM>
  84. <BR>
  85. <!--
  86. -- This is the output table. Result rows will by dynamically added, but the header will
  87. -- just be hidden until needed.
  88. -->
  89. </td></td>
  90. </table>
  91. <!-- <br><INPUT TYPE="BUTTON" NAME="SortRank" VALUE="Sort by Ascending Rank"> -->
  92. <P>
  93. <TABLE bgcolor=ffffcc ID=Results COLS=3 CELLSPACING=1 CELLPADDING=3>
  94. <TR bgcolor=99cccc>
  95. <TH>#</TH>
  96. <TH>Title</TH>
  97. <TH>Size</TH>
  98. <TH>Modified</TH>
  99. <TH>Path</TH>
  100. </TR>
  101. </TABLE>
  102. <table width=775 ID=BottomButt>
  103. <tr><td>
  104. <br><br>
  105. <FORM NAME=Navigation2 ALIGN=RIGHT>
  106. <INPUT TYPE="BUTTON" NAME="CmdPrevious" VALUE="Previous">
  107. <INPUT TYPE="BUTTON" NAME="CmdNext" VALUE="Next">
  108. </FORM>
  109. </td></tr>
  110. </table>
  111. </BODY>
  112. <SCRIPT LANGUAGE=VBSCRIPT>
  113. DIM RS ' The ADO Recordset. Initially null.
  114. DIM SortBy ' Current sort order
  115. DIM FirstOnPage, LastOnPage ' Keeps track of records being shown
  116. DIM MaxDisplayed ' Max number of results displayed on-screen
  117. DIM machine,catalog
  118. DIM OrigLocation
  119. DIM fUnfiltered ' Unfiltered query was requested.
  120. DIM fFreetext ' Free text query was requested
  121. '
  122. ' SubRoutine: Init
  123. '
  124. ' Synopsis: Initializes the page. Sets defaults for page-global variables
  125. ' and DHTML elements. Initially, no query is active.
  126. '
  127. Private SUB Init()
  128. ' Make the heading roll into view
  129. ' idHead.style.visibility = "hidden"
  130. ' idTransDiv.filters.item(0).apply()
  131. ' idTransDiv.filters.item(0).transition = 3
  132. ' idHead.style.visibility = "visible"
  133. ' idTransDiv.filters(0).play(1.000)
  134. UserSearchString.focus
  135. Navigation.CmdPrevious.Disabled = TRUE
  136. Navigation.CmdNext.Disabled = TRUE
  137. Navigation2.CmdPrevious.Disabled = TRUE
  138. Navigation2.CmdNext.Disabled = TRUE
  139. FirstOnPage = 0
  140. LastOnPage = 0
  141. MaxDisplayed = 25
  142. fUnfiltered = FALSE
  143. SortBy = "Rank[d]"
  144. 'Parse the catalog name out of the URL
  145. 'No need to localize "catalog", "machine" because they are hidden
  146. 'from the user.
  147. 'URL syntax is: file://<syspath>/help/ciquery.htm#machine=<machine>,catalog=<catalog>
  148. 'catPos = InStr(1, Document.Location.Hash, "catalog=", 1)
  149. 'catPos = catPos + 8
  150. 'catalog name is at the end of the string
  151. 'catalog = Right(Document.Location.Hash, len(Document.Location.Hash) - catPos + 1)
  152. 'Parse the machine name out of the URL
  153. 'macPos = InStr(1, Document.Location.Hash, "machine=", 1)
  154. 'macPos = macPos + 8
  155. 'machine name is between "machine=" and ",catalog="
  156. 'commaPos = InStr(macPos, Document.Location.Hash, ",catalog", 1)
  157. 'machine = Mid(Document.Location.Hash, macPos, commaPos - macPos)
  158. 'Check the state of buttons and init accordingly
  159. IF StdQryButton.Checked THEN
  160. call StandardSelected
  161. ELSE
  162. call AdvancedSelected
  163. end if
  164. HideTable()
  165. HideBottomButt()
  166. END SUB
  167. Const L_Freetext_Text="<LABEL FOR=SrchStrCtrl> <b>Enter your free text query below:</b> </LABEL>"
  168. Const L_Advanced_Text="<LABEL FOR=SrchStrCtrl> <b>Enter your advanced query below:</b> </LABEL>"
  169. '
  170. ' SubRoutine: StandardSelected()
  171. '
  172. ' Synopsis: Queries will be free-text
  173. '
  174. Private SUB StandardSelected()
  175. Document.All.QueryHeader.innerHTML = CStr(L_Freetext_Text)
  176. fFreetext = TRUE
  177. END SUB
  178. '
  179. ' SubRoutine: AdvancedSelected
  180. '
  181. ' Synopsis: Allows for advanced queries to be executed
  182. '
  183. Private SUB AdvancedSelected()
  184. Document.All.QueryHeader.innerHTML = CStr(L_Advanced_Text)
  185. fFreetext = FALSE
  186. END SUB
  187. '
  188. ' SubRoutine: mouseoverUnfiltered
  189. '
  190. ' Synopsis: Hilights the Unfiltered Docs cell
  191. '
  192. Private SUB mouseoverUnfiltered()
  193. UnfilteredRequest.bgcolor = "99cccc"
  194. END SUB
  195. '
  196. ' SubRoutine: mouseoutUnfiltered()
  197. '
  198. ' Synopsis: Un-hilights the Unfiltered Docs cell back to the original color
  199. '
  200. Private SUB mouseoutUnfiltered()
  201. UnfilteredRequest.bgcolor = "ffffcc"
  202. END SUB
  203. '
  204. ' SubRoutine: UnfilteredSelected()
  205. '
  206. ' Synopsis: Searches for unfiltered documents
  207. '
  208. Private SUB UnfilteredSelected()
  209. fUnfiltered = TRUE
  210. CmdGo_OnClick()
  211. END SUB
  212. '
  213. ' SubRoutine: SortOrderSelected()
  214. '
  215. ' Synopsis: Sets the sort order as selected by the user
  216. '
  217. Private SUB SortOrderSelected()
  218. IF StrComp(selectSort.value, "DocTitle") = 0 THEN
  219. SortBy = selectSort.value & selectOrder.value & ",Filename" & selectOrder.value
  220. ELSE
  221. SortBy = selectSort.value & selectOrder.value
  222. END IF
  223. END SUB
  224. '
  225. ' SubRoutine: CmdNext_OnClick()
  226. '
  227. ' Synposis: Displays next page of query results.
  228. '
  229. Private SUB CmdNext_OnClick()
  230. NextPage()
  231. END SUB
  232. '
  233. ' SubRoutine: CmdPrevious_OnClick()
  234. '
  235. ' Synposis: Displays previous page of query results.
  236. '
  237. Private SUB CmdPrevious_OnClick()
  238. RS.Move( -MaxDisplayed - LastOnPage + FirstOnPage )
  239. NextPage()
  240. END SUB
  241. Const L_Creation_Status_Text="Creating query object..."
  242. Const L_Issuing_Status_Text="Issuing query..."
  243. '
  244. ' SubRoutine: CmdGo_OnClick
  245. '
  246. ' Synopsis: Executes query
  247. '
  248. Private SUB CmdGo_OnClick()
  249. ON ERROR RESUME NEXT
  250. '
  251. ' Setup Query
  252. '
  253. Window.Status = L_Creation_Status_Text
  254. SET Q = CreateObject("ixsso.Query")
  255. Q.DefineColumn "Unfiltered(DBTYPE_BOOL, 1) = 49691c90-7e17-101a-a91c-08002b2ecda9 7"
  256. ' use the default catalog
  257. 'Q.Catalog = "query://"+ machine + "/" + catalog
  258. Q.SortBy = SortBy
  259. Q.Columns = "DocTitle, FileName, Path, Write, Size"
  260. Q.Dialect = 2
  261. '
  262. ' The default use of the query form should be completely freetext.
  263. ' Advanced users can then use all of the features of the query language
  264. ' by having the check boxed checked.
  265. '
  266. IF fUnfiltered THEN
  267. CompSearch = "@Unfiltered=TRUE"
  268. fUnfiltered = FALSE
  269. 'ELSEIF Advanced.Checked THEN
  270. ELSEIF fFreetext = TRUE THEN
  271. CompSearch = "{freetext}" & UserSearchString.value & "{/freetext}"
  272. ELSE
  273. CompSearch = UserSearchString.value
  274. END IF
  275. '
  276. ' The query is now set up. Time to execute.
  277. '
  278. IF CompSearch <> "" THEN
  279. Q.Query = CompSearch
  280. ' Issue query
  281. Window.Status = L_Issuing_Status_Text
  282. set RS = Q.CreateRecordSet("nonsequential")
  283. Navigation.CmdPrevious.Disabled = TRUE
  284. Navigation.CmdNext.Disabled = TRUE
  285. Navigation2.CmdPrevious.Disabled = TRUE
  286. Navigation2.CmdNext.Disabled = TRUE
  287. HideBottomButt()
  288. IF Err.Number = 0 THEN
  289. NextPage()
  290. ELSE
  291. ReportError Err.Number, Err.Description
  292. Err.Clear()
  293. END IF
  294. END IF
  295. END SUB
  296. '
  297. ' SubRoutine: NextPage
  298. '
  299. ' Synopsis: Workhorse routine to populate table with results
  300. '
  301. Const L_QueryMatched_Text="Query matched "
  302. Const L_Records_Text=" record(s)"
  303. Const L_NoResults_Text="<EM>No results</EM>"
  304. Const L_NoResults_Text_NoEm="No results"
  305. Const L_PopulatingList_Text="Populating result list (row "
  306. Const L_Of_Text=" of "
  307. Const L_ShowingRecords_Text=" record(s). Now showing "
  308. Const L_To_Text=" to "
  309. Private SUB NextPage
  310. '
  311. ' Populate result list. Once this message is displayed, virtually all the time is being
  312. ' spent in DHTML and not in query processing.
  313. '
  314. fFirstPage = TRUE
  315. '
  316. ' Did we actually get anything back?
  317. '
  318. IF RS.RecordCount = 0 THEN
  319. IF Err.Number = 0 THEN
  320. Document.All.Counter.innerHTML = CStr(L_NoResults_Text)
  321. Window.Status = CStr(L_NoResults_Text_NoEm)
  322. MsgBox CStr(L_NoResults_Text_NoEm)
  323. ELSE
  324. ReportError Err.Number, Err.Description
  325. END IF
  326. JumpPoint.scrollintoview ( FALSE )
  327. FirstOnPage = 0
  328. Navigation.CmdNext.Disabled = TRUE
  329. Navigation.CmdPrevious.Disabled = TRUE
  330. Navigation2.CmdPrevious.Disabled = TRUE
  331. Navigation2.CmdNext.Disabled = TRUE
  332. HideBottomButt()
  333. HideTable()
  334. ELSE
  335. JumpPoint.scrollintoview ( TRUE )
  336. FirstOnPage = RS.AbsolutePosition
  337. LastOnPage = FirstOnPage
  338. Document.All.Counter.innerText = CStr(L_QueryMatched_Text) + CStr(RS.RecordCount) + CStr(L_Records_Text)
  339. ShowTable()
  340. END IF
  341. '
  342. ' Loop through the table. For each row, either store values from Recordset or delete
  343. ' the row.
  344. '
  345. FOR i = 1 TO MaxDisplayed
  346. Window.Status = CStr(L_PopulatingList_Text) + CStr(i) + CStr(L_Of_Text) + Cstr(MaxDisplayed) + ")"
  347. IF RS.EOF THEN
  348. '
  349. ' We hit the end. Just clear any remaining rows and fall out of loop.
  350. '
  351. FOR j = Results.Rows.length - 1 TO i STEP -1
  352. Results.DeleteRow(j)
  353. NEXT
  354. EXIT FOR
  355. ELSE
  356. '
  357. ' We may have to add a row...
  358. '
  359. IF i >= Results.Rows.length THEN
  360. Results.InsertRow()
  361. FOR j = 0 TO 4
  362. Results.Rows(i).InsertCell()
  363. NEXT
  364. Results.Rows(i).Cells(0).align = "right"
  365. Results.Rows(i).Cells(2).align = "right"
  366. Results.Rows(i).Cells(3).align = "right"
  367. END IF
  368. ' Write record number
  369. Results.Rows(i).Cells(0).innerText = CStr( RS.AbsolutePosition ) + "."
  370. ' Write either title or filename
  371. IF VarType(RS("DocTitle")) = 1 Or RS("DocTitle") = "" THEN
  372. Results.Rows(i).Cells(1).innerHTML = "<A HREF=""file://" & RS("path") & """>" & RS("filename") & "</A>"
  373. ELSE
  374. Results.Rows(i).Cells(1).innerHTML = "<A HREF=""file://" & RS("path") & """>" & RS("DocTitle") & "</A>"
  375. END IF
  376. ' Size
  377. Results.Rows(i).Cells(2).innerText = RS("Size")
  378. ' Last Modify time
  379. WriteTime = CDate( RS("Write") )
  380. Results.Rows(i).Cells(3).innerText = CStr(Month(WriteTime)) + "-" + CStr(Day(WriteTime)) + "-" + CStr(Year(WriteTime) ) + " "
  381. ' Path
  382. Results.Rows(i).Cells(4).innerHTML = "<A HREF=""file://" & RS("path") & """>" & RS("Path") & "</A>"
  383. LastOnPage = LastOnPage + 1
  384. RS.MoveNext
  385. END IF
  386. NEXT
  387. '
  388. ' Report result.
  389. '
  390. IF FirstOnPage <> LastOnPage And RS.RecordCount <> 0 THEN
  391. Document.All.Counter.innerHTML = CStr(L_QueryMatched_Text) + CStr(RS.RecordCount) + CStr(L_ShowingRecords_Text) + CStr(FirstOnPage) + CStr(L_To_Text) + CStr(LastOnPage-1) + "."
  392. END IF
  393. '
  394. ' Enable Previous/Next as appropriate
  395. '
  396. IF FirstOnPage <= 1 THEN
  397. Navigation.CmdPrevious.Disabled = TRUE
  398. Navigation2.CmdPrevious.Disabled = TRUE
  399. ELSE
  400. Navigation.CmdPrevious.Disabled = FALSE
  401. Navigation2.CmdPrevious.Disabled = FALSE
  402. END IF
  403. IF RS.EOF THEN
  404. Navigation.CmdNext.Disabled = TRUE
  405. Navigation2.CmdNext.Disabled = TRUE
  406. UserSearchString.focus
  407. ELSE
  408. Navigation.CmdNext.Disabled = FALSE
  409. Navigation.CmdNext.focus
  410. Navigation2.CmdNext.Disabled = FALSE
  411. END IF
  412. IF Navigation2.CmdPrevious.Disabled = FALSE OR Navigation2.CmdNext.Disabled = FALSE THEN
  413. ShowBottomButt()
  414. END IF
  415. '
  416. ' Done!
  417. '
  418. Window.Status = Window.DefaultStatus
  419. END SUB
  420. '
  421. ' SubRoutine: HideBottomButt
  422. '
  423. ' Synopsis: Hides the bottom button table from the user's view.
  424. '
  425. SUB HideBottomButt()
  426. BottomButt.Rows(0).Cells(0).style.visibility = "hidden"
  427. BottomButt.Border = 0
  428. BottomButt.Rules = ""
  429. FOR i = BottomButt.Rows.length - 1 TO 1 STEP -1
  430. BottomButt.DeleteRow(i)
  431. NEXT
  432. END SUB
  433. '
  434. ' SubRoutine: ShowBottomButt
  435. '
  436. ' Synopsis: Shows the bottom button table from the user's view.
  437. '
  438. SUB ShowBottomButt()
  439. BottomButt.Rows(0).Cells(0).style.visibility = "visible"
  440. BottomButt.Border = 0
  441. BottomButt.Rules = ""
  442. END SUB
  443. '
  444. ' SubRoutine: HideTable
  445. '
  446. ' Synopsis: Hides the table from the user's view.
  447. '
  448. SUB HideTable()
  449. Results.Rows(0).Cells(0).style.visibility = "hidden"
  450. Results.Rows(0).Cells(1).style.visibility = "hidden"
  451. Results.Rows(0).Cells(2).style.visibility = "hidden"
  452. Results.Rows(0).Cells(3).style.visibility = "hidden"
  453. Results.Rows(0).Cells(4).style.visibility = "hidden"
  454. Results.Border = 0
  455. Results.Rules = ""
  456. FOR i = Results.Rows.length - 1 TO 1 STEP -1
  457. Results.DeleteRow(i)
  458. NEXT
  459. END SUB
  460. '
  461. ' SubRoutine: ShowTable
  462. '
  463. ' Synopsis: Makes the result table visible.
  464. '
  465. SUB ShowTable()
  466. Results.Rows(0).Cells(0).style.visibility = "visible"
  467. Results.Rows(0).Cells(1).style.visibility = "visible"
  468. Results.Rows(0).Cells(2).style.visibility = "visible"
  469. Results.Rows(0).Cells(3).style.visibility = "visible"
  470. Results.Rows(0).Cells(4).style.visibility = "visible"
  471. Results.Border = 1
  472. Results.Rules = "cols"
  473. END SUB
  474. '
  475. ' SubRoutine: ReportError
  476. '
  477. ' Synopsis: Clears table and reports error.
  478. '
  479. ' Arguments: [ErrNo] -- Error to report
  480. '
  481. Const L_RedError_Text="<FONT color=red><EM><B>Error "
  482. SUB ReportError( ErrNo, ErrDesc )
  483. HideTable()
  484. Window.Status = Err.Description
  485. MsgBox Err.Description
  486. UserSearchString.focus
  487. Document.All.Counter.innerHTML = CStr(L_RedError_Text) + Hex(Err.Number) + " - " + Err.Description + "</B></EM></FONT>"
  488. END SUB
  489. </SCRIPT>
  490. </HTML>