Last active
December 27, 2018 16:48
-
-
Save codegard1/a5023ec6c5f6405a9c3e5e5f9db7549e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="results"></div> | |
<script type="text/javascript"> | |
console.time('initialize'); | |
function retrieveWebSiteProperties(siteUrl) { | |
var clientContext = SP.ClientContext.get_current(); | |
this.oWebsite = clientContext.get_web(); | |
this.collList = oWebsite.get_lists(); | |
this.listInfoCollection = clientContext.load(collList); | |
clientContext.executeQueryAsync( | |
Function.createDelegate(this, this.onQuerySucceeded), | |
Function.createDelegate(this, this.onQueryFailed) | |
); | |
} | |
function onQuerySucceeded(sender, args) { | |
var listInfo = []; | |
var listEnumerator = this.collList.getEnumerator(); | |
while (listEnumerator.moveNext()) { | |
var oList = listEnumerator.get_current(); | |
if (oList.get_title().indexOf("Site") !== -1) { | |
console.log( oList.get_title() ); | |
listInfo.push( | |
// Create a P element and append it to the listInfo array | |
jQuery('<p/>').text('Title: ' + oList.get_title() + ' Created: ' + | |
oList.get_created().toString()) | |
); | |
} | |
} | |
jQuery("#results").html(listInfo); | |
console.timeEnd('initialize'); | |
} | |
function onQueryFailed(sender, args) { | |
console.log('Request failed. ' + args.get_message() + | |
'\n' + args.get_stackTrace()); | |
console.timeEnd('initialize'); | |
} | |
// Define the "starting" method that executes the callback | |
function initialize() { | |
SP.SOD.executeFunc("sp.js", "SP.ClientContext", function () { | |
// This will run after SP.js is loaded. | |
retrieveWebSiteProperties(_spPageContextInfo.webAbsoluteUrl); | |
}); | |
} | |
// Add the initializing method to the load queue | |
_spBodyOnLoadFunctionNames.push('initialize'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment