In my last article “Useful Javascript Functions and objects in SharePoint – Part 1” I listed some useful javascript objects in SharePoint.
Today I will continue exploring useful functions.
DOM Management
- byid(id) = Return element for the given id
- newE(tag) = Create a new dom element of the given tag e.g. div etc.
- wpf() = return ASP.net form object for the current web part page
- GetEventSrcElement(e) = return source element for the given event object
- GetEventKeyCode(e) = Return key code of the currently pressed key for the given object
- GetInnerText(e) = Return inner html for the given object
HTML Encoding and Decoding
- escapeProperlyCoreCore(str, bAsUrl, bForFilterQuery, bForCallback) = Very useful function to perform any type of string escaping. Last three parameters are flags to perform deifferent type of escaping i.e.
- bAsUrl = true, for url escaping
- bForFilterQuery = true, for filter query escaping
- bForCallback = true, for call back escaping
- escapeProperly(str) = Escapes the given string to make it valid SharePoint compatible string. It internally calls escapeProperlyCoreCore to perform the actual escaping
- escapeUrlForCallback(str) = Escapes the given string to make it valid url for call back
- encodeScriptQuote(str) = Replace the apostrophe i.e. ‘ to %27 in the given string
- STSHtmlEncode(str) = Encodes the reserved characters to their respective HTML entities in the given string. For example “<div>” will become <div>
- StAttrQuote(st) = Encodes the “&”, “ “ ” and carriage return to their respective HTML entities in the given string.
- STSScriptEncode(str) = Encodes the given string for use in script. It has the same functionality as SPEncode.ScriptEncode defined here
- STSScriptEncodeWithQuote = Encodes the specified string so that characters in embedded HTML tags are displayed as text in the browser, and writes the string in quotation marks
- escapeForSync(str) = Encodes the given string for syncing. Need further clarification.
- Vutf8ToUnicode(rgBytes) = Converts the given utf8 string to unicode
- unescapeProperly(str) = Unescapes the given escaped string
Validations
- PageUrlValidation(url) = Checks if the given string is a valid url or not.
- IndexOfIllegalCharInUrlLeafName(strLeafName) = Return the index of character in the given string which is illegal to be used in url leaf name.
- IndexOfIllegalCharInUrlPath(strPath) = Return the index of character in the given string which is illegal to be used in url leaf name.
- UrlContainsIllegalStrings(strPath) = Returns true if the given string contains an illegal character which can not be used in a url. Otherwise, return false.
- UrlLeafNameValidate(source, args) = Validates the url leaf name. Returns true if valid otherwise, false. Need further clarification.
- UrlPathValidate (source, args) = Validates the url path. Returns true if valid otherwise, false. Need further clarification.
- IsCheckBoxListSelected(checkboxlist) = Returns true, if the given checkbox is either null or at least one check box is checked in it.
- IsAccessibilityFeatureEnabled() = Returns true, if the accessibility feature is enabled by checking the cookie called “WSS_AccessibilityFeature”
Cookie Management
- DeleteCookie(sName) = Deletes the given cookie by setting its expiry date to 01-Jan-1970
- GetCookie(sName) = Returns the given cookie
Navigation
- navigateMailToLink(strUrl, strUrlNew) = Creates a mail to link for the given url
- GetUrlFromWebUrlAndWebRelativeUrl(webUrl, webRelativeUrl) = Creates a url by combining webUrl and relative url. It takes care of checking null webUrl and slash character at the end.
Syncing with other applications
- GetStssyncAppNameForType(strType,strDefault) = Returns an string similar to “Connect to Outlook” etc. depending on the given type.
- GetStssyncIconPath(strDefault, strPrefix) = Returns the path of icon image for the given syncing application type.
- ExportHailStorm ( ….. ) = Creates connection to Outlook. Check here for further details.
Miscellaneous
- DeferCall() = Not sure.
- AdmBuildParam(stPattern) = Not sure.
To be continued….