search.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. /*
  2. @licstart The following is the entire license notice for the JavaScript code in this file.
  3. The MIT License (MIT)
  4. Copyright (C) 1997-2020 by Dimitri van Heesch
  5. Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  6. and associated documentation files (the "Software"), to deal in the Software without restriction,
  7. including without limitation the rights to use, copy, modify, merge, publish, distribute,
  8. sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all copies or
  11. substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  13. BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15. DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. @licend The above is the entire license notice for the JavaScript code in this file
  18. */
  19. function convertToId(search)
  20. {
  21. var result = '';
  22. for (i=0;i<search.length;i++)
  23. {
  24. var c = search.charAt(i);
  25. var cn = c.charCodeAt(0);
  26. if (c.match(/[a-z0-9\u0080-\uFFFF]/))
  27. {
  28. result+=c;
  29. }
  30. else if (cn<16)
  31. {
  32. result+="_0"+cn.toString(16);
  33. }
  34. else
  35. {
  36. result+="_"+cn.toString(16);
  37. }
  38. }
  39. return result;
  40. }
  41. function getXPos(item)
  42. {
  43. var x = 0;
  44. if (item.offsetWidth)
  45. {
  46. while (item && item!=document.body)
  47. {
  48. x += item.offsetLeft;
  49. item = item.offsetParent;
  50. }
  51. }
  52. return x;
  53. }
  54. function getYPos(item)
  55. {
  56. var y = 0;
  57. if (item.offsetWidth)
  58. {
  59. while (item && item!=document.body)
  60. {
  61. y += item.offsetTop;
  62. item = item.offsetParent;
  63. }
  64. }
  65. return y;
  66. }
  67. /* A class handling everything associated with the search panel.
  68. Parameters:
  69. name - The name of the global variable that will be
  70. storing this instance. Is needed to be able to set timeouts.
  71. resultPath - path to use for external files
  72. */
  73. function SearchBox(name, resultsPath, label, extension)
  74. {
  75. if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); }
  76. if (!extension || extension == "") { extension = ".html"; }
  77. // ---------- Instance variables
  78. this.name = name;
  79. this.resultsPath = resultsPath;
  80. this.keyTimeout = 0;
  81. this.keyTimeoutLength = 500;
  82. this.closeSelectionTimeout = 300;
  83. this.lastSearchValue = "";
  84. this.lastResultsPage = "";
  85. this.hideTimeout = 0;
  86. this.searchIndex = 0;
  87. this.searchActive = false;
  88. this.searchLabel = label;
  89. this.extension = extension;
  90. // ----------- DOM Elements
  91. this.DOMSearchField = function()
  92. { return document.getElementById("MSearchField"); }
  93. this.DOMSearchSelect = function()
  94. { return document.getElementById("MSearchSelect"); }
  95. this.DOMSearchSelectWindow = function()
  96. { return document.getElementById("MSearchSelectWindow"); }
  97. this.DOMPopupSearchResults = function()
  98. { return document.getElementById("MSearchResults"); }
  99. this.DOMPopupSearchResultsWindow = function()
  100. { return document.getElementById("MSearchResultsWindow"); }
  101. this.DOMSearchClose = function()
  102. { return document.getElementById("MSearchClose"); }
  103. this.DOMSearchBox = function()
  104. { return document.getElementById("MSearchBox"); }
  105. // ------------ Event Handlers
  106. // Called when focus is added or removed from the search field.
  107. this.OnSearchFieldFocus = function(isActive)
  108. {
  109. this.Activate(isActive);
  110. }
  111. this.OnSearchSelectShow = function()
  112. {
  113. var searchSelectWindow = this.DOMSearchSelectWindow();
  114. var searchField = this.DOMSearchSelect();
  115. var left = getXPos(searchField);
  116. var top = getYPos(searchField);
  117. top += searchField.offsetHeight;
  118. // show search selection popup
  119. searchSelectWindow.style.display='block';
  120. searchSelectWindow.style.left = left + 'px';
  121. searchSelectWindow.style.top = top + 'px';
  122. // stop selection hide timer
  123. if (this.hideTimeout)
  124. {
  125. clearTimeout(this.hideTimeout);
  126. this.hideTimeout=0;
  127. }
  128. return false; // to avoid "image drag" default event
  129. }
  130. this.OnSearchSelectHide = function()
  131. {
  132. this.hideTimeout = setTimeout(this.name +".CloseSelectionWindow()",
  133. this.closeSelectionTimeout);
  134. }
  135. // Called when the content of the search field is changed.
  136. this.OnSearchFieldChange = function(evt)
  137. {
  138. if (this.keyTimeout) // kill running timer
  139. {
  140. clearTimeout(this.keyTimeout);
  141. this.keyTimeout = 0;
  142. }
  143. var e = (evt) ? evt : window.event; // for IE
  144. if (e.keyCode==40 || e.keyCode==13)
  145. {
  146. if (e.shiftKey==1)
  147. {
  148. this.OnSearchSelectShow();
  149. var win=this.DOMSearchSelectWindow();
  150. for (i=0;i<win.childNodes.length;i++)
  151. {
  152. var child = win.childNodes[i]; // get span within a
  153. if (child.className=='SelectItem')
  154. {
  155. child.focus();
  156. return;
  157. }
  158. }
  159. return;
  160. }
  161. else
  162. {
  163. window.frames.MSearchResults.postMessage("take_focus", "*");
  164. }
  165. }
  166. else if (e.keyCode==27) // Escape out of the search field
  167. {
  168. this.DOMSearchField().blur();
  169. this.DOMPopupSearchResultsWindow().style.display = 'none';
  170. this.DOMSearchClose().style.display = 'none';
  171. this.lastSearchValue = '';
  172. this.Activate(false);
  173. return;
  174. }
  175. // strip whitespaces
  176. var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
  177. if (searchValue != this.lastSearchValue) // search value has changed
  178. {
  179. if (searchValue != "") // non-empty search
  180. {
  181. // set timer for search update
  182. this.keyTimeout = setTimeout(this.name + '.Search()',
  183. this.keyTimeoutLength);
  184. }
  185. else // empty search field
  186. {
  187. this.DOMPopupSearchResultsWindow().style.display = 'none';
  188. this.DOMSearchClose().style.display = 'none';
  189. this.lastSearchValue = '';
  190. }
  191. }
  192. }
  193. this.SelectItemCount = function(id)
  194. {
  195. var count=0;
  196. var win=this.DOMSearchSelectWindow();
  197. for (i=0;i<win.childNodes.length;i++)
  198. {
  199. var child = win.childNodes[i]; // get span within a
  200. if (child.className=='SelectItem')
  201. {
  202. count++;
  203. }
  204. }
  205. return count;
  206. }
  207. this.SelectItemSet = function(id)
  208. {
  209. var i,j=0;
  210. var win=this.DOMSearchSelectWindow();
  211. for (i=0;i<win.childNodes.length;i++)
  212. {
  213. var child = win.childNodes[i]; // get span within a
  214. if (child.className=='SelectItem')
  215. {
  216. var node = child.firstChild;
  217. if (j==id)
  218. {
  219. node.innerHTML='&#8226;';
  220. }
  221. else
  222. {
  223. node.innerHTML='&#160;';
  224. }
  225. j++;
  226. }
  227. }
  228. }
  229. // Called when an search filter selection is made.
  230. // set item with index id as the active item
  231. this.OnSelectItem = function(id)
  232. {
  233. this.searchIndex = id;
  234. this.SelectItemSet(id);
  235. var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
  236. if (searchValue!="" && this.searchActive) // something was found -> do a search
  237. {
  238. this.Search();
  239. }
  240. }
  241. this.OnSearchSelectKey = function(evt)
  242. {
  243. var e = (evt) ? evt : window.event; // for IE
  244. if (e.keyCode==40 && this.searchIndex<this.SelectItemCount()) // Down
  245. {
  246. this.searchIndex++;
  247. this.OnSelectItem(this.searchIndex);
  248. }
  249. else if (e.keyCode==38 && this.searchIndex>0) // Up
  250. {
  251. this.searchIndex--;
  252. this.OnSelectItem(this.searchIndex);
  253. }
  254. else if (e.keyCode==13 || e.keyCode==27)
  255. {
  256. this.OnSelectItem(this.searchIndex);
  257. this.CloseSelectionWindow();
  258. this.DOMSearchField().focus();
  259. }
  260. return false;
  261. }
  262. // --------- Actions
  263. // Closes the results window.
  264. this.CloseResultsWindow = function()
  265. {
  266. this.DOMPopupSearchResultsWindow().style.display = 'none';
  267. this.DOMSearchClose().style.display = 'none';
  268. this.Activate(false);
  269. }
  270. this.CloseSelectionWindow = function()
  271. {
  272. this.DOMSearchSelectWindow().style.display = 'none';
  273. }
  274. // Performs a search.
  275. this.Search = function()
  276. {
  277. this.keyTimeout = 0;
  278. // strip leading whitespace
  279. var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
  280. var code = searchValue.toLowerCase().charCodeAt(0);
  281. var idxChar = searchValue.substr(0, 1).toLowerCase();
  282. if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
  283. {
  284. idxChar = searchValue.substr(0, 2);
  285. }
  286. var resultsPage;
  287. var resultsPageWithSearch;
  288. var hasResultsPage;
  289. var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
  290. if (idx!=-1)
  291. {
  292. var hexCode=idx.toString(16);
  293. resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + this.extension;
  294. resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
  295. hasResultsPage = true;
  296. }
  297. else // nothing available for this search term
  298. {
  299. resultsPage = this.resultsPath + '/nomatches' + this.extension;
  300. resultsPageWithSearch = resultsPage;
  301. hasResultsPage = false;
  302. }
  303. window.frames.MSearchResults.location = resultsPageWithSearch;
  304. var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
  305. if (domPopupSearchResultsWindow.style.display!='block')
  306. {
  307. var domSearchBox = this.DOMSearchBox();
  308. this.DOMSearchClose().style.display = 'inline-block';
  309. var domPopupSearchResults = this.DOMPopupSearchResults();
  310. var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth;
  311. var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1;
  312. domPopupSearchResultsWindow.style.display = 'block';
  313. left -= domPopupSearchResults.offsetWidth;
  314. var maxWidth = document.body.clientWidth;
  315. var width = 400;
  316. if (left<10) left=10;
  317. if (width+left+8>maxWidth) width=maxWidth-left-8;
  318. domPopupSearchResultsWindow.style.top = top + 'px';
  319. domPopupSearchResultsWindow.style.left = left + 'px';
  320. domPopupSearchResultsWindow.style.width = width + 'px';
  321. }
  322. this.lastSearchValue = searchValue;
  323. this.lastResultsPage = resultsPage;
  324. }
  325. // -------- Activation Functions
  326. // Activates or deactivates the search panel, resetting things to
  327. // their default values if necessary.
  328. this.Activate = function(isActive)
  329. {
  330. if (isActive || // open it
  331. this.DOMPopupSearchResultsWindow().style.display == 'block'
  332. )
  333. {
  334. this.DOMSearchBox().className = 'MSearchBoxActive';
  335. var searchField = this.DOMSearchField();
  336. if (searchField.value == this.searchLabel) // clear "Search" term upon entry
  337. {
  338. searchField.value = '';
  339. this.searchActive = true;
  340. }
  341. }
  342. else if (!isActive) // directly remove the panel
  343. {
  344. this.DOMSearchBox().className = 'MSearchBoxInactive';
  345. this.DOMSearchField().value = this.searchLabel;
  346. this.searchActive = false;
  347. this.lastSearchValue = ''
  348. this.lastResultsPage = '';
  349. }
  350. }
  351. }
  352. // -----------------------------------------------------------------------
  353. // The class that handles everything on the search results page.
  354. function SearchResults(name)
  355. {
  356. // The number of matches from the last run of <Search()>.
  357. this.lastMatchCount = 0;
  358. this.lastKey = 0;
  359. this.repeatOn = false;
  360. // Toggles the visibility of the passed element ID.
  361. this.FindChildElement = function(id)
  362. {
  363. var parentElement = document.getElementById(id);
  364. var element = parentElement.firstChild;
  365. while (element && element!=parentElement)
  366. {
  367. if (element.nodeName.toLowerCase() == 'div' && element.className == 'SRChildren')
  368. {
  369. return element;
  370. }
  371. if (element.nodeName.toLowerCase() == 'div' && element.hasChildNodes())
  372. {
  373. element = element.firstChild;
  374. }
  375. else if (element.nextSibling)
  376. {
  377. element = element.nextSibling;
  378. }
  379. else
  380. {
  381. do
  382. {
  383. element = element.parentNode;
  384. }
  385. while (element && element!=parentElement && !element.nextSibling);
  386. if (element && element!=parentElement)
  387. {
  388. element = element.nextSibling;
  389. }
  390. }
  391. }
  392. }
  393. this.Toggle = function(id)
  394. {
  395. var element = this.FindChildElement(id);
  396. if (element)
  397. {
  398. if (element.style.display == 'block')
  399. {
  400. element.style.display = 'none';
  401. }
  402. else
  403. {
  404. element.style.display = 'block';
  405. }
  406. }
  407. }
  408. // Searches for the passed string. If there is no parameter,
  409. // it takes it from the URL query.
  410. //
  411. // Always returns true, since other documents may try to call it
  412. // and that may or may not be possible.
  413. this.Search = function(search)
  414. {
  415. if (!search) // get search word from URL
  416. {
  417. search = window.location.search;
  418. search = search.substring(1); // Remove the leading '?'
  419. search = unescape(search);
  420. }
  421. search = search.replace(/^ +/, ""); // strip leading spaces
  422. search = search.replace(/ +$/, ""); // strip trailing spaces
  423. search = search.toLowerCase();
  424. search = convertToId(search);
  425. var resultRows = document.getElementsByTagName("div");
  426. var matches = 0;
  427. var i = 0;
  428. while (i < resultRows.length)
  429. {
  430. var row = resultRows.item(i);
  431. if (row.className == "SRResult")
  432. {
  433. var rowMatchName = row.id.toLowerCase();
  434. rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_'
  435. if (search.length<=rowMatchName.length &&
  436. rowMatchName.substr(0, search.length)==search)
  437. {
  438. row.style.display = 'block';
  439. matches++;
  440. }
  441. else
  442. {
  443. row.style.display = 'none';
  444. }
  445. }
  446. i++;
  447. }
  448. document.getElementById("Searching").style.display='none';
  449. if (matches == 0) // no results
  450. {
  451. document.getElementById("NoMatches").style.display='block';
  452. }
  453. else // at least one result
  454. {
  455. document.getElementById("NoMatches").style.display='none';
  456. }
  457. this.lastMatchCount = matches;
  458. return true;
  459. }
  460. // return the first item with index index or higher that is visible
  461. this.NavNext = function(index)
  462. {
  463. var focusItem;
  464. while (1)
  465. {
  466. var focusName = 'Item'+index;
  467. focusItem = document.getElementById(focusName);
  468. if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
  469. {
  470. break;
  471. }
  472. else if (!focusItem) // last element
  473. {
  474. break;
  475. }
  476. focusItem=null;
  477. index++;
  478. }
  479. return focusItem;
  480. }
  481. this.NavPrev = function(index)
  482. {
  483. var focusItem;
  484. while (1)
  485. {
  486. var focusName = 'Item'+index;
  487. focusItem = document.getElementById(focusName);
  488. if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
  489. {
  490. break;
  491. }
  492. else if (!focusItem) // last element
  493. {
  494. break;
  495. }
  496. focusItem=null;
  497. index--;
  498. }
  499. return focusItem;
  500. }
  501. this.ProcessKeys = function(e)
  502. {
  503. if (e.type == "keydown")
  504. {
  505. this.repeatOn = false;
  506. this.lastKey = e.keyCode;
  507. }
  508. else if (e.type == "keypress")
  509. {
  510. if (!this.repeatOn)
  511. {
  512. if (this.lastKey) this.repeatOn = true;
  513. return false; // ignore first keypress after keydown
  514. }
  515. }
  516. else if (e.type == "keyup")
  517. {
  518. this.lastKey = 0;
  519. this.repeatOn = false;
  520. }
  521. return this.lastKey!=0;
  522. }
  523. this.Nav = function(evt,itemIndex)
  524. {
  525. var e = (evt) ? evt : window.event; // for IE
  526. if (e.keyCode==13) return true;
  527. if (!this.ProcessKeys(e)) return false;
  528. if (this.lastKey==38) // Up
  529. {
  530. var newIndex = itemIndex-1;
  531. var focusItem = this.NavPrev(newIndex);
  532. if (focusItem)
  533. {
  534. var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
  535. if (child && child.style.display == 'block') // children visible
  536. {
  537. var n=0;
  538. var tmpElem;
  539. while (1) // search for last child
  540. {
  541. tmpElem = document.getElementById('Item'+newIndex+'_c'+n);
  542. if (tmpElem)
  543. {
  544. focusItem = tmpElem;
  545. }
  546. else // found it!
  547. {
  548. break;
  549. }
  550. n++;
  551. }
  552. }
  553. }
  554. if (focusItem)
  555. {
  556. focusItem.focus();
  557. }
  558. else // return focus to search field
  559. {
  560. parent.document.getElementById("MSearchField").focus();
  561. }
  562. }
  563. else if (this.lastKey==40) // Down
  564. {
  565. var newIndex = itemIndex+1;
  566. var focusItem;
  567. var item = document.getElementById('Item'+itemIndex);
  568. var elem = this.FindChildElement(item.parentNode.parentNode.id);
  569. if (elem && elem.style.display == 'block') // children visible
  570. {
  571. focusItem = document.getElementById('Item'+itemIndex+'_c0');
  572. }
  573. if (!focusItem) focusItem = this.NavNext(newIndex);
  574. if (focusItem) focusItem.focus();
  575. }
  576. else if (this.lastKey==39) // Right
  577. {
  578. var item = document.getElementById('Item'+itemIndex);
  579. var elem = this.FindChildElement(item.parentNode.parentNode.id);
  580. if (elem) elem.style.display = 'block';
  581. }
  582. else if (this.lastKey==37) // Left
  583. {
  584. var item = document.getElementById('Item'+itemIndex);
  585. var elem = this.FindChildElement(item.parentNode.parentNode.id);
  586. if (elem) elem.style.display = 'none';
  587. }
  588. else if (this.lastKey==27) // Escape
  589. {
  590. parent.searchBox.CloseResultsWindow();
  591. parent.document.getElementById("MSearchField").focus();
  592. }
  593. else if (this.lastKey==13) // Enter
  594. {
  595. return true;
  596. }
  597. return false;
  598. }
  599. this.NavChild = function(evt,itemIndex,childIndex)
  600. {
  601. var e = (evt) ? evt : window.event; // for IE
  602. if (e.keyCode==13) return true;
  603. if (!this.ProcessKeys(e)) return false;
  604. if (this.lastKey==38) // Up
  605. {
  606. if (childIndex>0)
  607. {
  608. var newIndex = childIndex-1;
  609. document.getElementById('Item'+itemIndex+'_c'+newIndex).focus();
  610. }
  611. else // already at first child, jump to parent
  612. {
  613. document.getElementById('Item'+itemIndex).focus();
  614. }
  615. }
  616. else if (this.lastKey==40) // Down
  617. {
  618. var newIndex = childIndex+1;
  619. var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex);
  620. if (!elem) // last child, jump to parent next parent
  621. {
  622. elem = this.NavNext(itemIndex+1);
  623. }
  624. if (elem)
  625. {
  626. elem.focus();
  627. }
  628. }
  629. else if (this.lastKey==27) // Escape
  630. {
  631. parent.searchBox.CloseResultsWindow();
  632. parent.document.getElementById("MSearchField").focus();
  633. }
  634. else if (this.lastKey==13) // Enter
  635. {
  636. return true;
  637. }
  638. return false;
  639. }
  640. }
  641. function setKeyActions(elem,action)
  642. {
  643. elem.setAttribute('onkeydown',action);
  644. elem.setAttribute('onkeypress',action);
  645. elem.setAttribute('onkeyup',action);
  646. }
  647. function setClassAttr(elem,attr)
  648. {
  649. elem.setAttribute('class',attr);
  650. elem.setAttribute('className',attr);
  651. }
  652. function createResults()
  653. {
  654. var results = document.getElementById("SRResults");
  655. for (var e=0; e<searchData.length; e++)
  656. {
  657. var id = searchData[e][0];
  658. var srResult = document.createElement('div');
  659. srResult.setAttribute('id','SR_'+id);
  660. setClassAttr(srResult,'SRResult');
  661. var srEntry = document.createElement('div');
  662. setClassAttr(srEntry,'SREntry');
  663. var srLink = document.createElement('a');
  664. srLink.setAttribute('id','Item'+e);
  665. setKeyActions(srLink,'return searchResults.Nav(event,'+e+')');
  666. setClassAttr(srLink,'SRSymbol');
  667. srLink.innerHTML = searchData[e][1][0];
  668. srEntry.appendChild(srLink);
  669. if (searchData[e][1].length==2) // single result
  670. {
  671. srLink.setAttribute('href',searchData[e][1][1][0]);
  672. srLink.setAttribute('onclick','parent.searchBox.CloseResultsWindow()');
  673. if (searchData[e][1][1][1])
  674. {
  675. srLink.setAttribute('target','_parent');
  676. }
  677. var srScope = document.createElement('span');
  678. setClassAttr(srScope,'SRScope');
  679. srScope.innerHTML = searchData[e][1][1][2];
  680. srEntry.appendChild(srScope);
  681. }
  682. else // multiple results
  683. {
  684. srLink.setAttribute('href','javascript:searchResults.Toggle("SR_'+id+'")');
  685. var srChildren = document.createElement('div');
  686. setClassAttr(srChildren,'SRChildren');
  687. for (var c=0; c<searchData[e][1].length-1; c++)
  688. {
  689. var srChild = document.createElement('a');
  690. srChild.setAttribute('id','Item'+e+'_c'+c);
  691. setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')');
  692. setClassAttr(srChild,'SRScope');
  693. srChild.setAttribute('href',searchData[e][1][c+1][0]);
  694. srChild.setAttribute('onclick','parent.searchBox.CloseResultsWindow()');
  695. if (searchData[e][1][c+1][1])
  696. {
  697. srChild.setAttribute('target','_parent');
  698. }
  699. srChild.innerHTML = searchData[e][1][c+1][2];
  700. srChildren.appendChild(srChild);
  701. }
  702. srEntry.appendChild(srChildren);
  703. }
  704. srResult.appendChild(srEntry);
  705. results.appendChild(srResult);
  706. }
  707. }
  708. function init_search()
  709. {
  710. var results = document.getElementById("MSearchSelectWindow");
  711. for (var key in indexSectionLabels)
  712. {
  713. var link = document.createElement('a');
  714. link.setAttribute('class','SelectItem');
  715. link.setAttribute('onclick','searchBox.OnSelectItem('+key+')');
  716. link.href='javascript:void(0)';
  717. link.innerHTML='<span class="SelectionMark">&#160;</span>'+indexSectionLabels[key];
  718. results.appendChild(link);
  719. }
  720. searchBox.OnSelectItem(0);
  721. }
  722. /* @license-end */