The SiteSearch plugin enables a static site search. The site documents are taken from a sitemap XML file. Site documents must be XHTML.
Current version: 0.4
The SiteSearch plugin uses jQuery.
$(selector).siteSearch(options);
sitemap: URI of the sitemap (default: 'sitemap.xml')selector: Selector for the html elements that are investigated during search (default: 'title, h1, h2, h3, h4, h5, h6, p, td')noResult: No result message (default: 'No result.')buttonText: Text on the search button (default: 'Search')maxResults: Max number of results (result = site page with search hits) (default: 20)maxResultsPerPage: Max number of results displayed together in a result page (default: 5) maxSnippetLength: Max number of characters displayed in a result snippets block (default: 200)resultsReceived: Callback hook function which is called after results are determined (default: $noop(results)) showResults: Function for displaying search results (default: showResults(results))
Each time options are changed the events are exclusively bound to the option handler functions.
In order to add an event handler to previously bound handlers please use .bind().
Event handlers run in window scope.
create: Event handler for the "create.siteSearch"
event which is triggered after displaying the search form.
(default: $.noop)
$('#search').siteSearch({
create: function(event, siteSearchObject) {
alert('Search form created');
}
});
Add event handler:
$('#search').bind('create.siteSearch', function(event, siteSearchObject) {
alert('Search form created');
});
failure: Event handler for the "failure.siteSearch" event with string argument.
(default: function(event, sitesearchObject, message) {alert(message);})success: Event handler for the "success.siteSearch" event
which is triggered after a successful search was done and search results are displayed.
(default: $.noop(event, sitesearchObject)})resultsReceived: Event handler for the "resultsReceived.siteSearch" event
which is triggered after a successful search was done but search results are not displayed yet.
(default: $.noop(event, sitesearchObject, results)})option: Set one option: .siteSearch('option', optionName, value);
.siteSearch('option', options);
.siteSearch('option', optionName);
.siteSearch('option');
search: Performs a search: .siteSearch('search', searchString);
destroy: Delets the form and the search object: .siteSearch('destroy');
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.sitesearch.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#search').siteSearch();
$('#searchblock').css('display','block');
});
</script>
<title>Search Example</title>
</head>
<body>
<h1>Search Example</h1>
<div id="searchblock" style="display:none">
<h2>Local Search</h2>
<div id="search">
<p>Please wait...</p>
</div>
</div>