search.js 24 KB

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