Class AjxStringUtil
Class Detail
AjxStringUtil()
Default constructor does nothing (static class).
Author: Ross Dargahi, Roland Schemers, Conrad Damon.
Method Detail
<static>
AjxStringUtil.capitalize(str)
Capitalizes the specified string by upper-casing the first character
and lower-casing the rest of the string.
<static>
AjxStringUtil.capitalizeFirstLetter(str)
Capitalizes the specified string by upper-casing the first character.
Unlike AjxStringUtil.capitalize - don't change the rest of the letters.
<static>
AjxStringUtil.capitalizeWords(str)
Capitalizes all the words in the specified string by upper-casing the first
character of each word (does not change following characters, so something like MTV stays MTV
<static>
AjxStringUtil.checkForCleanHtml(html, okTags, untrustedAttrs)
Checks the given HTML to see if it is "safe", and cleans it up if it is. It must have only
the tags in the given list, otherwise false is returned. Attributes in the given list will
be removed. It is not necessary to include "#text", "html", "head", and "body" in the list
of allowed tags.
<static>
{string}
AjxStringUtil.convertToHtml(str, quotePrefix, openTag, closeTag)
Converts the string to HTML.
<static>
{number}
AjxStringUtil.diffPoint(str1, str2)
Does a diff between two strings, returning the index of the first differing character.
<static>
AjxStringUtil.encodeQuotes(str)
encode quotes for using in inline JS code, so the text does not end a quoted param prematurely.
<static>
AjxStringUtil.equalsHtmlPlatformIndependent(html1, html2)
compare two html code fragments, ignoring the case of tags, since the tags inside innnerHTML are returned differently by different browsers (and from Outlook)
e.g. IE returns CAPS for tag names in innerHTML while FF returns lowercase tag names. Outlook signature creation also returns lowercase.
this approach is also good in case the browser removes some of the innerHTML set to it, like I suspect might be in the case of stuff coming from Outlook. (e.g. it removes head tag since it's illegal inside a div)
<static>
{String}
AjxStringUtil.fitString(str, width)
Fits as much of a string within the given width as possible. If truncation is needed, adds an ellipsis.
Truncation could happen at any letter, and not necessarily at a word boundary.
<static>
AjxStringUtil.fixCrossDomainReference(url, restUrlAuthority, convertToRelativeURL)
correct the cross domain reference in passed url content
eg: http://
<static>
AjxStringUtil.fromMixed(text, sep)
Converts the given mixed-case text to a string of one or more words
separated by spaces.
<static>
{String}
AjxStringUtil.getAsString(o)
Returns the given object/primitive as a string.
<static>
{string}
AjxStringUtil.getOriginalContent(text, isHtml)
Analyze the text and return what appears to be original (as opposed to quoted) content. We
look for separators commonly used by mail clients, as well as prefixes that indicate that
a line is being quoted.
<static>
{string}
AjxStringUtil.getUnitsFromSizeString(sizeString)
Gets the units from size string.
<static>
AjxStringUtil.getWidth(str, bold, font)
Returns the width in pixels of the given string.
<static>
{string}
AjxStringUtil.htmlDecode(str, decodeSpaces)
Decodes the string.
<static>
{string}
AjxStringUtil.htmlEncode(str, includeSpaces)
HTML-encodes a string.
<static>
AjxStringUtil.htmlRubyEncode(base, text)
Encode
<static>
{string}
AjxStringUtil.jsEncode(str)
Encodes non-ASCII and non-printable characters as \uXXXX, suitable
for JSON.
<static>
{Object}
AjxStringUtil.parseMailtoLink(str)
Parses a mailto: link into components. If the string is not a mailto: link, the object returned will
have a "to" property set to the string.
<static>
{Object}
AjxStringUtil.parseQueryString(sourceUri)
Parse the query string (part after the "?") and return it as a hash of key/value pairs.
<static>
AjxStringUtil.prettyPrint(obj, recurse, showFuncs, omit)
Pretty-prints a JS object. Preferred over JSON.stringify for the debug-related dumping
of an object for several reasons:
- doesn't have an enclosing object, which shifts everything over one level
- doesn't put quotes around keys
- shows indexes for arrays (downside is that prevents output from being eval-able)
<static>
{String}
AjxStringUtil.queryStringRemove(qs, name)
Removes the given arg from the query string.
<static>
{string}
AjxStringUtil.quoteText(params)
Quotes text with the given quote character. For HTML, surrounds the text with the
given strings. Does no wrapping.
<static>
{string}
AjxStringUtil.repeat(str, num)
Returns the string repeated the given number of times.
<static>
{char}
AjxStringUtil.shiftChar(keycode, shifted)
Returns the character for the given key, taking the shift key into consideration.
<static>
{array}
AjxStringUtil.split(str, dels)
Splits a string, ignoring delimiters that are in quotes or parentheses. Comma
is the default split character, but the user can pass in a string of multiple
delimiters. It can handle nested parentheses, but not nested quotes.
TODO: handle escaped quotes
<static>
{array}
AjxStringUtil.splitKeepLeadingWhitespace(line)
Splits the line into words, keeping leading whitespace with each word.
<static>
{string}
AjxStringUtil.stripTags(str, removeContent)
Removes HTML tags from the given string.
<static>
{string}
AjxStringUtil.toMixed(text, sep, camel)
Converts the given text to mixed-case. The input text is one or more words
separated by spaces. The output is a single word in mixed (or camel) case.
<static>
{string}
AjxStringUtil.trim(str, compress, space)
Removes white space from the beginning and end of a string, optionally compressing internal white space. By default, white
space is defined as a sequence of Unicode whitespace characters (\s in regexes). Optionally, the user can define what
white space is by passing it as an argument.
TODO: add left/right options
<static>
{String}
AjxStringUtil.trimHtml(html)
Removes non-content HTML from the beginning and end. The idea is to remove anything that would
appear to the user as blank space. This function is an approximation since that's hard to do,
especially when dealing with HTML as a string.
<static>
{string}
AjxStringUtil.urlComponentDecode(str)
Decodes a string as if it were a part of a URL. Falls back
to unescape() if necessary.
<static>
{string}
AjxStringUtil.urlComponentEncode(str)
Encodes a string as if it were a part of a URL. The
difference between this function and AjxStringUtil.urlEncode
is that this will also encode the following delimiters:
: / ? & =
<static>
{string}
AjxStringUtil.urlDecode(str)
Decodes a complete URL.
<static>
{string}
AjxStringUtil.urlEncode(str)
Encodes a complete URL. Leaves delimiters alone.
<static>
{string}
AjxStringUtil.wordWrap(params, text, len, prefix, before, after, preserveReturns, isHeaders, isFlowed, htmlMode)
Wraps text to the given length and optionally quotes it. The level of quoting in the
source text is preserved based on the prefixes. Special lines such as email headers
always start a new line.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 28 2016 21:01:30 GMT-0400 (EDT)
|