$SP()

Methods

addressbook

addressbook(word, setup, result)
Find an user based on a part of his name

Parameters:

String
word
A part of the name from the guy you're looking for
Object
setup Optional
Options (see below)
String
setup.limit Optional, Default: 10
Number of results returned
String
setup.type Optional, Default: 'User'
Possible values are: 'All', 'DistributionList', 'SecurityGroup', 'SharePointGroup', 'User', and 'None' (see http://msdn.microsoft.com/en-us/library/people.spprincipaltype.aspx)
String
setup.url Optional, Default: 'current website'
The website url
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result (typically: AccountName,UserInfoID,DisplayName,Email,Departement,Title,PrincipalType)

Example:

$SP().addressbook("john", {limit:25}, function(people) {
  for (var i=0; i < people.length; i++) {
    for (var j=0; j < people[i].length; j++) console.log(people[i][j]+" = "+people[i][people[i][j]]);
  }
});

checkin

checkin(setup)
Checkin a file

Parameters:

Object
setup Optional
Options (see below)
String
setup.destination
The full path to the file to check in
String
setup.comments Optional, Default: ""
The comments related to the check in
String
setup.url Optional, Default: 'current website'
The website url
Function
setup.success Optional, Default: function(){}
A callback function that will be triggered when there is success
Function
setup.error Optional, Default: function(){}
A callback function that will be triggered if there is an error
Function
setup.after Optional, Default: function(){}
A callback function that will be triggered after the task

Example:

$SP().checkin({
  destination:"http://mysite/Shared Documents/myfile.txt",
  comments:"Automatic check in with SharepointPlus",
  after:function() { alert("Done"); }
});

cleanResult

cleanResult(str, separator)
clean a string returned by a GET (remove ";#" and "string;#" and null becomes "")

Parameters:

String
str
The string to clean
String
separator Optional, Default: ";"
When it's a list we may want to have a different output (see examples)

Returns:

String
the cleaned string

Example:

$SP().cleanResult("15;#Paul"); // -> "Paul"
$SP().cleanResult("string;#Paul"); // -> "Paul"
$SP().cleanResult("string;#"); // -> ""
$SP().cleanResult(";#Paul;#Jacques;#Aymeric;#"); // -> "Paul;Jacques;Aymeric"
$SP().cleanResult(";#Paul;#Jacques;#Aymeric;#", ", "); // -> "Paul, Jacques, Aymeric"

closeModalDialog

closeModalDialog(dialogResult, returnValue)
Close the last modal dialog

Parameters:

SP.UI.DialogResult|Object
dialogResult Optional
One of the enumeration values specifying the result of the modal dialog, or the modal object returned by $SP().getModalDialog()
Object
returnValue Optional
The return value of the modal dialog

Example:

// if the user use the cross to close the modal, then `dialogResult` equals to 0 in the callback
// but you can trigger the close of the modal and pass anything you want
$SP().showModalDialog({
  title:"Hello World",
  html:'

This is an example. Click one of the buttons.

', callback:function(res) { alert(res) } })

createFile

createFile(setup)
Create a file and save it to a Document library

Parameters:

Object
setup
Options (see below)
String
setup.content
The file content
String
setup.filename
The relative path (within the document library) to the file to create
String
setup.library
The name of the document library
Boolean
setup.encoded Optional, Default: false
Set to true if the content passed is already base64-encoded
Object
setup.fields Optional
If you want to set some other fields for the document
String
setup.url Optional, Default: 'current website'
The website url
Function
setup.success Optional, Default: function(fileURL){}
A callback function that will be triggered in case of success; 1 parameter
Function
setup.error Optional, Default: function(fileURL,errorMessage){}
A callback function that will be triggered in case of failure; 2 parameters
Function
setup.after Optional, Default: function(fileURL,errorMessage){}
A callback function that will be triggered after the task whatever it's successful or not; 2 parameters

Example:

// create a text document
$SP().createFile({
  content:"Hello World!",
  filename:"SubFolder/myfile.txt",
  library:"Shared Document",
  fields:{
    "Title":"My Document",
    "File_x0020_Description":"This is my file!"
  },
  after:function(fileURL, error) {
    if (error) alert("Error: "+error)
    else alert("File created at " + fileURL); // fileURL -> http://mysite/Shared Documents/SubFolder/myfile.txt
  }
});

// you can remove "library" if you use $SP().list()
$SP().list("Shared Document").createFile({
  content:"Hello World!",
  filename:"SubFolder/myfile.txt",
  fields:{
    "Title":"My Document",
    "File_x0020_Description":"This is my file!"
  },
  after:function(fileURL, error) {
    if (error) alert("Error: "+error)
    else alert("File created at " + fileURL); // fileURL -> http://mysite/Shared Documents/SubFolder/myfile.txt
  }
})

// we can also create an Excel file
// a good way to export some data to Excel
$SP().createFile({
  content:"<table><tr><th>Column A</th><th>Column B</th></tr><tr><td>Hello</td><td>World!</td></tr></table>",
  filename:"myfile.xls",
  library:"Excel Exports",
  after:function(fileURL) {
    window.location.href=fileURL;
  }
});

// You can use https://github.com/Aymkdn/FileToDataURI if you want to be able to read a local file
// and then upload it to a document library, via Javascript/Flash
// We'll use "encoded:true" to say our content is already a base64 string
$SP().createFile({
  content:"U2hhcmVwb2ludFBsdXMgUm9ja3Mh",
  encoded:true,
  filename:"Demo/HelloWorld.txt",
  library:"Documents",
  url:"http://my.other.site/website/"
});

// NOTE: in some cases the files are automatically checked out, so you have to use $SP().checkin()

createFolder

createFolder(setup)
Create a folter in a Document library

Parameters:

Object
setup
Options (see below)
String
setup.path
The relative path to the new folder
String
setup.library
The name of the Document Library
String
setup.url Optional, Default: 'current website'
The website url
Function
setup.after Optional, Default: function(){}
A callback function that will be triggered after the task

Example:

// create a folder called "first" at the root of the Shared Documents library
// the result should be "http://mysite/Shared Documents/first/"
$SP().createFolder({
  path:"first",
  library:"Shared Documents",
  url:"http://mysite/",
  after:function() { alert("Folder created!"); }
});

// create a folder called "second" under "first" 
// the result should be "http://mysite/Shared Documents/first/second/"
// if "first" doesn't exist then it will be created
$SP().createFolder({
  path:"first/second",
  library:"Shared Documents",
  after:function() { alert("Folder created!"); }
});

// Note: To delete a folder you can use $SP().list().remove()

decode_b64

decode_b64(toDecode)
Permits to decode a Base 64 string

Parameters:

String
toDecode
It's the Base 64 string to decode

Returns:

String
The decoded string

distributionLists

distributionLists(username, setup, result)
Find the distribution lists where the specified user is member of

Parameters:

String
username
The username with or without the domain (don't forget to use a double \ like "mydomain\\john_doe")
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Boolean
setup.cache Optional, Default: true
Cache the response from the server
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result

Example:

$SP().distributionLists("mydomain\\john_doe",{url:"http://my.si.te/subdir/"}, function(mailing) {
  for (var i=0; i < mailing.length; i++) console.log(mailing[i]); // -> {SourceReference: "cn=listname,ou=distribution lists,ou=rainbow,dc=com", DisplayName:"listname", MailNickname:"List Name", Url:"mailto:listname@rainbow.com"}
});

encode_b64

encode_b64(toEncode)
Permits to encode in Base 64

Parameters:

String
toEncode
It's the string to encode into Base 64

Returns:

String
The encoded string

getLookup

getLookup(text)
Split the ID and Value

Parameters:

String
text
The string to retrieve data

Returns:

Object
.id returns the ID, and .value returns the value

Example:

$SP().getLookup("328;#Foo"); // --> {id:328, value:"Foo"}

getModalDialog

getModalDialog(id)
Retrieve the modal object for a special modalDialog

Parameters:

String
id
The ID of the modal

Returns:

Object
The modal object or NULL if the modal doesnt exist

Example:

var modal = $SP().getModalDialog("MyModal");
$SP().closeModalDialog(modal);

getURL

getURL()
Return the current base URL website

Returns:

String
The current base URL website

getUserInfo

getUserInfo(username, setup, result)
Find the User ID, work email, and preferred name for the specified username (this is useful because of the User ID that can then be used for filtering a list)

Parameters:

String
username
That must be "domain\\login" for Sharepoint 2010, or something like "i:0#.w|domain\\login" for Sharepoint 2013
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Function
result Optional
A function that will be executed at the end of the request with a param that is an object with the result ({ID,Sid,Name,LoginName,Email,Notes,IsSiteAdmin,IsDomainGroup,Flags}), or a String with the error message

Example:

$SP().getUserInfo("domain\\john_doe",{url:"http://my.si.te/subdir/"}, function(info) {
  if (typeof info === "string") {
    alert("Error:"+info); // there was a problem so we show it
  } else
    alert("User ID = "+info.ID)
});

getVersion

getVersion()
Returns the SP version

Returns:

String
The current SharepointPlus version

groupMembers

groupMembers(groupname, setup, result)
Find the members of a Sharepoint group

Parameters:

String
groupname
Name of the group
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Boolean
setup.error Optional, Default: true
The function will stop and throw an error when something went wrong (use FALSE to don't throw an error)
Boolean
setup.cache Optional, Default: true
By default the function will cache the group members (so if you call several times it will use the cache)
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result

Example:

$SP().groupMembers("my group", function(members) {
  for (var i=0; i < members.length; i++) console.log(members[i]); // -> {ID:"1234", Name:"Doe, John", LoginName:"mydomain\john_doe", Email:"john_doe@rainbow.com"}
});

isMember

isMember(setup, result)
Find if the user is member of the Sharepoint group

Parameters:

Object
setup Optional
Options (see below)
String
setup.user
Username with domain ("domain\\login" for Sharepoint 2010, or "i:0#.w|domain\\login" for Sharepoint 2013)
String
setup.group
Name of the group
String
setup.url Optional, Default: 'current website'
The website url
Boolean
setup.cache Optional, Default: true
Cache the response from the server
Function
result Optional
Return TRUE if the user is a member of the group, FALSE if not.

Example:

$SP().isMember({user:"mydomain\\john_doe",group:"my group",url:"http://my.site.com/"}, function(isMember) {
  if (isMember) alert("OK !")
});

lists

lists(setup, function())
Get the lists from the site (for each list we'll have "ID", "Name", "Description", "Url")

Parameters:

Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Function
function() Optional
A function with the data from the request as first argument

Example:

$SP().lists(function(list) {
  for (var i=0; i<list.length; i++) console.log("List #"+i+": "+list[i]['Name']);
});

notify

notify(message, options)
Permits to notify the user using the SP.UI.Notify.addNotification system

Parameters:

String
message
Message to show
Object
options Optional
Integer
options.timeout Optional, Default: 5
The number of seconds that the notification is shown
Boolean
options.override Optional, Default: false
This option to TRUE permits to remove the previous/current notification that is showing (even if the timeout is not over and even if it's a sticky) and replace it with the new one
Boolean
options.overrideAll Optional, Default: false
Same as previously except that it will remove *all* the previous notifications that are currently showing
Boolean
options.overrideSticky Optional, Default: true
When "overrideAll:true" then even the sticky notifications are removed, but you can block this behavior with "overrideSticky:false"
Boolean
options.sticky Optional, Default: false
Keep the notification on the screen until it's manually removed (or automatically removed with "overrideAll:true" and "overrideSticky:true")
String
options.name Optional, Default: random()
You can give a name to the notification (to use it with $SP().removeNotify('name'))
Function
options.after Optional, Default: function(name,afterDelay){}
You can call this function when the notification is removed -- the argument "name" is the name of the notification (see previous option), the argument "afterDelay" is TRUE when the notification has been removed by the system after it's normal timeout

Example:

$SP().notify('Processing the data...', {sticky:true}); // the notification will stay on the screen until we remove it
$SP().notify('All done!', {overrideAll:true}); // the "Processing the data..." is removed from the screen and a 5 seconds message says "All done!"

$SP().notify('Please wait 10 seconds...', {
  name:"My 10 seconds notification",
  timeout:10,
  after:function(name,afterDelay) {
    if (afterDelay) alert("OK, you waited during 10 seconds!")
    else alert("Something just removed this notification called '"+name+"'' before the timeout :-(")
  }
})

parse

parse(where, escapeChar)
Use a WHERE sentence to transform it into a CAML Syntax sentence

Parameters:

String
where
The WHERE sentence to change
String
escapeChar Optional, Default: true
Determines if we want to escape the special chars that will cause an error (for example '&' will be automatically converted to '&')

Example:

$SP().parse('ContentType = "My Content Type" OR Description <> null AND Fiscal_x0020_Week >= 43 AND Result_x0020_Date < "2012-02-03"');
// -> return <And><And><Or><Eq><FieldRef Name="ContentType" /><Value Type="Text">My Content Type</Value></Eq><IsNotNull><FieldRef Name="Description" /></IsNotNull></Or><Geq><FieldRef Name="Fiscal_x0020_Week" /><Value Type="Number">43</Value></Geq></And><Lt><FieldRef Name="Result_x0020_Date" /><Value Type="DateTime">2012-02-03</Value></Lt></And>

// available operators :
// "<" : less than
// "<=" : less than or equal to
// ">" : greater than
// ">=" : greater than or equal to
// "<>" : different
// "~=" : this must be only used when comparing to a number that represents the User ID (e.g. 'User ~= 328') - that permits to query a list with too many items but with the User column that is indexed
// " AND "
// " OR "
// " LIKE " : for example 'Title LIKE "foo"' will return "foobar" "foo" "barfoobar" "barfoo" and so on
// " IN " : for example 'Location IN ["Los Angeles","San Francisco","New York"]', equivalent to 'Location = "Los Angeles" OR Location = "San Francisco" OR Location = "New York"' — SP2013 limits each IN to 60 items. If you want to check Lookup IDs instead of text you can use '~' followed by the ID, for example 'Location IN ["~23", "~26", "~30"]'

// special words:
// '[Me]' : for the current user
// '[Today]' : to use the today date
// '[Today+X]' : to use today + X days
// Null : for the Null value
// TRUE : for the Yes/No columns
// FALSE : for the Yes/No columns

// in the below example, on the "&" will be escaped
var bar="Bob & Marley";
var foo="O'Conney";
$SP().parse('Bar = "'+bar+'" AND Foo = "'+foo+'"'); // -> <And><Eq><FieldRef Name="Bar" /><Value Type="Text">Bob & Marley</Value></Eq><Eq><FieldRef Name="Foo" /><Value Type="Text">O'Conney</Value></Eq></And>
$SP().parse("Bar = '"+bar+"' AND Foo = '"+foo+"'"); // don't put the simple and double quotes this way because it'll cause an issue with O'Conney

people

people(username, setup, result)
Find the user details like manager, email, colleagues, ...

Parameters:

String
username Optional
With or without the domain, and you can also use an email address, and if you leave it empty it's the current user by default (if you use the domain, don't forget to use a double \ like "mydomain\\john_doe")
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result, or a String with the error message

Example:

$SP().people("john_doe",{url:"http://my.si.te/subdir/"}, function(people) {
  if (typeof people === "string") {
    alert(people); // there was a problem so we prompt it
  } else
    for (var i=0; i < people.length; i++) console.log(people[i]+" = "+people[people[i]]);
});

plugin

plugin(pluginName, options)
Permits to use a plugin

Parameters:

String
pluginName
The plugin name to call
Object
options Optional
The options for the plugin

Example:

$SP().plugin('test',{message:"This is a test !"})

regionalDateFormat

regionalDateFormat(callback)
Provide the Date Format based on the user regional settings (YYYY for 4-digits Year, YY for 2-digits day, MM for 2-digits Month, M for 1-digit Month, DD for 2-digits day, D for 1-digit day) -- it's using the DatePicker iFrame (so an AJAX request)

Parameters:

Function
callback Optional
It will pass the date format

Example:

// you'll typically need that info when parsing a date from a Date Picker field from a form
// we suppose here you're using momentjs
// eg. we want to verify start date is before end date
var startDate = $SP().formfields("Start Date").val();
var endDate = $SP().formfields("End Date").val();
$SP().regionalDateFormat(function(dateFormat) {
  // if the user settings are on French, then dateFormat = "DD/MM/YYYY"
  if (moment(startDate, dateFormat).isAfter(moment(endDate, dateFormat))) {
    alert("StartDate must be before EndDate!")
  }
})

// Here is also an example of how you can parse a string date
// -> https://gist.github.com/Aymkdn/b17903cf7786578300f04f50460ebe96

regionalSettings

regionalSettings(callback)
Find the region settings (of the current user) defined with _layouts/regionalsetng.aspx?Type=User (lcid, cultureInfo, timeZone, calendar, alternateCalendar, workWeek, timeFormat..)

Parameters:

Function
callback Optional
A function with one paramater that contains the parameters returned from the server

Example:

$SP().regionalSettings(function(region) {
  if (typeof region === "string") {
    // something went wrong
    console.log(region); // returns the error
  } else {
    // show the selected timezone, and the working days
    console.log("timeZone: "+region.timeZone);
    console.log("working days: "+region.workWeek.days.join(", "))
  }
})

registerPlugin

registerPlugin(pluginName, pluginFct)
Permits to register a plugin

Parameters:

String
pluginName
You have to define the plugin name
Function
pluginFct
You have to define the function of the plugin with one parameter that are the options passed

Example:

$SP().registerPlugin('test', function(options) {
  console.log(options.message);
})

removeNotify

removeNotify(name, options)
Permits to remove a notification that is shown on the screen

Parameters:

String
name Optional
Name of the notification
Object
options Optional
If you pass the options, then the 'name' is ignored
Boolean
options.all Optional, Default: false
To TRUE to remove ALL notifications
Boolean
options.includeSticky Optional, Default: true
To FALSE if you don't want to remove the sticky notifications (only works with the "all:true" option)

Example:

$SP().notify('Processing the data...', {sticky:true,name:"Processing data"}); // the notification will stay on the screen until we remove it
$SP().removeNotify("Processing data"); // the notification is removed

$SP().notify('Doing some stuff...');
$SP().notify('Doing some other stuff...');
$SP().removeNotify({all:true}); // all the notifications are removed

$SP().notify('Doing some stuff...');
$SP().notify('Doing some other stuff...');
$SP().notify('This is a sticky message', {sticky:true});
$SP().removeNotify({all:true, includeSticky:false}); // all the notifications are removed except the sticky one

showModalDialog

showModalDialog(options)
Show a modal dialog (based on SP.UI.ModalDialog.showModalDialog) but provides some advanced functions and better management of the modals (for example when you launch several modals)

Parameters:

Object
options Optional
Regular options from http://msdn.microsoft.com/en-us/library/office/ff410058%28v=office.14%29.aspx with some additional ones or some changes
String
options.html Optional
We can directly provide the HTML code as a string
String
options.width Optional
If equals to "calculated", then we use the 2/3 of the viewport width; if equals to "full" then we use the full viewport width; otherwise see the original documentation (https://msdn.microsoft.com/en-us/library/office/ff410058(v=office.14).aspx)
String
options.height Optional
If equals to "calculated", then we use 90% of the viewport height; if equals to "full" then we use the full viewport height; otherwise see the original documentation (https://msdn.microsoft.com/en-us/library/office/ff410058(v=office.14).aspx)
Boolean
options.closePrevious Optional, Default: false
It permits to close a previous modal dialog before opening this one
Boolean
options.wait Optional, Default: false
If we want to show a Wait Screen (alias for $SP().waitModalDialog())
String
options.id Optional, Default: random()
An unique ID to identify the modal dialog (don't use space or special characters)
Function
options.callback Optional
A shortcut to `dialogReturnValueCallback` with dialogResult and returnValue
Function
options.onload Optional
The modal might be delayed as we need to load some Sharepoint JS files; the `onload` function is called once the modal is shown
Function
options.onurlload Optional
When we use the "url" parameter, this is triggered when the DOMContent of the iframe is loaded (if it's the same origin)
String
options.title Optional
The title to give to the modal (if you use `wait:true` then it will be the main text that will appear)
String
options.message Optional
This parameter is only use if there is `wait:true` and permits to define the subtitle message
String
options.url Optional
A string that contains the URL of the page that appears in the dialog. If both url and html are specified, url takes precedence. Either url or html must be specified.
Number
options.x Optional
An integer value that specifies the x-offset of the dialog. This value works like the CSS left value.
Number
options.y Optional
An integer value that specifies the y-offset of the dialog. This value works like the CSS top value.
Boolean
options.allowMaximize Optional
A Boolean value that specifies whether the dialog can be maximized. true if the Maximize button is shown; otherwise, false.
Boolean
options.showMaximized Optional
A Boolean value that specifies whether the dialog opens in a maximized state. true the dialog opens maximized. Otherwise, the dialog is opened at the requested sized if specified; otherwise, the default size, if specified; otherwise, the autosized size.
Boolean
options.showClose Optional, Default: true
A Boolean value that specifies whether the Close button appears on the dialog.
Boolean
options.autoSize Optional
A Boolean value that specifies whether the dialog platform handles dialog sizing.

Example:

$SP().showModalDialog({
  title:"Dialog",
  html:'<h1>Hello World</h1><p><button type="button" onclick="$SP().closeModialDialog(\'here\')">Close</button></p>',
  callback:function(dialogResult, returnValue) {
    alert("Result="+dialogResult); // -> "here"
  }
})

// show a waiting message
$SP().waitModalDialog("Working...");
// --- do some stuff ---
// close the waiting message and open a new modal dialog
$SP().showModalDialog({
  closePrevious:true,
  title:"Success",
  html:'<h1>Done!</h1>'
})
// and use $SP().closeModalDialog() to close it

toCurrency

toCurrency(number, decimal, sign)
It will return a number with commas, currency sign and a specific number of decimals

Parameters:

Number|String
number
The number to format
Number
decimal Optional, Default: -1
The number of decimals (use -1 if you want to have 2 decimals when there are decimals, or no decimals if it's .00)
String
sign Optional, Default: '$'
The currency sign to add

Returns:

String
The converted number

Example:


$SP().toCurrency(1500000); // --> $1,500,000
$SP().toCurrency(1500000,2,''); // --> 1,500,000.00

toDate

toDate(textDate, forceUTC)
Change a Sharepoint date (as a string) to a Date Object

Parameters:

String
textDate
the Sharepoint date string
Boolean
forceUTC Optional, Default: false
Permits to force the reading of the date in UTC

Returns:

Date
the equivalent Date object for the Sharepoint date string passed

Example:

$SP().toDate("2012-10-31T00:00:00").getFullYear(); // 2012

toSPDate

toSPDate(dateObject, includeTime)
Change a Date object into a Sharepoint date string

Parameters:

Date
dateObject
The Date object you want to convert
Date
includeTime Optional, Default: false
By default the time is not returned (if the time appears then the WHERE clause will do a time comparison)

Returns:

String
the equivalent string for the Date object passed

Example:

  $SP().toSPDate(new Date(2012,9,31), true); // --> "2012-10-31 00:00:00"
  $SP().toSPDate(new Date(2012,9,31)); // --> "2012-10-31"

toXSLString

toXSLString(text)
Change a string into a XSL format string

Parameters:

String
text
The string to change

Returns:

String
the XSL version of the string passed

Example:

$SP().toXSLString("Big Title"); // --> "Big_x0020_Title"

usergroups

usergroups(username, setup, result)
Find the Sharepoint groups where the specified user is member of

Parameters:

String
username
The username with the domain (don't forget to use a double \ like "mydomain\\john_doe")
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Boolean
setup.error Optional, Default: true
The function will stop and throw an error when something went wrong (use FALSE to don't throw an error)
Boolean
setup.cache Optional, Default: true
Keep a cache of the result
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result

Example:

$SP().usergroups("mydomain\\john_doe",{url:"http://my.si.te/subdir/"}, function(groups) {
  for (var i=0; i < groups.length; i++) console.log(groups[i]); // -> "Roadmap Admin", "Global Viewers", ...
});

waitModalDialog

waitModalDialog(title, subtitle, height, width)
Shortcut for SP.UI.ModalDialog.showWaitScreenWithNoClose()

Parameters:

String
title Optional, Default: "Working on it..."
The main message with the loading spin
String
subtitle Optional, Default: ""
The subtitle
Number
height Optional
The modal height
Number
width Optional
The modal width

whoami

whoami(setup, result)
Find the current user details like manager, email, colleagues, ...

Parameters:

Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result

Example:

$SP().whoami({url:"http://my.si.te/subdir/"}, function(people) {
  for (var i=0; i < people.length; i++) console.log(people[i]+" = "+people[people[i]]);
});

workflowStatusToText

workflowStatusToText(code)
Return the text related to a workflow status code

Parameters:

String|Number
code
This is the code returned by a workflow

Example:

$SP().workflowStatusToText(2); // -> "In Progress"