Exhibit/Text Search Facet

From SIMILE Widgets
Jump to: navigation, search

To include a text search facet, add to your HTML

 <div ex:role="facet" 

By default the text search facet searches all properties. To limit it to a specified property, add:


You can search more than one property with a comma separated list:

 ex:expressions=".property1, .property2"

For example, this facet will only search the content of labels:

 <div ex:role="facet" 

FACET HACK: To use this search information locally, I wrote this bit of javascript because EXHIBIT changes the title tag of the page dynamically. There are probably "better" ways of doing it, but this worked for me - and I thought I'd share it with you too.

<script type="text/javascript">
 function searchHack(){ 
   var titleNow=document.title;
   var result = titleNow.search(/Text search.+/);
   var resultReset = titleNow.search(/Reset all filters.+/);//initialize the error value
   var resultSelect = titleNow.search(/Select.+/);//initialize the error value
   var resultUnselect = titleNow.search(/Unselect.+/);//initialize the error value
   if (result != -1){
     var extract= titleNow.slice(34); 
            // You need to add the number of characters in the <title>WHATEVER</title> 
            // that you use within your HTML <head> tag to 13. In my case I had a title length of 21.
            // That is why the titleNow.slice() has a value of 34... 
     var extractLen=extract.length-1;
     var searchTerm=extract.substr(0,extractLen);
        document.getElementById("iFrame1").src = "search_result.php?term=" + searchTerm;
        $('#searchFrame').fadeIn(3000); //jQuery animation to show the div where the Iframe is held
        $('#shutter').show(); //jQuery animation for the close button
        $('#visualizerLink').hide(); //jQuery animation for the open search button
 // search error results
   } else if (resultReset != -1) {alert("Search field empty.");}
     else if (resultSelect != -1) {alert("Please Reset all Filters or Begin a new Search.");}
     else if (resultUnselect != -1) {alert("Please try a new Search.");}
     else if (titleNow == "[your base title]") {alert("Enter your term in the Search field.");}

Then you just need to initialize the function like this:

Every time the link is clicked a new query is sent to the search_result.php script according to the content of the title as long as the user has initiated a search. From Danielcaleb. Visit vis.ionary.org to see it in action.

Filter by query string

The email archive reveals this useful tidbit added in by Brian:

Searches (automatically) for the URI string passed in as example.com/map.html?srch=SEARCHTERM

-- very useful to filter on a map item's name/label, etc.
Personal tools