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