main.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  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. if(searchPanel){
  217. var searchField=searchPanel.DOMSearchField();
  218. if(!searchField.placeholder){
  219. searchField.value="Search";
  220. }
  221. }
  222. document.onclick=function(){
  223. if(searchPanel){
  224. var show=(searchPanel.DOMPopupSearchResultsWindow().style.display == "block");
  225. if(show){
  226. searchPanel.CloseResultsWindow();
  227. }
  228. }
  229. }
  230. };
  231. var resizeTimer = 0;
  232. function NDOnResize()
  233. {
  234. if (resizeTimer != 0)
  235. { clearTimeout(resizeTimer); };
  236. resizeTimer = setTimeout(NDDoResize, 250);
  237. };
  238. function NDDoResize()
  239. {
  240. var scrollboxes = document.getElementsByTagName('blockquote');
  241. var i;
  242. var item;
  243. i = 0;
  244. while (item = scrollboxes.item(i))
  245. {
  246. item.style.width = 100;
  247. i++;
  248. };
  249. i = 0;
  250. while (item = scrollboxes.item(i))
  251. {
  252. item.style.width = item.parentNode.offsetWidth;
  253. i++;
  254. };
  255. clearTimeout(resizeTimer);
  256. resizeTimer = 0;
  257. }
  258. /* ________________________________________________________________________________________________________
  259. Class: SearchPanel
  260. ________________________________________________________________________________________________________
  261. A class handling everything associated with the search panel.
  262. Parameters:
  263. name - The name of the global variable that will be storing this instance. Is needed to be able to set timeouts.
  264. mode - The mode the search is going to work in. Pass <NaturalDocs::Builder::Base->CommandLineOption()>, so the
  265. value will be something like "HTML" or "FramedHTML".
  266. ________________________________________________________________________________________________________
  267. */
  268. function SearchPanel(name, mode, resultsPath)
  269. {
  270. if (!name || !mode || !resultsPath)
  271. { alert("Incorrect parameters to SearchPanel."); };
  272. // Group: Variables
  273. // ________________________________________________________________________
  274. /*
  275. var: name
  276. The name of the global variable that will be storing this instance of the class.
  277. */
  278. this.name = name;
  279. /*
  280. var: mode
  281. The mode the search is going to work in, such as "HTML" or "FramedHTML".
  282. */
  283. this.mode = mode;
  284. /*
  285. var: resultsPath
  286. The relative path from the current HTML page to the results page directory.
  287. */
  288. this.resultsPath = resultsPath;
  289. /*
  290. var: keyTimeout
  291. The timeout used between a keystroke and when a search is performed.
  292. */
  293. this.keyTimeout = 0;
  294. /*
  295. var: keyTimeoutLength
  296. The length of <keyTimeout> in thousandths of a second.
  297. */
  298. this.keyTimeoutLength = 500;
  299. /*
  300. var: lastSearchValue
  301. The last search string executed, or an empty string if none.
  302. */
  303. this.lastSearchValue = "";
  304. /*
  305. var: lastResultsPage
  306. The last results page. The value is only relevant if <lastSearchValue> is set.
  307. */
  308. this.lastResultsPage = "";
  309. /*
  310. var: deactivateTimeout
  311. The timeout used between when a control is deactivated and when the entire panel is deactivated. Is necessary
  312. because a control may be deactivated in favor of another control in the same panel, in which case it should stay
  313. active.
  314. */
  315. this.deactivateTimout = 0;
  316. /*
  317. var: deactivateTimeoutLength
  318. The length of <deactivateTimeout> in thousandths of a second.
  319. */
  320. this.deactivateTimeoutLength = 200;
  321. // Group: DOM Elements
  322. // ________________________________________________________________________
  323. // Function: DOMSearchField
  324. this.DOMSearchField = function()
  325. { return document.getElementById("MSearchField"); };
  326. // Function: DOMSearchType
  327. this.DOMSearchType = function()
  328. { return document.getElementById("MSearchType"); };
  329. // Function: DOMPopupSearchResults
  330. this.DOMPopupSearchResults = function()
  331. { return document.getElementById("MSearchResults"); };
  332. // Function: DOMPopupSearchResultsWindow
  333. this.DOMPopupSearchResultsWindow = function()
  334. { return document.getElementById("MSearchResultsWindow"); };
  335. // Function: DOMSearchPanel
  336. this.DOMSearchPanel = function()
  337. { return document.getElementById("MSearchPanel"); };
  338. // Group: Event Handlers
  339. // ________________________________________________________________________
  340. /*
  341. Function: OnSearchFieldFocus
  342. Called when focus is added or removed from the search field.
  343. */
  344. this.OnSearchFieldFocus = function(isActive)
  345. {
  346. this.Activate(isActive);
  347. };
  348. /*
  349. Function: OnSearchFieldChange
  350. Called when the content of the search field is changed.
  351. */
  352. this.OnSearchFieldChange = function()
  353. {
  354. if (this.keyTimeout)
  355. {
  356. clearTimeout(this.keyTimeout);
  357. this.keyTimeout = 0;
  358. };
  359. var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
  360. if (searchValue != this.lastSearchValue)
  361. {
  362. if (searchValue != "")
  363. {
  364. this.keyTimeout = setTimeout(this.name + ".Search()", this.keyTimeoutLength);
  365. }
  366. else
  367. {
  368. if (this.mode == "HTML")
  369. { this.DOMPopupSearchResultsWindow().style.display = "none"; };
  370. this.lastSearchValue = "";
  371. };
  372. };
  373. };
  374. /*
  375. Function: OnSearchTypeFocus
  376. Called when focus is added or removed from the search type.
  377. */
  378. this.OnSearchTypeFocus = function(isActive)
  379. {
  380. this.Activate(isActive);
  381. };
  382. /*
  383. Function: OnSearchTypeChange
  384. Called when the search type is changed.
  385. */
  386. this.OnSearchTypeChange = function()
  387. {
  388. var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
  389. if (searchValue != "")
  390. {
  391. this.Search();
  392. };
  393. };
  394. // Group: Action Functions
  395. // ________________________________________________________________________
  396. /*
  397. Function: CloseResultsWindow
  398. Closes the results window.
  399. */
  400. this.CloseResultsWindow = function()
  401. {
  402. this.DOMPopupSearchResultsWindow().style.display = "none";
  403. this.Activate(false, true);
  404. };
  405. /*
  406. Function: Search
  407. Performs a search.
  408. */
  409. this.Search = function()
  410. {
  411. this.keyTimeout = 0;
  412. var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
  413. var searchTopic = this.DOMSearchType().value;
  414. var pageExtension = searchValue.substr(0,1);
  415. if (pageExtension.match(/^[a-z]/i))
  416. { pageExtension = pageExtension.toUpperCase(); }
  417. else if (pageExtension.match(/^[0-9]/))
  418. { pageExtension = 'Numbers'; }
  419. else
  420. { pageExtension = "Symbols"; };
  421. var resultsPage;
  422. var resultsPageWithSearch;
  423. var hasResultsPage;
  424. // indexSectionsWithContent is defined in searchdata.js
  425. if (indexSectionsWithContent[searchTopic][pageExtension] == true)
  426. {
  427. resultsPage = this.resultsPath + '/' + searchTopic + pageExtension + '.html';
  428. resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
  429. hasResultsPage = true;
  430. }
  431. else
  432. {
  433. resultsPage = this.resultsPath + '/NoResults.html';
  434. resultsPageWithSearch = resultsPage;
  435. hasResultsPage = false;
  436. };
  437. var resultsFrame;
  438. if (this.mode == "HTML")
  439. { resultsFrame = window.frames.MSearchResults; }
  440. else if (this.mode == "FramedHTML")
  441. { resultsFrame = window.top.frames['Content']; };
  442. if (resultsPage != this.lastResultsPage ||
  443. // Bug in IE. If everything becomes hidden in a run, none of them will be able to be reshown in the next for some
  444. // reason. It counts the right number of results, and you can even read the display as "block" after setting it, but it
  445. // 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
  446. // page anyway to get around the bug.
  447. (browserType == "IE" && hasResultsPage &&
  448. (!resultsFrame.searchResults || resultsFrame.searchResults.lastMatchCount == 0)) )
  449. {
  450. resultsFrame.location.href = resultsPageWithSearch;
  451. }
  452. // 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
  453. // are results because NoResults.html doesn't have any JavaScript, and it would be useless to do anything on that page even
  454. // if it did.
  455. else if (hasResultsPage)
  456. {
  457. // We need to check if this exists in case the frame is present but didn't finish loading.
  458. if (resultsFrame.searchResults)
  459. { resultsFrame.searchResults.Search(searchValue); }
  460. // Otherwise just reload instead of waiting.
  461. else
  462. { resultsFrame.location.href = resultsPageWithSearch; };
  463. };
  464. var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
  465. if (this.mode == "HTML" && domPopupSearchResultsWindow.style.display != "block")
  466. {
  467. var domSearchType = this.DOMSearchType();
  468. var left = GetXPosition(domSearchType);
  469. var top = GetYPosition(domSearchType) + domSearchType.offsetHeight;
  470. MoveToPosition(domPopupSearchResultsWindow, left, top);
  471. domPopupSearchResultsWindow.style.display = 'block';
  472. };
  473. this.lastSearchValue = searchValue;
  474. this.lastResultsPage = resultsPage;
  475. };
  476. // Group: Activation Functions
  477. // Functions that handle whether the entire panel is active or not.
  478. // ________________________________________________________________________
  479. /*
  480. Function: Activate
  481. Activates or deactivates the search panel, resetting things to their default values if necessary. You can call this on every
  482. control's OnBlur() and it will handle not deactivating the entire panel when focus is just switching between them transparently.
  483. Parameters:
  484. isActive - Whether you're activating or deactivating the panel.
  485. ignoreDeactivateDelay - Set if you're positive the action will deactivate the panel and thus want to skip the delay.
  486. */
  487. this.Activate = function(isActive, ignoreDeactivateDelay)
  488. {
  489. // We want to ignore isActive being false while the results window is open.
  490. if (isActive || (this.mode == "HTML" && this.DOMPopupSearchResultsWindow().style.display == "block"))
  491. {
  492. if (this.inactivateTimeout)
  493. {
  494. clearTimeout(this.inactivateTimeout);
  495. this.inactivateTimeout = 0;
  496. };
  497. this.DOMSearchPanel().className = 'MSearchPanelActive';
  498. var searchField = this.DOMSearchField();
  499. if (!searchField.placeholder&&searchField.value == 'Search')
  500. { searchField.value = ""; }
  501. }
  502. else if (!ignoreDeactivateDelay)
  503. {
  504. this.inactivateTimeout = setTimeout(this.name + ".InactivateAfterTimeout()", this.inactivateTimeoutLength);
  505. }
  506. else
  507. {
  508. this.InactivateAfterTimeout();
  509. };
  510. };
  511. /*
  512. Function: InactivateAfterTimeout
  513. Called by <inactivateTimeout>, which is set by <Activate()>. Inactivation occurs on a timeout because a control may
  514. receive OnBlur() when focus is really transferring to another control in the search panel. In this case we don't want to
  515. actually deactivate the panel because not only would that cause a visible flicker but it could also reset the search value.
  516. So by doing it on a timeout instead, there's a short period where the second control's OnFocus() can cancel the deactivation.
  517. */
  518. this.InactivateAfterTimeout = function()
  519. {
  520. this.inactivateTimeout = 0;
  521. this.DOMSearchPanel().className = 'MSearchPanelInactive';
  522. var searchField=this.DOMSearchField();
  523. if(searchField.placeholder){
  524. searchField.value = "";
  525. }else{
  526. searchField.value = "Search";
  527. }
  528. this.lastSearchValue = "";
  529. this.lastResultsPage = "";
  530. };
  531. };
  532. /* ________________________________________________________________________________________________________
  533. Class: SearchResults
  534. _________________________________________________________________________________________________________
  535. The class that handles everything on the search results page.
  536. _________________________________________________________________________________________________________
  537. */
  538. function SearchResults(name, mode)
  539. {
  540. /*
  541. var: mode
  542. The mode the search is going to work in, such as "HTML" or "FramedHTML".
  543. */
  544. this.mode = mode;
  545. /*
  546. var: lastMatchCount
  547. The number of matches from the last run of <Search()>.
  548. */
  549. this.lastMatchCount = 0;
  550. /*
  551. Function: Toggle
  552. Toggles the visibility of the passed element ID.
  553. */
  554. this.Toggle = function(id)
  555. {
  556. if (this.mode == "FramedHTML")
  557. { return; };
  558. var parentElement = document.getElementById(id);
  559. var element = parentElement.firstChild;
  560. while (element && element != parentElement)
  561. {
  562. if (element.nodeName == 'DIV' && element.className == 'ISubIndex')
  563. {
  564. if (element.style.display == 'block')
  565. { element.style.display = "none"; }
  566. else
  567. { element.style.display = 'block'; }
  568. };
  569. if (element.nodeName == 'DIV' && element.hasChildNodes())
  570. { element = element.firstChild; }
  571. else if (element.nextSibling)
  572. { element = element.nextSibling; }
  573. else
  574. {
  575. do
  576. {
  577. element = element.parentNode;
  578. }
  579. while (element && element != parentElement && !element.nextSibling);
  580. if (element && element != parentElement)
  581. { element = element.nextSibling; };
  582. };
  583. };
  584. };
  585. /*
  586. Function: Search
  587. Searches for the passed string. If there is no parameter, it takes it from the URL query.
  588. Always returns true, since other documents may try to call it and that may or may not be possible.
  589. */
  590. this.Search = function(search)
  591. {
  592. if (!search)
  593. {
  594. search = window.location.search;
  595. search = search.substring(1); // Remove the leading ?
  596. search = unescape(search);
  597. };
  598. search = search.replace(/^ +/, "");
  599. search = search.replace(/ +$/, "");
  600. search = search.toLowerCase();
  601. if (search.match(/[^a-z0-9]/)) // Just a little speedup so it doesn't have to go through the below unnecessarily.
  602. {
  603. search = search.replace(/\_/g, "_und");
  604. search = search.replace(/\ +/gi, "_spc");
  605. search = search.replace(/\~/g, "_til");
  606. search = search.replace(/\!/g, "_exc");
  607. search = search.replace(/\@/g, "_att");
  608. search = search.replace(/\#/g, "_num");
  609. search = search.replace(/\$/g, "_dol");
  610. search = search.replace(/\%/g, "_pct");
  611. search = search.replace(/\^/g, "_car");
  612. search = search.replace(/\&/g, "_amp");
  613. search = search.replace(/\*/g, "_ast");
  614. search = search.replace(/\(/g, "_lpa");
  615. search = search.replace(/\)/g, "_rpa");
  616. search = search.replace(/\-/g, "_min");
  617. search = search.replace(/\+/g, "_plu");
  618. search = search.replace(/\=/g, "_equ");
  619. search = search.replace(/\{/g, "_lbc");
  620. search = search.replace(/\}/g, "_rbc");
  621. search = search.replace(/\[/g, "_lbk");
  622. search = search.replace(/\]/g, "_rbk");
  623. search = search.replace(/\:/g, "_col");
  624. search = search.replace(/\;/g, "_sco");
  625. search = search.replace(/\"/g, "_quo");
  626. search = search.replace(/\'/g, "_apo");
  627. search = search.replace(/\</g, "_lan");
  628. search = search.replace(/\>/g, "_ran");
  629. search = search.replace(/\,/g, "_com");
  630. search = search.replace(/\./g, "_per");
  631. search = search.replace(/\?/g, "_que");
  632. search = search.replace(/\//g, "_sla");
  633. search = search.replace(/[^a-z0-9\_]i/gi, "_zzz");
  634. };
  635. var resultRows = document.getElementsByTagName("div");
  636. var matches = 0;
  637. var i = 0;
  638. while (i < resultRows.length)
  639. {
  640. var row = resultRows.item(i);
  641. if (row.className == "SRResult")
  642. {
  643. var rowMatchName = row.id.toLowerCase();
  644. rowMatchName = rowMatchName.replace(/^sr\d*_/, '');
  645. if (search.length <= rowMatchName.length && rowMatchName.substr(0, search.length) == search)
  646. {
  647. row.style.display = "block";
  648. matches++;
  649. }
  650. else
  651. { row.style.display = "none"; };
  652. };
  653. i++;
  654. };
  655. document.getElementById("Searching").style.display="none";
  656. if (matches == 0)
  657. { document.getElementById("NoMatches").style.display="block"; }
  658. else
  659. { document.getElementById("NoMatches").style.display="none"; }
  660. this.lastMatchCount = matches;
  661. return true;
  662. };
  663. };