Predefined search allows you to define a set of predefined search terms. To enable this functionality you must add the predefinedSearch property to the Viewer parameters. The following example shows you how:
Example |
Copy Code
|
---|---|
<script type="text/javascript"> $(document).ready(function () { var pluginOptions = { documentID: viewingSessionId, language: languageItems, template: htmlTemplates, predefinedSearch: { highlightColor: "#ee3a8c", searchOnInit: false, globalOptions: { matchCase: false, endsWith: false, beginsWith: false, matchWholeWord: false }, terms: [{ searchTerm: "llama", selected: true, options: { matchWholeWord: true } }, { searchTerm: "Words that begin with ll", userDefinedRegex: "\\bll(\\w*)\\b", searchTermIsRegex: true, selected: true, highlightColor: "#4169e1", options: { matchCase: true } }] } } }; $("#sample").pccViewer(pluginOptions); }); </script> |
Predefined Search can also be specified using a text file (predefinedSearch.json). PredefinedSearch.json provides several sample search terms and custom regular expressions. PredefinedSearch.json file is parsed by the web-tier and loaded in the Viewer. The following example shows you how:
Example |
Copy Code
|
---|---|
<script type="text/javascript"> var viewingSessionId = '<%=HttpUtility.JavaScriptStringEncode(viewingSessionId)%>'; //Retrieve the searchJson (search data) into javascript var searchTerms = <%=searchJson%>; var pluginOptions = { documentID: viewingSessionId, predefinedSearch: searchTerms, }; $(document).ready(function () { var viewerControl = $("#viewer1").pccViewer(pluginOptions).viewerControl; }); </script> |
Parameter |
Data Type |
Description |
||||
highlightColor |
String |
The default highlight color of the search terms. This is overridden by the term-level parameter. This must be in 6 digit hexadecimal format preceded by a #. Example: "#ee3a8c" |
||||
searchOnInit |
Boolean |
Run search on launch. |
||||
globalOptions |
Object |
Set the default search options for each of the predefined search terms. This is overridden by the term-level "options" parameter.
|
||||
terms |
Array |
An array of objects that represent the search terms that will be available in the predefined menu.
|
Parameter |
Data Type |
Description |
||||
searchTerm |
String |
The search string for the term object. This is overridden by the userDefinedRegex parameter. |
||||
searchTermIsRegex |
Boolean |
When set to true will use userDefinedRegex to execute the search |
||||
userDefinedRegex |
String |
A regular expression that will be searched in place of searchTerm. The first and last forward slashes, as well as the flags, are stripped from the string. For example, "/Pa(\\w+)/ig" will become "Pa(\\w+)". When special characters (ex: backslash) are used in the "userDefinedRegex" field, they need to be properly escaped. For example, for searching words that begins with "Pa", the regular expression will be "Pa(\w+)", this regular expression should be properly escaped like this "Pa(\\w+)". All patterns use the Global(g) flag.
|
||||
description |
String |
Description of the search term. If description is not defined "searchTerm" will be used. |
||||
highlightColor |
String |
When specified system will use this value to show the highlight color for this search term. When not specified system will generate a color. Ex: highlightColor: "#FFFF20" |
||||
Options
|
Object |
|