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.

817 lines
25 KiB

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