dom.annotate

Classes


Public Protected Private

Global Functions

goog.dom.annotate.annotateTerms(nodetermsannotateFnopt_ignoreCaseopt_classesToSkipopt_maxMs) boolean
Calls annotateFn for each occurrence of a search term in text nodes under node. Returns the number of hits.
Arguments:
node : Node
A DOM node.
terms : Array
An array of [searchTerm, matchWholeWordOnly] tuples. The matchWholeWordOnly value is a per-term attribute because some terms may be CJK, while others are not. (For correctness, matchWholeWordOnly should always be false for CJK terms.).
annotateFn : goog.dom.annotate.AnnotateFn
No description.
opt_ignoreCase : *=
Whether to ignore the case of the query terms when looking for matches.
opt_classesToSkip : Array.<string>>
Nodes with one of these CSS class names (and its descendants) will be skipped.
opt_maxMs : number=
Number of milliseconds after which this function, if still annotating, should stop and return.
Returns: boolean  Whether any terms were annotated.
code »
goog.dom.annotate.annotateTermsInNode_(nodetermsannotateFnignoreCaseclassesToSkipstopTimerecursionLevel) boolean
Recursive helper function.
Arguments:
node : Node
A DOM node.
terms : Array
An array of [searchTerm, matchWholeWordOnly] tuples. The matchWholeWordOnly value is a per-term attribute because some terms may be CJK, while others are not. (For correctness, matchWholeWordOnly should always be false for CJK terms.).
annotateFn : goog.dom.annotate.AnnotateFn
No description.
ignoreCase : *
Whether to ignore the case of the query terms when looking for matches.
classesToSkip : Array.<string>
Nodes with one of these CSS class names will be skipped (as will their descendants).
stopTime : number
Deadline for annotation operation (ignored if 0).
recursionLevel : number
How deep this recursive call is; pass the value 0 in the initial call.
Returns: boolean  Whether any terms were annotated.
code »
goog.dom.annotate.annotateText(texttermsannotateFnopt_ignoreCase) goog.html.SafeHtml
Annotates occurrences of query terms in plain text. This process consists of identifying all occurrences of all query terms, calling a provided function to get the appropriate replacement HTML for each occurrence, and HTML-escaping all the text.
Arguments:
text : string
The plain text to be searched.
terms : Array
An array of [{string} searchTerm, {boolean} matchWholeWordOnly] tuples. The matchWholeWordOnly value is a per-term attribute because some terms may be CJK, while others are not. (For correctness, matchWholeWordOnly should always be false for CJK terms.).
annotateFn : goog.dom.annotate.AnnotateFn
No description.
opt_ignoreCase : *=
Whether to ignore the case of the query terms when looking for matches.
Returns: goog.html.SafeHtml  The HTML equivalent of text with terms annotated, or null if the text did not contain any of the terms.
code »
goog.dom.annotate.helpAnnotateText_(texttermsannotateFnignoreCase) goog.html.SafeHtml
Annotates occurrences of query terms in plain text. This process consists of identifying all occurrences of all query terms, calling a provided function to get the appropriate replacement HTML for each occurrence, and HTML-escaping all the text.
Arguments:
text : string
The plain text to be searched.
terms : Array
An array of [{string} searchTerm, {boolean} matchWholeWordOnly] tuples. If ignoreCase is true, each search term must already be lowercase. The matchWholeWordOnly value is a per-term attribute because some terms may be CJK, while others are not. (For correctness, matchWholeWordOnly should always be false for CJK terms.).
annotateFn : goog.dom.annotate.AnnotateFn
No description.
ignoreCase : *
Whether to ignore the case of the query terms when looking for matches.
Returns: goog.html.SafeHtml  The HTML equivalent of text with terms annotated, or null if the text did not contain any of the terms.
code »
goog.dom.annotate.lowercaseTerms_(terms) !Array
Converts terms to lowercase.
Arguments:
terms : Array
An array of [{string} searchTerm, {boolean} matchWholeWordOnly] tuples.
Returns: !Array  An array of [{string} searchTerm, {boolean} matchWholeWordOnly] tuples.
code »

Global Properties

goog.dom.annotate.AnnotateFn :
A function that takes: (1) the number of the term that is "hit", (2) the HTML (search term) to be annotated, and returns the annotated term as an HTML.
Code »
goog.dom.annotate.MAX_RECURSION_ :
The maximum recursion depth allowed. Any DOM nodes deeper than this are ignored.
Code »
goog.dom.annotate.NODES_TO_SKIP_ :
The node types whose descendants should not be affected by annotation.
Code »
goog.dom.annotate.NONWORD_RE_ :
Regular expression that matches non-word characters. Performance note: Testing a one-character string using this regex is as fast as the equivalent string test ("a-zA-Z0-9_".indexOf(c) < 0), give or take a few percent. (The regex is about 5% faster in IE 6 and about 4% slower in Firefox 1.5.) If performance becomes critical, it may be better to convert the character to a numerical char code and check whether it falls in the word character ranges. A quick test suggests that could be 33% faster.
Code »

Package dom

Package Reference