The NI Search Bar Plugin is a simple piece of code that will allow you to embed the NI.com search bar into an exisitng web page or web application. The search.xml file below is a pre-built plugin to which you can point and access on this public server. This works great with pre-built applications or websites (like Google Wave). If you want to take the code and embed it into your own application/page you can download the .txt file below which contains the code.
The code for this plugin is realatively simple, we setup 3 simple html elements, a text box, a button, and a radio button. Then we addin the javascript logic which runs the plugin. We configure the text box so that it will respond to the press of an enter key so that way the user can hit the enter key or click on search to bring up the results. This is done using:
onkeydown="if(event.keyCode == 13) document.getElementById('searchBtn').click()
The embedded if statement is testing to catch only the press of the enter key. This could be done in many different ways but for this case we wanted to save on size to make the plugin easier to edit.
If you want to add more search options, you only need to change two peices of the code. First you can simply add another item to the radio button which represents the section of NI.com that you want to search:
<input type=radio name="searchType" id="searchXX" value="XX">Facet X<br/>
You must ensure you use a uinique id string so that you can properly access each item later. Next go to NI.com navigate to a page with those search options enabled (for example search for "cRIO" and choose "Online Help" on the facets on the left-hand side). Then you can copy the url in the address bar and modify it to be used in the plugin, as we see with the 3 options built in:
searchString = 'http://search.ni.com/nisearch/app/main/p/bot/no/ap/global/lang/en/pg/1/sn/catnav:mp/q/' + searchKey;
Javascript, HTML, XML
logo.gif - NI corporate logo
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.