|
// This script returns an array of Role Definition objects, containing the Permission Levels for the site |
|
|
|
// See http://msdn.microsoft.com/en-us/library/office/jj244931(v=office.15).aspx for examples of how to use the |
|
// SP.PermissionKind object to assign permissions to a Role Definition |
|
|
|
// replacement function for console.log(), which avoids 'undefined' exception in IE 8 |
|
window.LogMsg = function (msg) { |
|
if (window.console) { |
|
console.log(msg); |
|
} |
|
}; |
|
|
|
// ensure library is loaded before executing a function |
|
// ns = namespace (i.e. jQuery) |
|
// url = url of library (i.e. from a CDN) |
|
// func = a function to execute when the library has loaded |
|
window.EnsureLibrary = function (ns, url, func) { |
|
// execute a function when a library has loaded |
|
var executeOnLoaded = function (ns, func) { |
|
if (!window[ns]) { |
|
setTimeout(function () { |
|
executeOnLoaded(ns, func); |
|
}, 100); |
|
} else { |
|
LogMsg(ns + " loaded"); |
|
func(); |
|
} |
|
}; |
|
|
|
if (!window[ns]) { |
|
var script = document.createElement("script"); |
|
script.setAttribute("src", url); |
|
var head = document.getElementsByTagName("head")[0]; |
|
head.appendChild(script); |
|
} |
|
|
|
executeOnLoaded(ns, func); |
|
}; |
|
|
|
(function() { |
|
var jQueryURL = "//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"; |
|
var restEndpoint = _spPageContextInfo.webAbsoluteUrl + "/_api/web/RoleDefinitions?$select=Name,Description,Id,BasePermissions"; |
|
|
|
EnsureLibrary("jQuery", jQueryURL, function() { |
|
jQuery.noConflict(); |
|
jQuery.ajax({ |
|
url: restEndpoint, |
|
cache: false, |
|
async: true, |
|
dataType: "json" |
|
}).done(function (data) { |
|
var data = data.value; |
|
LogMsg(data); |
|
}); |
|
}); |
|
})(); |
|
|
|
|