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

'+searchResultsText[1]+'

');\n" " } else {\n" " results.html('

'+searchResultsText[2].replace(/\\$num/,data.hits)+'

');\n" " }\n" " var r='';\n" " $.each(data.items, function(i,item){\n" " var prefix = tagMap[item.tag];\n" " if (prefix) prefix+='/'; else prefix='';\n" " r+=''+\n" " ''+\n" " '';\n" " for (var i=0;i';\n" " }\n" " r+='';\n" " });\n" " r+='
'+(data.first+i+1)+'.'+escapeHtml(item.type)+' '+\n" " ''+escapeHtml(item.name)+'';\n" " if (item.type==\"source\") {\n" " var l=item.url.match(/[1-9][0-9]*$/);\n" " if (l) r+=' at line '+parseInt(l[0]);\n" " }\n" " r+='
';\n" " if (data.pages>1) // write multi page navigation bar\n" " {\n" " r+='
';\n" " if (data.page>0)\n" " {\n" " r+='« ';\n" " }\n" " var firstPage = data.page-5;\n" " var lastPage = data.page+5;\n" " if (firstPage<0)\n" " {\n" " lastPage-=firstPage;\n" " firstPage=0;\n" " } \n" " if (lastPage>data.pages)\n" " {\n" " lastPage=data.pages;\n" " }\n" " for(var i=firstPage;i ';\n" " }\n" " else\n" " {\n" " r+=''+(i+1).toString()+' ';\n" " }\n" " }\n" " if (data.page+1»';\n" " }\n" " r+='
';\n" " }\n" " results.append(r);\n" " } else {\n" " results.html('

'+searchResultsText[0]+'

');\n" " }\n" " });\n" "}\n"