2
0

search.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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, 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
  176. {
  177. window.frames.MSearchResults.postMessage("take_focus", "*");
  178. }
  179. }
  180. else if (e.keyCode==27) // Escape out of the search field
  181. {
  182. this.DOMSearchField().blur();
  183. this.DOMPopupSearchResultsWindow().style.display = 'none';
  184. this.DOMSearchClose().style.display = 'none';
  185. this.lastSearchValue = '';
  186. this.Activate(false);
  187. return;
  188. }
  189. // strip whitespaces
  190. var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
  191. if (searchValue != this.lastSearchValue) // search value has changed
  192. {
  193. if (searchValue != "") // non-empty search
  194. {
  195. // set timer for search update
  196. this.keyTimeout = setTimeout(this.name + '.Search()',
  197. this.keyTimeoutLength);
  198. }
  199. else // empty search field
  200. {
  201. this.DOMPopupSearchResultsWindow().style.display = 'none';
  202. this.DOMSearchClose().style.display = 'none';
  203. this.lastSearchValue = '';
  204. }
  205. }
  206. }
  207. this.SelectItemCount = function(id)
  208. {
  209. var count=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. count++;
  217. }
  218. }
  219. return count;
  220. }
  221. this.SelectItemSet = function(id)
  222. {
  223. var i,j=0;
  224. var win=this.DOMSearchSelectWindow();
  225. for (i=0;i<win.childNodes.length;i++)
  226. {
  227. var child = win.childNodes[i]; // get span within a
  228. if (child.className=='SelectItem')
  229. {
  230. var node = child.firstChild;
  231. if (j==id)
  232. {
  233. node.innerHTML='&#8226;';
  234. }
  235. else
  236. {
  237. node.innerHTML='&#160;';
  238. }
  239. j++;
  240. }
  241. }
  242. }
  243. // Called when an search filter selection is made.
  244. // set item with index id as the active item
  245. this.OnSelectItem = function(id)
  246. {
  247. this.searchIndex = id;
  248. this.SelectItemSet(id);
  249. var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
  250. if (searchValue!="" && this.searchActive) // something was found -> do a search
  251. {
  252. this.Search();
  253. }
  254. }
  255. this.OnSearchSelectKey = function(evt)
  256. {
  257. var e = (evt) ? evt : window.event; // for IE
  258. if (e.keyCode==40 && this.searchIndex<this.SelectItemCount()) // Down
  259. {
  260. this.searchIndex++;
  261. this.OnSelectItem(this.searchIndex);
  262. }
  263. else if (e.keyCode==38 && this.searchIndex>0) // Up
  264. {
  265. this.searchIndex--;
  266. this.OnSelectItem(this.searchIndex);
  267. }
  268. else if (e.keyCode==13 || e.keyCode==27)
  269. {
  270. this.OnSelectItem(this.searchIndex);
  271. this.CloseSelectionWindow();
  272. this.DOMSearchField().focus();
  273. }
  274. return false;
  275. }
  276. // --------- Actions
  277. // Closes the results window.
  278. this.CloseResultsWindow = function()
  279. {
  280. this.DOMPopupSearchResultsWindow().style.display = 'none';
  281. this.DOMSearchClose().style.display = 'none';
  282. this.Activate(false);
  283. }
  284. this.CloseSelectionWindow = function()
  285. {
  286. this.DOMSearchSelectWindow().style.display = 'none';
  287. }
  288. // Performs a search.
  289. this.Search = function()
  290. {
  291. this.keyTimeout = 0;
  292. // strip leading whitespace
  293. var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
  294. var code = searchValue.toLowerCase().charCodeAt(0);
  295. var idxChar = searchValue.substr(0, 1).toLowerCase();
  296. if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
  297. {
  298. idxChar = searchValue.substr(0, 2);
  299. }
  300. var resultsPage;
  301. var resultsPageWithSearch;
  302. var hasResultsPage;
  303. var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
  304. if (idx!=-1)
  305. {
  306. var hexCode=idx.toString(16);
  307. resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html';
  308. resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
  309. hasResultsPage = true;
  310. }
  311. else // nothing available for this search term
  312. {
  313. resultsPage = this.resultsPath + '/nomatches.html';
  314. resultsPageWithSearch = resultsPage;
  315. hasResultsPage = false;
  316. }
  317. window.frames.MSearchResults.location = resultsPageWithSearch;
  318. var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
  319. if (domPopupSearchResultsWindow.style.display!='block')
  320. {
  321. var domSearchBox = this.DOMSearchBox();
  322. this.DOMSearchClose().style.display = 'inline-block';
  323. if (this.insideFrame)
  324. {
  325. var domPopupSearchResults = this.DOMPopupSearchResults();
  326. domPopupSearchResultsWindow.style.position = 'relative';
  327. domPopupSearchResultsWindow.style.display = 'block';
  328. var width = document.body.clientWidth - 8; // the -8 is for IE :-(
  329. domPopupSearchResultsWindow.style.width = width + 'px';
  330. domPopupSearchResults.style.width = width + 'px';
  331. }
  332. else
  333. {
  334. var domPopupSearchResults = this.DOMPopupSearchResults();
  335. var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth;
  336. var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1;
  337. domPopupSearchResultsWindow.style.display = 'block';
  338. left -= domPopupSearchResults.offsetWidth;
  339. domPopupSearchResultsWindow.style.top = top + 'px';
  340. domPopupSearchResultsWindow.style.left = left + 'px';
  341. }
  342. }
  343. this.lastSearchValue = searchValue;
  344. this.lastResultsPage = resultsPage;
  345. }
  346. // -------- Activation Functions
  347. // Activates or deactivates the search panel, resetting things to
  348. // their default values if necessary.
  349. this.Activate = function(isActive)
  350. {
  351. if (isActive || // open it
  352. this.DOMPopupSearchResultsWindow().style.display == 'block'
  353. )
  354. {
  355. this.DOMSearchBox().className = 'MSearchBoxActive';
  356. var searchField = this.DOMSearchField();
  357. if (searchField.value == this.searchLabel) // clear "Search" term upon entry
  358. {
  359. searchField.value = '';
  360. this.searchActive = true;
  361. }
  362. }
  363. else if (!isActive) // directly remove the panel
  364. {
  365. this.DOMSearchBox().className = 'MSearchBoxInactive';
  366. this.DOMSearchField().value = this.searchLabel;
  367. this.searchActive = false;
  368. this.lastSearchValue = ''
  369. this.lastResultsPage = '';
  370. }
  371. }
  372. }
  373. // -----------------------------------------------------------------------
  374. // The class that handles everything on the search results page.
  375. function SearchResults(name)
  376. {
  377. // The number of matches from the last run of <Search()>.
  378. this.lastMatchCount = 0;
  379. this.lastKey = 0;
  380. this.repeatOn = false;
  381. // Toggles the visibility of the passed element ID.
  382. this.FindChildElement = function(id)
  383. {
  384. var parentElement = document.getElementById(id);
  385. var element = parentElement.firstChild;
  386. while (element && element!=parentElement)
  387. {
  388. if (element.nodeName == 'DIV' && element.className == 'SRChildren')
  389. {
  390. return element;
  391. }
  392. if (element.nodeName == 'DIV' && element.hasChildNodes())
  393. {
  394. element = element.firstChild;
  395. }
  396. else if (element.nextSibling)
  397. {
  398. element = element.nextSibling;
  399. }
  400. else
  401. {
  402. do
  403. {
  404. element = element.parentNode;
  405. }
  406. while (element && element!=parentElement && !element.nextSibling);
  407. if (element && element!=parentElement)
  408. {
  409. element = element.nextSibling;
  410. }
  411. }
  412. }
  413. }
  414. this.Toggle = function(id)
  415. {
  416. var element = this.FindChildElement(id);
  417. if (element)
  418. {
  419. if (element.style.display == 'block')
  420. {
  421. element.style.display = 'none';
  422. }
  423. else
  424. {
  425. element.style.display = 'block';
  426. }
  427. }
  428. }
  429. // Searches for the passed string. If there is no parameter,
  430. // it takes it from the URL query.
  431. //
  432. // Always returns true, since other documents may try to call it
  433. // and that may or may not be possible.
  434. this.Search = function(search)
  435. {
  436. if (!search) // get search word from URL
  437. {
  438. search = window.location.search;
  439. search = search.substring(1); // Remove the leading '?'
  440. search = unescape(search);
  441. }
  442. search = search.replace(/^ +/, ""); // strip leading spaces
  443. search = search.replace(/ +$/, ""); // strip trailing spaces
  444. search = search.toLowerCase();
  445. search = convertToId(search);
  446. var resultRows = document.getElementsByTagName("div");
  447. var matches = 0;
  448. var i = 0;
  449. while (i < resultRows.length)
  450. {
  451. var row = resultRows.item(i);
  452. if (row.className == "SRResult")
  453. {
  454. var rowMatchName = row.id.toLowerCase();
  455. rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_'
  456. if (search.length<=rowMatchName.length &&
  457. rowMatchName.substr(0, search.length)==search)
  458. {
  459. row.style.display = 'block';
  460. matches++;
  461. }
  462. else
  463. {
  464. row.style.display = 'none';
  465. }
  466. }
  467. i++;
  468. }
  469. document.getElementById("Searching").style.display='none';
  470. if (matches == 0) // no results
  471. {
  472. document.getElementById("NoMatches").style.display='block';
  473. }
  474. else // at least one result
  475. {
  476. document.getElementById("NoMatches").style.display='none';
  477. }
  478. this.lastMatchCount = matches;
  479. return true;
  480. }
  481. // return the first item with index index or higher that is visible
  482. this.NavNext = function(index)
  483. {
  484. var focusItem;
  485. while (1)
  486. {
  487. var focusName = 'Item'+index;
  488. focusItem = document.getElementById(focusName);
  489. if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
  490. {
  491. break;
  492. }
  493. else if (!focusItem) // last element
  494. {
  495. break;
  496. }
  497. focusItem=null;
  498. index++;
  499. }
  500. return focusItem;
  501. }
  502. this.NavPrev = function(index)
  503. {
  504. var focusItem;
  505. while (1)
  506. {
  507. var focusName = 'Item'+index;
  508. focusItem = document.getElementById(focusName);
  509. if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
  510. {
  511. break;
  512. }
  513. else if (!focusItem) // last element
  514. {
  515. break;
  516. }
  517. focusItem=null;
  518. index--;
  519. }
  520. return focusItem;
  521. }
  522. this.ProcessKeys = function(e)
  523. {
  524. if (e.type == "keydown")
  525. {
  526. this.repeatOn = false;
  527. this.lastKey = e.keyCode;
  528. }
  529. else if (e.type == "keypress")
  530. {
  531. if (!this.repeatOn)
  532. {
  533. if (this.lastKey) this.repeatOn = true;
  534. return false; // ignore first keypress after keydown
  535. }
  536. }
  537. else if (e.type == "keyup")
  538. {
  539. this.lastKey = 0;
  540. this.repeatOn = false;
  541. }
  542. return this.lastKey!=0;
  543. }
  544. this.Nav = function(evt,itemIndex)
  545. {
  546. var e = (evt) ? evt : window.event; // for IE
  547. if (e.keyCode==13) return true;
  548. if (!this.ProcessKeys(e)) return false;
  549. if (this.lastKey==38) // Up
  550. {
  551. var newIndex = itemIndex-1;
  552. var focusItem = this.NavPrev(newIndex);
  553. if (focusItem)
  554. {
  555. var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
  556. if (child && child.style.display == 'block') // children visible
  557. {
  558. var n=0;
  559. var tmpElem;
  560. while (1) // search for last child
  561. {
  562. tmpElem = document.getElementById('Item'+newIndex+'_c'+n);
  563. if (tmpElem)
  564. {
  565. focusItem = tmpElem;
  566. }
  567. else // found it!
  568. {
  569. break;
  570. }
  571. n++;
  572. }
  573. }
  574. }
  575. if (focusItem)
  576. {
  577. focusItem.focus();
  578. }
  579. else // return focus to search field
  580. {
  581. parent.document.getElementById("MSearchField").focus();
  582. }
  583. }
  584. else if (this.lastKey==40) // Down
  585. {
  586. var newIndex = itemIndex+1;
  587. var focusItem;
  588. var item = document.getElementById('Item'+itemIndex);
  589. var elem = this.FindChildElement(item.parentNode.parentNode.id);
  590. if (elem && elem.style.display == 'block') // children visible
  591. {
  592. focusItem = document.getElementById('Item'+itemIndex+'_c0');
  593. }
  594. if (!focusItem) focusItem = this.NavNext(newIndex);
  595. if (focusItem) focusItem.focus();
  596. }
  597. else if (this.lastKey==39) // Right
  598. {
  599. var item = document.getElementById('Item'+itemIndex);
  600. var elem = this.FindChildElement(item.parentNode.parentNode.id);
  601. if (elem) elem.style.display = 'block';
  602. }
  603. else if (this.lastKey==37) // Left
  604. {
  605. var item = document.getElementById('Item'+itemIndex);
  606. var elem = this.FindChildElement(item.parentNode.parentNode.id);
  607. if (elem) elem.style.display = 'none';
  608. }
  609. else if (this.lastKey==27) // Escape
  610. {
  611. parent.searchBox.CloseResultsWindow();
  612. parent.document.getElementById("MSearchField").focus();
  613. }
  614. else if (this.lastKey==13) // Enter
  615. {
  616. return true;
  617. }
  618. return false;
  619. }
  620. this.NavChild = function(evt,itemIndex,childIndex)
  621. {
  622. var e = (evt) ? evt : window.event; // for IE
  623. if (e.keyCode==13) return true;
  624. if (!this.ProcessKeys(e)) return false;
  625. if (this.lastKey==38) // Up
  626. {
  627. if (childIndex>0)
  628. {
  629. var newIndex = childIndex-1;
  630. document.getElementById('Item'+itemIndex+'_c'+newIndex).focus();
  631. }
  632. else // already at first child, jump to parent
  633. {
  634. document.getElementById('Item'+itemIndex).focus();
  635. }
  636. }
  637. else if (this.lastKey==40) // Down
  638. {
  639. var newIndex = childIndex+1;
  640. var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex);
  641. if (!elem) // last child, jump to parent next parent
  642. {
  643. elem = this.NavNext(itemIndex+1);
  644. }
  645. if (elem)
  646. {
  647. elem.focus();
  648. }
  649. }
  650. else if (this.lastKey==27) // Escape
  651. {
  652. parent.searchBox.CloseResultsWindow();
  653. parent.document.getElementById("MSearchField").focus();
  654. }
  655. else if (this.lastKey==13) // Enter
  656. {
  657. return true;
  658. }
  659. return false;
  660. }
  661. }
  662. function setKeyActions(elem,action)
  663. {
  664. elem.setAttribute('onkeydown',action);
  665. elem.setAttribute('onkeypress',action);
  666. elem.setAttribute('onkeyup',action);
  667. }
  668. function setClassAttr(elem,attr)
  669. {
  670. elem.setAttribute('class',attr);
  671. elem.setAttribute('className',attr);
  672. }
  673. function createResults()
  674. {
  675. var results = document.getElementById("SRResults");
  676. for (var e=0; e<searchData.length; e++)
  677. {
  678. var id = searchData[e][0];
  679. var srResult = document.createElement('div');
  680. srResult.setAttribute('id','SR_'+id);
  681. setClassAttr(srResult,'SRResult');
  682. var srEntry = document.createElement('div');
  683. setClassAttr(srEntry,'SREntry');
  684. var srLink = document.createElement('a');
  685. srLink.setAttribute('id','Item'+e);
  686. setKeyActions(srLink,'return searchResults.Nav(event,'+e+')');
  687. setClassAttr(srLink,'SRSymbol');
  688. srLink.innerHTML = searchData[e][1][0];
  689. srEntry.appendChild(srLink);
  690. if (searchData[e][1].length==2) // single result
  691. {
  692. srLink.setAttribute('href',searchData[e][1][1][0]);
  693. if (searchData[e][1][1][1])
  694. {
  695. srLink.setAttribute('target','_parent');
  696. }
  697. var srScope = document.createElement('span');
  698. setClassAttr(srScope,'SRScope');
  699. srScope.innerHTML = searchData[e][1][1][2];
  700. srEntry.appendChild(srScope);
  701. }
  702. else // multiple results
  703. {
  704. srLink.setAttribute('href','javascript:searchResults.Toggle("SR_'+id+'")');
  705. var srChildren = document.createElement('div');
  706. setClassAttr(srChildren,'SRChildren');
  707. for (var c=0; c<searchData[e][1].length-1; c++)
  708. {
  709. var srChild = document.createElement('a');
  710. srChild.setAttribute('id','Item'+e+'_c'+c);
  711. setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')');
  712. setClassAttr(srChild,'SRScope');
  713. srChild.setAttribute('href',searchData[e][1][c+1][0]);
  714. if (searchData[e][1][c+1][1])
  715. {
  716. srChild.setAttribute('target','_parent');
  717. }
  718. srChild.innerHTML = searchData[e][1][c+1][2];
  719. srChildren.appendChild(srChild);
  720. }
  721. srEntry.appendChild(srChildren);
  722. }
  723. srResult.appendChild(srEntry);
  724. results.appendChild(srResult);
  725. }
  726. }
  727. function init_search()
  728. {
  729. var results = document.getElementById("MSearchSelectWindow");
  730. for (var key in indexSectionLabels)
  731. {
  732. var link = document.createElement('a');
  733. link.setAttribute('class','SelectItem');
  734. link.setAttribute('onclick','searchBox.OnSelectItem('+key+')');
  735. link.href='javascript:void(0)';
  736. link.innerHTML='<span class="SelectionMark">&#160;</span>'+indexSectionLabels[key];
  737. results.appendChild(link);
  738. }
  739. searchBox.OnSelectItem(0);
  740. }
  741. /* @license-end */