search.js 22 KB

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