search.js 23 KB

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