search.js 24 KB

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