flatmax@592: // Search script generated by doxygen flatmax@592: // Copyright (C) 2009 by Dimitri van Heesch. flatmax@592: flatmax@592: // The code in this file is loosly based on main.js, part of Natural Docs, flatmax@592: // which is Copyright (C) 2003-2008 Greg Valure flatmax@592: // Natural Docs is licensed under the GPL. flatmax@592: flatmax@592: var indexSectionsWithContent = flatmax@592: { flatmax@592: 0: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101111011100111100110100010001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", flatmax@592: 1: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101010001000000100100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", flatmax@592: 2: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101010001000000100100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", flatmax@592: 3: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101010001000000100100000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", flatmax@592: 4: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101111011100111100110100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", flatmax@592: 5: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", flatmax@592: 6: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" flatmax@592: }; flatmax@592: flatmax@592: var indexSectionNames = flatmax@592: { flatmax@592: 0: "all", flatmax@592: 1: "classes", flatmax@592: 2: "files", flatmax@592: 3: "functions", flatmax@592: 4: "variables", flatmax@592: 5: "typedefs", flatmax@592: 6: "defines" flatmax@592: }; flatmax@592: flatmax@592: function convertToId(search) flatmax@592: { flatmax@592: var result = ''; flatmax@592: for (i=0;i do a search flatmax@592: { flatmax@592: this.Search(); flatmax@592: } flatmax@592: } flatmax@592: flatmax@592: this.OnSearchSelectKey = function(evt) flatmax@592: { flatmax@592: var e = (evt) ? evt : window.event; // for IE flatmax@592: if (e.keyCode==40 && this.searchIndex0) // Up flatmax@592: { flatmax@592: this.searchIndex--; flatmax@592: this.OnSelectItem(this.searchIndex); flatmax@592: } flatmax@592: else if (e.keyCode==13 || e.keyCode==27) flatmax@592: { flatmax@592: this.OnSelectItem(this.searchIndex); flatmax@592: this.CloseSelectionWindow(); flatmax@592: this.DOMSearchField().focus(); flatmax@592: } flatmax@592: return false; flatmax@592: } flatmax@592: flatmax@592: // --------- Actions flatmax@592: flatmax@592: // Closes the results window. flatmax@592: this.CloseResultsWindow = function() flatmax@592: { flatmax@592: this.DOMPopupSearchResultsWindow().style.display = 'none'; flatmax@592: this.DOMSearchClose().style.display = 'none'; flatmax@592: this.Activate(false); flatmax@592: } flatmax@592: flatmax@592: this.CloseSelectionWindow = function() flatmax@592: { flatmax@592: this.DOMSearchSelectWindow().style.display = 'none'; flatmax@592: } flatmax@592: flatmax@592: // Performs a search. flatmax@592: this.Search = function() flatmax@592: { flatmax@592: this.keyTimeout = 0; flatmax@592: flatmax@592: // strip leading whitespace flatmax@592: var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); flatmax@592: flatmax@592: var code = searchValue.toLowerCase().charCodeAt(0); flatmax@592: var hexCode; flatmax@592: if (code<16) flatmax@592: { flatmax@592: hexCode="0"+code.toString(16); flatmax@592: } flatmax@592: else flatmax@592: { flatmax@592: hexCode=code.toString(16); flatmax@592: } flatmax@592: flatmax@592: var resultsPage; flatmax@592: var resultsPageWithSearch; flatmax@592: var hasResultsPage; flatmax@592: flatmax@592: if (indexSectionsWithContent[this.searchIndex].charAt(code) == '1') flatmax@592: { flatmax@592: resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html'; flatmax@592: resultsPageWithSearch = resultsPage+'?'+escape(searchValue); flatmax@592: hasResultsPage = true; flatmax@592: } flatmax@592: else // nothing available for this search term flatmax@592: { flatmax@592: resultsPage = this.resultsPath + '/nomatches.html'; flatmax@592: resultsPageWithSearch = resultsPage; flatmax@592: hasResultsPage = false; flatmax@592: } flatmax@592: flatmax@592: window.frames.MSearchResults.location = resultsPageWithSearch; flatmax@592: var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); flatmax@592: flatmax@592: if (domPopupSearchResultsWindow.style.display!='block') flatmax@592: { flatmax@592: var domSearchBox = this.DOMSearchBox(); flatmax@592: this.DOMSearchClose().style.display = 'inline'; flatmax@592: if (this.insideFrame) flatmax@592: { flatmax@592: var domPopupSearchResults = this.DOMPopupSearchResults(); flatmax@592: domPopupSearchResultsWindow.style.position = 'relative'; flatmax@592: domPopupSearchResultsWindow.style.display = 'block'; flatmax@592: var width = document.body.clientWidth - 8; // the -8 is for IE :-( flatmax@592: domPopupSearchResultsWindow.style.width = width + 'px'; flatmax@592: domPopupSearchResults.style.width = width + 'px'; flatmax@592: } flatmax@592: else flatmax@592: { flatmax@592: var domPopupSearchResults = this.DOMPopupSearchResults(); flatmax@592: var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; flatmax@592: var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; flatmax@592: domPopupSearchResultsWindow.style.display = 'block'; flatmax@592: left -= domPopupSearchResults.offsetWidth; flatmax@592: domPopupSearchResultsWindow.style.top = top + 'px'; flatmax@592: domPopupSearchResultsWindow.style.left = left + 'px'; flatmax@592: } flatmax@592: } flatmax@592: flatmax@592: this.lastSearchValue = searchValue; flatmax@592: this.lastResultsPage = resultsPage; flatmax@592: } flatmax@592: flatmax@592: // -------- Activation Functions flatmax@592: flatmax@592: // Activates or deactivates the search panel, resetting things to flatmax@592: // their default values if necessary. flatmax@592: this.Activate = function(isActive) flatmax@592: { flatmax@592: if (isActive || // open it flatmax@592: this.DOMPopupSearchResultsWindow().style.display == 'block' flatmax@592: ) flatmax@592: { flatmax@592: this.DOMSearchBox().className = 'MSearchBoxActive'; flatmax@592: flatmax@592: var searchField = this.DOMSearchField(); flatmax@592: flatmax@592: if (searchField.value == this.searchLabel) // clear "Search" term upon entry flatmax@592: { flatmax@592: searchField.value = ''; flatmax@592: this.searchActive = true; flatmax@592: } flatmax@592: } flatmax@592: else if (!isActive) // directly remove the panel flatmax@592: { flatmax@592: this.DOMSearchBox().className = 'MSearchBoxInactive'; flatmax@592: this.DOMSearchField().value = this.searchLabel; flatmax@592: this.searchActive = false; flatmax@592: this.lastSearchValue = '' flatmax@592: this.lastResultsPage = ''; flatmax@592: } flatmax@592: } flatmax@592: } flatmax@592: flatmax@592: // ----------------------------------------------------------------------- flatmax@592: flatmax@592: // The class that handles everything on the search results page. flatmax@592: function SearchResults(name) flatmax@592: { flatmax@592: // The number of matches from the last run of . flatmax@592: this.lastMatchCount = 0; flatmax@592: this.lastKey = 0; flatmax@592: this.repeatOn = false; flatmax@592: flatmax@592: // Toggles the visibility of the passed element ID. flatmax@592: this.FindChildElement = function(id) flatmax@592: { flatmax@592: var parentElement = document.getElementById(id); flatmax@592: var element = parentElement.firstChild; flatmax@592: flatmax@592: while (element && element!=parentElement) flatmax@592: { flatmax@592: if (element.nodeName == 'DIV' && element.className == 'SRChildren') flatmax@592: { flatmax@592: return element; flatmax@592: } flatmax@592: flatmax@592: if (element.nodeName == 'DIV' && element.hasChildNodes()) flatmax@592: { flatmax@592: element = element.firstChild; flatmax@592: } flatmax@592: else if (element.nextSibling) flatmax@592: { flatmax@592: element = element.nextSibling; flatmax@592: } flatmax@592: else flatmax@592: { flatmax@592: do flatmax@592: { flatmax@592: element = element.parentNode; flatmax@592: } flatmax@592: while (element && element!=parentElement && !element.nextSibling); flatmax@592: flatmax@592: if (element && element!=parentElement) flatmax@592: { flatmax@592: element = element.nextSibling; flatmax@592: } flatmax@592: } flatmax@592: } flatmax@592: } flatmax@592: flatmax@592: this.Toggle = function(id) flatmax@592: { flatmax@592: var element = this.FindChildElement(id); flatmax@592: if (element) flatmax@592: { flatmax@592: if (element.style.display == 'block') flatmax@592: { flatmax@592: element.style.display = 'none'; flatmax@592: } flatmax@592: else flatmax@592: { flatmax@592: element.style.display = 'block'; flatmax@592: } flatmax@592: } flatmax@592: } flatmax@592: flatmax@592: // Searches for the passed string. If there is no parameter, flatmax@592: // it takes it from the URL query. flatmax@592: // flatmax@592: // Always returns true, since other documents may try to call it flatmax@592: // and that may or may not be possible. flatmax@592: this.Search = function(search) flatmax@592: { flatmax@592: if (!search) // get search word from URL flatmax@592: { flatmax@592: search = window.location.search; flatmax@592: search = search.substring(1); // Remove the leading '?' flatmax@592: search = unescape(search); flatmax@592: } flatmax@592: flatmax@592: search = search.replace(/^ +/, ""); // strip leading spaces flatmax@592: search = search.replace(/ +$/, ""); // strip trailing spaces flatmax@592: search = search.toLowerCase(); flatmax@592: search = convertToId(search); flatmax@592: flatmax@592: var resultRows = document.getElementsByTagName("div"); flatmax@592: var matches = 0; flatmax@592: flatmax@592: var i = 0; flatmax@592: while (i < resultRows.length) flatmax@592: { flatmax@592: var row = resultRows.item(i); flatmax@592: if (row.className == "SRResult") flatmax@592: { flatmax@592: var rowMatchName = row.id.toLowerCase(); flatmax@592: rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' flatmax@592: flatmax@592: if (search.length<=rowMatchName.length && flatmax@592: rowMatchName.substr(0, search.length)==search) flatmax@592: { flatmax@592: row.style.display = 'block'; flatmax@592: matches++; flatmax@592: } flatmax@592: else flatmax@592: { flatmax@592: row.style.display = 'none'; flatmax@592: } flatmax@592: } flatmax@592: i++; flatmax@592: } flatmax@592: document.getElementById("Searching").style.display='none'; flatmax@592: if (matches == 0) // no results flatmax@592: { flatmax@592: document.getElementById("NoMatches").style.display='block'; flatmax@592: } flatmax@592: else // at least one result flatmax@592: { flatmax@592: document.getElementById("NoMatches").style.display='none'; flatmax@592: } flatmax@592: this.lastMatchCount = matches; flatmax@592: return true; flatmax@592: } flatmax@592: flatmax@592: // return the first item with index index or higher that is visible flatmax@592: this.NavNext = function(index) flatmax@592: { flatmax@592: var focusItem; flatmax@592: while (1) flatmax@592: { flatmax@592: var focusName = 'Item'+index; flatmax@592: focusItem = document.getElementById(focusName); flatmax@592: if (focusItem && focusItem.parentNode.parentNode.style.display=='block') flatmax@592: { flatmax@592: break; flatmax@592: } flatmax@592: else if (!focusItem) // last element flatmax@592: { flatmax@592: break; flatmax@592: } flatmax@592: focusItem=null; flatmax@592: index++; flatmax@592: } flatmax@592: return focusItem; flatmax@592: } flatmax@592: flatmax@592: this.NavPrev = function(index) flatmax@592: { flatmax@592: var focusItem; flatmax@592: while (1) flatmax@592: { flatmax@592: var focusName = 'Item'+index; flatmax@592: focusItem = document.getElementById(focusName); flatmax@592: if (focusItem && focusItem.parentNode.parentNode.style.display=='block') flatmax@592: { flatmax@592: break; flatmax@592: } flatmax@592: else if (!focusItem) // last element flatmax@592: { flatmax@592: break; flatmax@592: } flatmax@592: focusItem=null; flatmax@592: index--; flatmax@592: } flatmax@592: return focusItem; flatmax@592: } flatmax@592: flatmax@592: this.ProcessKeys = function(e) flatmax@592: { flatmax@592: if (e.type == "keydown") flatmax@592: { flatmax@592: this.repeatOn = false; flatmax@592: this.lastKey = e.keyCode; flatmax@592: } flatmax@592: else if (e.type == "keypress") flatmax@592: { flatmax@592: if (!this.repeatOn) flatmax@592: { flatmax@592: if (this.lastKey) this.repeatOn = true; flatmax@592: return false; // ignore first keypress after keydown flatmax@592: } flatmax@592: } flatmax@592: else if (e.type == "keyup") flatmax@592: { flatmax@592: this.lastKey = 0; flatmax@592: this.repeatOn = false; flatmax@592: } flatmax@592: return this.lastKey!=0; flatmax@592: } flatmax@592: flatmax@592: this.Nav = function(evt,itemIndex) flatmax@592: { flatmax@592: var e = (evt) ? evt : window.event; // for IE flatmax@592: if (e.keyCode==13) return true; flatmax@592: if (!this.ProcessKeys(e)) return false; flatmax@592: flatmax@592: if (this.lastKey==38) // Up flatmax@592: { flatmax@592: var newIndex = itemIndex-1; flatmax@592: var focusItem = this.NavPrev(newIndex); flatmax@592: if (focusItem) flatmax@592: { flatmax@592: var child = this.FindChildElement(focusItem.parentNode.parentNode.id); flatmax@592: if (child && child.style.display == 'block') // children visible flatmax@592: { flatmax@592: var n=0; flatmax@592: var tmpElem; flatmax@592: while (1) // search for last child flatmax@592: { flatmax@592: tmpElem = document.getElementById('Item'+newIndex+'_c'+n); flatmax@592: if (tmpElem) flatmax@592: { flatmax@592: focusItem = tmpElem; flatmax@592: } flatmax@592: else // found it! flatmax@592: { flatmax@592: break; flatmax@592: } flatmax@592: n++; flatmax@592: } flatmax@592: } flatmax@592: } flatmax@592: if (focusItem) flatmax@592: { flatmax@592: focusItem.focus(); flatmax@592: } flatmax@592: else // return focus to search field flatmax@592: { flatmax@592: parent.document.getElementById("MSearchField").focus(); flatmax@592: } flatmax@592: } flatmax@592: else if (this.lastKey==40) // Down flatmax@592: { flatmax@592: var newIndex = itemIndex+1; flatmax@592: var focusItem; flatmax@592: var item = document.getElementById('Item'+itemIndex); flatmax@592: var elem = this.FindChildElement(item.parentNode.parentNode.id); flatmax@592: if (elem && elem.style.display == 'block') // children visible flatmax@592: { flatmax@592: focusItem = document.getElementById('Item'+itemIndex+'_c0'); flatmax@592: } flatmax@592: if (!focusItem) focusItem = this.NavNext(newIndex); flatmax@592: if (focusItem) focusItem.focus(); flatmax@592: } flatmax@592: else if (this.lastKey==39) // Right flatmax@592: { flatmax@592: var item = document.getElementById('Item'+itemIndex); flatmax@592: var elem = this.FindChildElement(item.parentNode.parentNode.id); flatmax@592: if (elem) elem.style.display = 'block'; flatmax@592: } flatmax@592: else if (this.lastKey==37) // Left flatmax@592: { flatmax@592: var item = document.getElementById('Item'+itemIndex); flatmax@592: var elem = this.FindChildElement(item.parentNode.parentNode.id); flatmax@592: if (elem) elem.style.display = 'none'; flatmax@592: } flatmax@592: else if (this.lastKey==27) // Escape flatmax@592: { flatmax@592: parent.searchBox.CloseResultsWindow(); flatmax@592: parent.document.getElementById("MSearchField").focus(); flatmax@592: } flatmax@592: else if (this.lastKey==13) // Enter flatmax@592: { flatmax@592: return true; flatmax@592: } flatmax@592: return false; flatmax@592: } flatmax@592: flatmax@592: this.NavChild = function(evt,itemIndex,childIndex) flatmax@592: { flatmax@592: var e = (evt) ? evt : window.event; // for IE flatmax@592: if (e.keyCode==13) return true; flatmax@592: if (!this.ProcessKeys(e)) return false; flatmax@592: flatmax@592: if (this.lastKey==38) // Up flatmax@592: { flatmax@592: if (childIndex>0) flatmax@592: { flatmax@592: var newIndex = childIndex-1; flatmax@592: document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); flatmax@592: } flatmax@592: else // already at first child, jump to parent flatmax@592: { flatmax@592: document.getElementById('Item'+itemIndex).focus(); flatmax@592: } flatmax@592: } flatmax@592: else if (this.lastKey==40) // Down flatmax@592: { flatmax@592: var newIndex = childIndex+1; flatmax@592: var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); flatmax@592: if (!elem) // last child, jump to parent next parent flatmax@592: { flatmax@592: elem = this.NavNext(itemIndex+1); flatmax@592: } flatmax@592: if (elem) flatmax@592: { flatmax@592: elem.focus(); flatmax@592: } flatmax@592: } flatmax@592: else if (this.lastKey==27) // Escape flatmax@592: { flatmax@592: parent.searchBox.CloseResultsWindow(); flatmax@592: parent.document.getElementById("MSearchField").focus(); flatmax@592: } flatmax@592: else if (this.lastKey==13) // Enter flatmax@592: { flatmax@592: return true; flatmax@592: } flatmax@592: return false; flatmax@592: } flatmax@592: } flatmax@592: flatmax@592: function setKeyActions(elem,action) flatmax@592: { flatmax@592: elem.setAttribute('onkeydown',action); flatmax@592: elem.setAttribute('onkeypress',action); flatmax@592: elem.setAttribute('onkeyup',action); flatmax@592: } flatmax@592: flatmax@592: function setClassAttr(elem,attr) flatmax@592: { flatmax@592: elem.setAttribute('class',attr); flatmax@592: elem.setAttribute('className',attr); flatmax@592: } flatmax@592: flatmax@592: function createResults() flatmax@592: { flatmax@592: var results = document.getElementById("SRResults"); flatmax@592: for (var e=0; e