main.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  1. // This file is part of Natural Docs, which is Copyright © 2003-2010 Greg Valure
  2. // Natural Docs is licensed under version 3 of the GNU Affero General Public License (AGPL)
  3. // Refer to License.txt for the complete details
  4. // This file may be distributed with documentation files generated by Natural Docs.
  5. // Such documentation is not covered by Natural Docs' copyright and licensing,
  6. // and may have its own copyright and distribution terms as decided by its author.
  7. //
  8. // Browser Styles
  9. // ____________________________________________________________________________
  10. var agt=navigator.userAgent.toLowerCase();
  11. var browserType;
  12. var browserVer;
  13. if (agt.indexOf("opera") != -1)
  14. {
  15. browserType = "Opera";
  16. if (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1)
  17. { browserVer = "Opera7"; }
  18. else if (agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1)
  19. { browserVer = "Opera8"; }
  20. else if (agt.indexOf("opera 9") != -1 || agt.indexOf("opera/9") != -1)
  21. { browserVer = "Opera9"; }
  22. }
  23. else if (agt.indexOf("applewebkit") != -1)
  24. {
  25. browserType = "Safari";
  26. if (agt.indexOf("version/3") != -1)
  27. { browserVer = "Safari3"; }
  28. else if (agt.indexOf("safari/4") != -1)
  29. { browserVer = "Safari2"; }
  30. }
  31. else if (agt.indexOf("khtml") != -1)
  32. {
  33. browserType = "Konqueror";
  34. }
  35. else if (agt.indexOf("msie") != -1)
  36. {
  37. browserType = "IE";
  38. if (agt.indexOf("msie 6") != -1)
  39. { browserVer = "IE6"; }
  40. else if (agt.indexOf("msie 7") != -1)
  41. { browserVer = "IE7"; }
  42. }
  43. else if (agt.indexOf("gecko") != -1)
  44. {
  45. browserType = "Firefox";
  46. if (agt.indexOf("rv:1.7") != -1)
  47. { browserVer = "Firefox1"; }
  48. else if (agt.indexOf("rv:1.8)") != -1 || agt.indexOf("rv:1.8.0") != -1)
  49. { browserVer = "Firefox15"; }
  50. else if (agt.indexOf("rv:1.8.1") != -1)
  51. { browserVer = "Firefox2"; }
  52. }
  53. //
  54. // Support Functions
  55. // ____________________________________________________________________________
  56. function GetXPosition(item)
  57. {
  58. var position = 0;
  59. if (item.offsetWidth != null)
  60. {
  61. while (item != document.body && item != null)
  62. {
  63. position += item.offsetLeft;
  64. item = item.offsetParent;
  65. };
  66. };
  67. return position;
  68. };
  69. function GetYPosition(item)
  70. {
  71. var position = 0;
  72. if (item.offsetWidth != null)
  73. {
  74. while (item != document.body && item != null)
  75. {
  76. position += item.offsetTop;
  77. item = item.offsetParent;
  78. };
  79. };
  80. return position;
  81. };
  82. function MoveToPosition(item, x, y)
  83. {
  84. // Opera 5 chokes on the px extension, so it can use the Microsoft one instead.
  85. if (item.style.left != null)
  86. {
  87. item.style.left = x + "px";
  88. item.style.top = y + "px";
  89. }
  90. else if (item.style.pixelLeft != null)
  91. {
  92. item.style.pixelLeft = x;
  93. item.style.pixelTop = y;
  94. };
  95. };
  96. //
  97. // Menu
  98. // ____________________________________________________________________________
  99. function ToggleMenu(id)
  100. {
  101. if (!window.document.getElementById)
  102. { return; };
  103. var display = window.document.getElementById(id).style.display;
  104. if (display == "none")
  105. { display = "block"; }
  106. else
  107. { display = "none"; }
  108. window.document.getElementById(id).style.display = display;
  109. }
  110. function HideAllBut(ids, max)
  111. {
  112. if (document.getElementById)
  113. {
  114. ids.sort( function(a,b) { return a - b; } );
  115. var number = 1;
  116. while (number < max)
  117. {
  118. if (ids.length > 0 && number == ids[0])
  119. { ids.shift(); }
  120. else
  121. {
  122. document.getElementById("MGroupContent" + number).style.display = "none";
  123. };
  124. number++;
  125. };
  126. };
  127. }
  128. //
  129. // Tooltips
  130. // ____________________________________________________________________________
  131. var tooltipTimer = 0;
  132. function ShowTip(event, tooltipID, linkID)
  133. {
  134. if (tooltipTimer)
  135. { clearTimeout(tooltipTimer); };
  136. var docX = event.clientX + window.pageXOffset;
  137. var docY = event.clientY + window.pageYOffset;
  138. var showCommand = "ReallyShowTip('" + tooltipID + "', '" + linkID + "', " + docX + ", " + docY + ")";
  139. tooltipTimer = setTimeout(showCommand, 1000);
  140. }
  141. function ReallyShowTip(tooltipID, linkID, docX, docY)
  142. {
  143. tooltipTimer = 0;
  144. var tooltip;
  145. var link;
  146. if (document.getElementById)
  147. {
  148. tooltip = document.getElementById(tooltipID);
  149. link = document.getElementById(linkID);
  150. }
  151. /* else if (document.all)
  152. {
  153. tooltip = eval("document.all['" + tooltipID + "']");
  154. link = eval("document.all['" + linkID + "']");
  155. }
  156. */
  157. if (tooltip)
  158. {
  159. var left = GetXPosition(link);
  160. var top = GetYPosition(link);
  161. top += link.offsetHeight;
  162. // The fallback method is to use the mouse X and Y relative to the document. We use a separate if and test if its a number
  163. // in case some browser snuck through the above if statement but didn't support everything.
  164. if (!isFinite(top) || top == 0)
  165. {
  166. left = docX;
  167. top = docY;
  168. }
  169. // Some spacing to get it out from under the cursor.
  170. top += 10;
  171. // Make sure the tooltip doesnt get smushed by being too close to the edge, or in some browsers, go off the edge of the
  172. // page. We do it here because Konqueror does get offsetWidth right even if it doesnt get the positioning right.
  173. if (tooltip.offsetWidth != null)
  174. {
  175. var width = tooltip.offsetWidth;
  176. var docWidth = document.body.clientWidth;
  177. if (left + width > docWidth)
  178. { left = docWidth - width - 1; }
  179. // If there's a horizontal scroll bar we could go past zero because it's using the page width, not the window width.
  180. if (left < 0)
  181. { left = 0; };
  182. }
  183. MoveToPosition(tooltip, left, top);
  184. tooltip.style.visibility = "visible";
  185. }
  186. }
  187. function HideTip(tooltipID)
  188. {
  189. if (tooltipTimer)
  190. {
  191. clearTimeout(tooltipTimer);
  192. tooltipTimer = 0;
  193. }
  194. var tooltip;
  195. if (document.getElementById)
  196. { tooltip = document.getElementById(tooltipID); }
  197. else if (document.all)
  198. { tooltip = eval("document.all['" + tooltipID + "']"); }
  199. if (tooltip)
  200. { tooltip.style.visibility = "hidden"; }
  201. }
  202. //
  203. // Blockquote fix for IE
  204. // ____________________________________________________________________________
  205. function NDOnLoad()
  206. {
  207. if (browserVer == "IE6")
  208. {
  209. var scrollboxes = document.getElementsByTagName('blockquote');
  210. if (scrollboxes.item(0))
  211. {
  212. NDDoResize();
  213. window.onresize=NDOnResize;
  214. };
  215. };
  216. };
  217. var resizeTimer = 0;
  218. function NDOnResize()
  219. {
  220. if (resizeTimer != 0)
  221. { clearTimeout(resizeTimer); };
  222. resizeTimer = setTimeout(NDDoResize, 250);
  223. };
  224. function NDDoResize()
  225. {
  226. var scrollboxes = document.getElementsByTagName('blockquote');
  227. var i;
  228. var item;
  229. i = 0;
  230. while (item = scrollboxes.item(i))
  231. {
  232. item.style.width = 100;
  233. i++;
  234. };
  235. i = 0;
  236. while (item = scrollboxes.item(i))
  237. {
  238. item.style.width = item.parentNode.offsetWidth;
  239. i++;
  240. };
  241. clearTimeout(resizeTimer);
  242. resizeTimer = 0;
  243. }
  244. /* ________________________________________________________________________________________________________
  245. Class: SearchPanel
  246. ________________________________________________________________________________________________________
  247. A class handling everything associated with the search panel.
  248. Parameters:
  249. name - The name of the global variable that will be storing this instance. Is needed to be able to set timeouts.
  250. mode - The mode the search is going to work in. Pass <NaturalDocs::Builder::Base->CommandLineOption()>, so the
  251. value will be something like "HTML" or "FramedHTML".
  252. ________________________________________________________________________________________________________
  253. */
  254. function SearchPanel(name, mode, resultsPath)
  255. {
  256. if (!name || !mode || !resultsPath)
  257. { alert("Incorrect parameters to SearchPanel."); };
  258. // Group: Variables
  259. // ________________________________________________________________________
  260. /*
  261. var: name
  262. The name of the global variable that will be storing this instance of the class.
  263. */
  264. this.name = name;
  265. /*
  266. var: mode
  267. The mode the search is going to work in, such as "HTML" or "FramedHTML".
  268. */
  269. this.mode = mode;
  270. /*
  271. var: resultsPath
  272. The relative path from the current HTML page to the results page directory.
  273. */
  274. this.resultsPath = resultsPath;
  275. /*
  276. var: keyTimeout
  277. The timeout used between a keystroke and when a search is performed.
  278. */
  279. this.keyTimeout = 0;
  280. /*
  281. var: keyTimeoutLength
  282. The length of <keyTimeout> in thousandths of a second.
  283. */
  284. this.keyTimeoutLength = 500;
  285. /*
  286. var: lastSearchValue
  287. The last search string executed, or an empty string if none.
  288. */
  289. this.lastSearchValue = "";
  290. /*
  291. var: lastResultsPage
  292. The last results page. The value is only relevant if <lastSearchValue> is set.
  293. */
  294. this.lastResultsPage = "";
  295. /*
  296. var: deactivateTimeout
  297. The timeout used between when a control is deactivated and when the entire panel is deactivated. Is necessary
  298. because a control may be deactivated in favor of another control in the same panel, in which case it should stay
  299. active.
  300. */
  301. this.deactivateTimout = 0;
  302. /*
  303. var: deactivateTimeoutLength
  304. The length of <deactivateTimeout> in thousandths of a second.
  305. */
  306. this.deactivateTimeoutLength = 200;
  307. // Group: DOM Elements
  308. // ________________________________________________________________________
  309. // Function: DOMSearchField
  310. this.DOMSearchField = function()
  311. { return document.getElementById("MSearchField"); };
  312. // Function: DOMSearchType
  313. this.DOMSearchType = function()
  314. { return document.getElementById("MSearchType"); };
  315. // Function: DOMPopupSearchResults
  316. this.DOMPopupSearchResults = function()
  317. { return document.getElementById("MSearchResults"); };
  318. // Function: DOMPopupSearchResultsWindow
  319. this.DOMPopupSearchResultsWindow = function()
  320. { return document.getElementById("MSearchResultsWindow"); };
  321. // Function: DOMSearchPanel
  322. this.DOMSearchPanel = function()
  323. { return document.getElementById("MSearchPanel"); };
  324. // Group: Event Handlers
  325. // ________________________________________________________________________
  326. /*
  327. Function: OnSearchFieldFocus
  328. Called when focus is added or removed from the search field.
  329. */
  330. this.OnSearchFieldFocus = function(isActive)
  331. {
  332. this.Activate(isActive);
  333. };
  334. /*
  335. Function: OnSearchFieldChange
  336. Called when the content of the search field is changed.
  337. */
  338. this.OnSearchFieldChange = function()
  339. {
  340. if (this.keyTimeout)
  341. {
  342. clearTimeout(this.keyTimeout);
  343. this.keyTimeout = 0;
  344. };
  345. var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
  346. if (searchValue != this.lastSearchValue)
  347. {
  348. if (searchValue != "")
  349. {
  350. this.keyTimeout = setTimeout(this.name + ".Search()", this.keyTimeoutLength);
  351. }
  352. else
  353. {
  354. if (this.mode == "HTML")
  355. { this.DOMPopupSearchResultsWindow().style.display = "none"; };
  356. this.lastSearchValue = "";
  357. };
  358. };
  359. };
  360. /*
  361. Function: OnSearchTypeFocus
  362. Called when focus is added or removed from the search type.
  363. */
  364. this.OnSearchTypeFocus = function(isActive)
  365. {
  366. this.Activate(isActive);
  367. };
  368. /*
  369. Function: OnSearchTypeChange
  370. Called when the search type is changed.
  371. */
  372. this.OnSearchTypeChange = function()
  373. {
  374. var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
  375. if (searchValue != "")
  376. {
  377. this.Search();
  378. };
  379. };
  380. // Group: Action Functions
  381. // ________________________________________________________________________
  382. /*
  383. Function: CloseResultsWindow
  384. Closes the results window.
  385. */
  386. this.CloseResultsWindow = function()
  387. {
  388. this.DOMPopupSearchResultsWindow().style.display = "none";
  389. this.Activate(false, true);
  390. };
  391. /*
  392. Function: Search
  393. Performs a search.
  394. */
  395. this.Search = function()
  396. {
  397. this.keyTimeout = 0;
  398. var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
  399. var searchTopic = this.DOMSearchType().value;
  400. var pageExtension = searchValue.substr(0,1);
  401. if (pageExtension.match(/^[a-z]/i))
  402. { pageExtension = pageExtension.toUpperCase(); }
  403. else if (pageExtension.match(/^[0-9]/))
  404. { pageExtension = 'Numbers'; }
  405. else
  406. { pageExtension = "Symbols"; };
  407. var resultsPage;
  408. var resultsPageWithSearch;
  409. var hasResultsPage;
  410. // indexSectionsWithContent is defined in searchdata.js
  411. if (indexSectionsWithContent[searchTopic][pageExtension] == true)
  412. {
  413. resultsPage = this.resultsPath + '/' + searchTopic + pageExtension + '.html';
  414. resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
  415. hasResultsPage = true;
  416. }
  417. else
  418. {
  419. resultsPage = this.resultsPath + '/NoResults.html';
  420. resultsPageWithSearch = resultsPage;
  421. hasResultsPage = false;
  422. };
  423. var resultsFrame;
  424. if (this.mode == "HTML")
  425. { resultsFrame = window.frames.MSearchResults; }
  426. else if (this.mode == "FramedHTML")
  427. { resultsFrame = window.top.frames['Content']; };
  428. if (resultsPage != this.lastResultsPage ||
  429. // Bug in IE. If everything becomes hidden in a run, none of them will be able to be reshown in the next for some
  430. // reason. It counts the right number of results, and you can even read the display as "block" after setting it, but it
  431. // just doesn't work in IE 6 or IE 7. So if we're on the right page but the previous search had no results, reload the
  432. // page anyway to get around the bug.
  433. (browserType == "IE" && hasResultsPage &&
  434. (!resultsFrame.searchResults || resultsFrame.searchResults.lastMatchCount == 0)) )
  435. {
  436. resultsFrame.location.href = resultsPageWithSearch;
  437. }
  438. // So if the results page is right and there's no IE bug, reperform the search on the existing page. We have to check if there
  439. // are results because NoResults.html doesn't have any JavaScript, and it would be useless to do anything on that page even
  440. // if it did.
  441. else if (hasResultsPage)
  442. {
  443. // We need to check if this exists in case the frame is present but didn't finish loading.
  444. if (resultsFrame.searchResults)
  445. { resultsFrame.searchResults.Search(searchValue); }
  446. // Otherwise just reload instead of waiting.
  447. else
  448. { resultsFrame.location.href = resultsPageWithSearch; };
  449. };
  450. var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
  451. if (this.mode == "HTML" && domPopupSearchResultsWindow.style.display != "block")
  452. {
  453. var domSearchType = this.DOMSearchType();
  454. var left = GetXPosition(domSearchType);
  455. var top = GetYPosition(domSearchType) + domSearchType.offsetHeight;
  456. MoveToPosition(domPopupSearchResultsWindow, left, top);
  457. domPopupSearchResultsWindow.style.display = 'block';
  458. };
  459. this.lastSearchValue = searchValue;
  460. this.lastResultsPage = resultsPage;
  461. };
  462. // Group: Activation Functions
  463. // Functions that handle whether the entire panel is active or not.
  464. // ________________________________________________________________________
  465. /*
  466. Function: Activate
  467. Activates or deactivates the search panel, resetting things to their default values if necessary. You can call this on every
  468. control's OnBlur() and it will handle not deactivating the entire panel when focus is just switching between them transparently.
  469. Parameters:
  470. isActive - Whether you're activating or deactivating the panel.
  471. ignoreDeactivateDelay - Set if you're positive the action will deactivate the panel and thus want to skip the delay.
  472. */
  473. this.Activate = function(isActive, ignoreDeactivateDelay)
  474. {
  475. // We want to ignore isActive being false while the results window is open.
  476. if (isActive || (this.mode == "HTML" && this.DOMPopupSearchResultsWindow().style.display == "block"))
  477. {
  478. if (this.inactivateTimeout)
  479. {
  480. clearTimeout(this.inactivateTimeout);
  481. this.inactivateTimeout = 0;
  482. };
  483. this.DOMSearchPanel().className = 'MSearchPanelActive';
  484. var searchField = this.DOMSearchField();
  485. if (searchField.value == 'Search')
  486. { searchField.value = ""; }
  487. }
  488. else if (!ignoreDeactivateDelay)
  489. {
  490. this.inactivateTimeout = setTimeout(this.name + ".InactivateAfterTimeout()", this.inactivateTimeoutLength);
  491. }
  492. else
  493. {
  494. this.InactivateAfterTimeout();
  495. };
  496. };
  497. /*
  498. Function: InactivateAfterTimeout
  499. Called by <inactivateTimeout>, which is set by <Activate()>. Inactivation occurs on a timeout because a control may
  500. receive OnBlur() when focus is really transferring to another control in the search panel. In this case we don't want to
  501. actually deactivate the panel because not only would that cause a visible flicker but it could also reset the search value.
  502. So by doing it on a timeout instead, there's a short period where the second control's OnFocus() can cancel the deactivation.
  503. */
  504. this.InactivateAfterTimeout = function()
  505. {
  506. this.inactivateTimeout = 0;
  507. this.DOMSearchPanel().className = 'MSearchPanelInactive';
  508. this.DOMSearchField().value = "Search";
  509. this.lastSearchValue = "";
  510. this.lastResultsPage = "";
  511. };
  512. };
  513. /* ________________________________________________________________________________________________________
  514. Class: SearchResults
  515. _________________________________________________________________________________________________________
  516. The class that handles everything on the search results page.
  517. _________________________________________________________________________________________________________
  518. */
  519. function SearchResults(name, mode)
  520. {
  521. /*
  522. var: mode
  523. The mode the search is going to work in, such as "HTML" or "FramedHTML".
  524. */
  525. this.mode = mode;
  526. /*
  527. var: lastMatchCount
  528. The number of matches from the last run of <Search()>.
  529. */
  530. this.lastMatchCount = 0;
  531. /*
  532. Function: Toggle
  533. Toggles the visibility of the passed element ID.
  534. */
  535. this.Toggle = function(id)
  536. {
  537. if (this.mode == "FramedHTML")
  538. { return; };
  539. var parentElement = document.getElementById(id);
  540. var element = parentElement.firstChild;
  541. while (element && element != parentElement)
  542. {
  543. if (element.nodeName == 'DIV' && element.className == 'ISubIndex')
  544. {
  545. if (element.style.display == 'block')
  546. { element.style.display = "none"; }
  547. else
  548. { element.style.display = 'block'; }
  549. };
  550. if (element.nodeName == 'DIV' && element.hasChildNodes())
  551. { element = element.firstChild; }
  552. else if (element.nextSibling)
  553. { element = element.nextSibling; }
  554. else
  555. {
  556. do
  557. {
  558. element = element.parentNode;
  559. }
  560. while (element && element != parentElement && !element.nextSibling);
  561. if (element && element != parentElement)
  562. { element = element.nextSibling; };
  563. };
  564. };
  565. };
  566. /*
  567. Function: Search
  568. Searches for the passed string. If there is no parameter, it takes it from the URL query.
  569. Always returns true, since other documents may try to call it and that may or may not be possible.
  570. */
  571. this.Search = function(search)
  572. {
  573. if (!search)
  574. {
  575. search = window.location.search;
  576. search = search.substring(1); // Remove the leading ?
  577. search = unescape(search);
  578. };
  579. search = search.replace(/^ +/, "");
  580. search = search.replace(/ +$/, "");
  581. search = search.toLowerCase();
  582. if (search.match(/[^a-z0-9]/)) // Just a little speedup so it doesn't have to go through the below unnecessarily.
  583. {
  584. search = search.replace(/\_/g, "_und");
  585. search = search.replace(/\ +/gi, "_spc");
  586. search = search.replace(/\~/g, "_til");
  587. search = search.replace(/\!/g, "_exc");
  588. search = search.replace(/\@/g, "_att");
  589. search = search.replace(/\#/g, "_num");
  590. search = search.replace(/\$/g, "_dol");
  591. search = search.replace(/\%/g, "_pct");
  592. search = search.replace(/\^/g, "_car");
  593. search = search.replace(/\&/g, "_amp");
  594. search = search.replace(/\*/g, "_ast");
  595. search = search.replace(/\(/g, "_lpa");
  596. search = search.replace(/\)/g, "_rpa");
  597. search = search.replace(/\-/g, "_min");
  598. search = search.replace(/\+/g, "_plu");
  599. search = search.replace(/\=/g, "_equ");
  600. search = search.replace(/\{/g, "_lbc");
  601. search = search.replace(/\}/g, "_rbc");
  602. search = search.replace(/\[/g, "_lbk");
  603. search = search.replace(/\]/g, "_rbk");
  604. search = search.replace(/\:/g, "_col");
  605. search = search.replace(/\;/g, "_sco");
  606. search = search.replace(/\"/g, "_quo");
  607. search = search.replace(/\'/g, "_apo");
  608. search = search.replace(/\</g, "_lan");
  609. search = search.replace(/\>/g, "_ran");
  610. search = search.replace(/\,/g, "_com");
  611. search = search.replace(/\./g, "_per");
  612. search = search.replace(/\?/g, "_que");
  613. search = search.replace(/\//g, "_sla");
  614. search = search.replace(/[^a-z0-9\_]i/gi, "_zzz");
  615. };
  616. var resultRows = document.getElementsByTagName("div");
  617. var matches = 0;
  618. var i = 0;
  619. while (i < resultRows.length)
  620. {
  621. var row = resultRows.item(i);
  622. if (row.className == "SRResult")
  623. {
  624. var rowMatchName = row.id.toLowerCase();
  625. rowMatchName = rowMatchName.replace(/^sr\d*_/, '');
  626. if (search.length <= rowMatchName.length && rowMatchName.substr(0, search.length) == search)
  627. {
  628. row.style.display = "block";
  629. matches++;
  630. }
  631. else
  632. { row.style.display = "none"; };
  633. };
  634. i++;
  635. };
  636. document.getElementById("Searching").style.display="none";
  637. if (matches == 0)
  638. { document.getElementById("NoMatches").style.display="block"; }
  639. else
  640. { document.getElementById("NoMatches").style.display="none"; }
  641. this.lastMatchCount = matches;
  642. return true;
  643. };
  644. };