2009/03/03

Map of Reusable SharePoint JavaScript

JSRequest



version: WSS 3.0
source file: init.js (ln 1621)
mapped by: Itay Shakury
purpose: provides method to parse query string, filename, and pathname from URL
example:



JSRequest.EnsureSetup();
var qs = JSRequest.QueryString[value];
var fn = JSRequest.FileName;
var pt = JSRequest.PathName;


PreSaveAction()



version: WSS 3.0
source file: n/a (ref: form.js ln 5909)
mapped by: Edin Kapic
purpose: provides hook for creating custom function interrupting submit action
example:



function PreSaveAction(){
var input = getTagFromIdentifierAndTitle("textarea","","Test");
if(input && input.value == "") {
alert("You must complete Test");
return false; // Cancel the item save process
}
return true; // OK to proceed with the save item
}


_spBodyOnLoadFunctionNames



version: WSS 3.0
source file: n/a
mapped by: Sanjay Arora
purpose: Allows you to register additional JavaScript methods that should run in the PageLoad event
example:


_spBodyOnLoadFunctionNames.Push('MyCustomFunctionName');


GetFirstChildElement(e)



version: WSS 3.0
source file: core.js
mapped by: Christophe
purpose: get the first "real" child of a DOM element. This function is useful for Firefox, which interprets a line break as a child element.


GetLastChildElement(e)



version: WSS 3.0
source file: core.js
mapped by: Christophe
purpose: get the last "real" child of a DOM element. This function is useful for Firefox, which interprets a line break as a child element.


GetCBSelectedValues(frm)



version: WSS 3.0
source file: core.js (ln 972)
mapped by: Paul Grenier
purpose: Accepts a form object, loops through all check box elements and returns the values of the checked boxes or false if none are checked.
example:
html


<input id="spUserSelCb_1131" type="checkbox" title="Paul Grenier" onclick="UserSelectionOnClick(this,'1');" value="131" name="spUserSelectionCheckBox_1"/>


JavaScript



var elm = document.getElementsByTagName("form")[0];
GetCBSelectedValues(elm)

Object returned: strList = "131,144,143,7,254,22..."


GetSelectedValue (frmElem)



version: WSS 3.0
source file: init.js (ln 1516)
mapped by: Paul Grenier
purpose: takes a form element with a selectedIndex and returns the selected value or an empty string.


GetSelectedText(frmElem)



version: WSS 3.0
source file: init.js (ln 1523)
mapped by: Paul Grenier
purpose: takes a form element with a selectedIndex and returns the selected text or an empty string.


escapeProperly(str)



version: WSS 3.0
source file: init.js (ln 168)
mapped by: Paul Grenier
purpose: takes any string and returns a URL-encoded string.
example:
escapeProperly("this is a test")


"this%20is%20a%20test"


unescapeProperly(str)



version: WSS 3.0
source file: init.js (ln 855)
mapped by: Paul Grenier
purpose: takes any URL-encoded string and returns a string.
example:
unescapeProperly("this%20is%20a%20test")


"this is a test"



refrance : http://sharepointdevwiki.com/display/public/SharePoint+JavaScript+Functions+Overview

No comments: