PrizmDoc Viewer v13.19 - Updated
Developer Guide / Viewer / Configure the Viewer / Configuration Options / How to Use Pre-defined Search
In This Topic
    How to Use Pre-defined Search
    In This Topic

    Introduction

    This feature 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

    <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,
                                wildcard: false
                            },
                            terms: [{
                                searchTerm: "llama",
                                selected: true,
                                options: {
                                    matchWholeWord: true,       
                                    wildcard: false
                                }
                    },
                            {
                                searchTerm: "Words that begin with ll",
                                userDefinedRegex: "\\bll(\\w*)\\b",
                                searchTermIsRegex: true,
                                selected: true,
                                highlightColor: "#4169e1",
                                options: {
                                    matchCase: true
                                }
                            }]
                        }
                    }
                };
                $("#sample").pccViewer(pluginOptions);
            });
            </script>
    
    

    PredefinedSearch.JSON

    Predefined Search can also be specified using a text file (predefinedSearch.json). The predefinedSearch.json file provides several sample search terms and custom regular expressions; the file is parsed by the web-tier and loaded in the Viewer. The following example shows you how:

    Example

    <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>
    
    

    Predefined Search Patterns

    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.

    Example:
    predefinedSearch : {
    globalOptions: {
    matchCase: false,
    endsWith: false,
    beginsWith: false,
    matchWholeWord: false,
    wildcard: false
    }
    }
    terms Array An array of objects that represent the search terms that will be available in the predefined menu.

    Example:
    predefinedSearch : {
    terms: [
    {
    searchTerm: "llama"
    }
    ]
    }

    Predefined Search Terms

    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 (for example, backslash) are used in the userDefinedRegex field, they need to be properly escaped. For example, for searching words that begin 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.

    Example:
    predefinedSearch : {
    terms: [
    {
    searchTerm: "4 digits"
    userdefinedRegex: "(\\d{4})"
    }
    ]
    }
    description String Description of the search term. If description is not defined, then searchTerm will be used.
    highlightColor String When specified the system will use this value to show the highlight color for this search term. When not specified the system will generate a color.

    Example: highlightColor: "#FFFF20"
    Options Object Example:
    options: {
    "matchCase": false,
    "endsWith": false,
    "beginsWith": false,
    "matchWholeWord": false,
    "exactPhrase": false,
    "wildcard": false
    }