search.js 24 KB

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