var context;
var web;
var list;
var currentItem;
$(document).ready(function () {
context = new SP.ClientContext.get_current();
web = parentContext.get_web();
list = web.get_lists().getById(_spPageContextInfo.pageListId);
currentItem = list.getItemById(_spPageContextInfo.pageItemId)
context.load(currentItem);
context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
});
function onQuerySucceeded() {
var guid = currentItem.get_fieldValues("UniqueId").UniqueId.toString();
}
function onQueryFailed(sender, args) {
//Error Logging
}
function onQuerySucceeded() {
var keywordQuery = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(context);
keywordQuery.set_queryText('PageGuid:"{' + currentItem.get_fieldValues("UniqueId").UniqueId.toString() + '}"');
var searchExecutor = new Microsoft.SharePoint.Client.Search.Query.SearchExecutor(context);
results = searchExecutor.executeQuery(keywordQuery);
context.executeQueryAsync(SearchDone, SearchFailed)
}
function SearchDone() {
var viewCount = results.m_value.ResultTables[0].ResultRows[0].ViewsLifeTime;
//Use JQuery to show the viewCount on the page
}
function SearchFailed(sender, args) {
//Error Logging
}
26.11.14
Get page views, javascript sharepoint
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment