function SearchBox(name, resultsPath, inFrame, label) { this.searchLabel = label; this.DOMSearchField = function() { return document.getElementById("MSearchField"); } this.DOMSearchBox = function() { return document.getElementById("MSearchBox"); } this.OnSearchFieldFocus = function(isActive) { if (isActive) { this.DOMSearchBox().className = 'MSearchBoxActive'; var searchField = this.DOMSearchField(); if (searchField.value == this.searchLabel) { searchField.value = ''; } } else { this.DOMSearchBox().className = 'MSearchBoxInactive'; this.DOMSearchField().value = this.searchLabel; } } } function trim(s) { return s?s.replace(/^\s\s*/, '').replace(/\s\s*$/, ''):''; } function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]'+name+ '='+'([^&;]+?)(&|#|;|$)').exec(location.search) ||[,""])[1].replace(/\+/g, '%20'))||null; } var entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }; function escapeHtml(s) { return String(s).replace(/[&<>"'\/]/g, function (s) { return entityMap[s]; }); } function searchFor(query,page,count) { $.getJSON(serverUrl+"?cb=?", { n:count, p:page, q:query }, function(data) { var results = $('#searchresults'); $('#MSearchField').val(query); if (data.hits>0) { if (data.hits==1) { results.html('
'+searchResultsText[1]+'
'); } else { results.html(''+searchResultsText[2].replace(/\$num/,data.hits)+'
'); } var r=''+(data.first+i+1)+'. | '+ ''+escapeHtml(item.type)+' '+ ''+escapeHtml(item.name)+''; if (item.type=="source") { var l=item.url.match(/[1-9][0-9]*$/); if (l) r+=' at line '+parseInt(l[0]); } r+=' | '; for (var i=0;i'+item.fragments[i]+' |
'+searchResultsText[0]+'
'); } }); }