Skip to content

Instantly share code, notes, and snippets.

View maxali's full-sized avatar

Mohamed Ali maxali

View GitHub Profile
@maxali
maxali / index.html
Last active January 27, 2016 00:49
JSON to Table
<!DOCTYPE html>
<html>
<head>JSON to Table</head>
<body>
<button type="button" value="Process" onclick="json2table('mytable')">
<table id='mytable'></table>
</body>
</html>
function getUserInformationList() {
var context = SP.ClientContext.get_current();
var list = context.get_web().get_siteUserInfoList(); //.get_currentUser();
var userInfoItems = list.getItems(SP.CamlQuery.createAllItemsQuery());
context.load(userInfoItems);
context.executeQueryAsync(
// success callback
function () {
//var listItemInfo = '';
@maxali
maxali / content-aware-frontpage.json
Last active February 15, 2016 22:43
Content Aware, JSON Based Structure FrontPage
{
"type": "FrontPage Structure",
"fields": [
"article",
"fosition",
"font",
"header",
"image"
],
"articles": [
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="dc08391a-82b7-44c6-b81b-5a093da0c978.RibbonCustomAction1"
RegistrationType="List"
RegistrationId="101"
Location="CommandUI.Ribbon"
Sequence="10001"
HostWebDialog="true"
HostWebDialogHeight="500"
HostWebDialogWidth="1000">
@maxali
maxali / LS.SP.JSOM.js
Created March 29, 2016 10:23 — forked from zplume/LS.SP.JSOM.js
SharePoint 2013 REST / JSOM / Utility functions (work in progress)
(function() {
var nsName = "LS"; // root namespace name
var ns = window[nsName]; // root namespace alias
var utils = ns.Utils; // utils alias
ns.SP = ns.SP || {};
ns.SP.JSOM = {
Data: {
Sites: {} // cache for Taxonomy terms JSON
},
@maxali
maxali / RenderListDataAsStream.js
Last active May 19, 2016 20:26
New SharePoint Document REST
TemplateHub.rest.post({
url:"https://inmetademo-9e1505ae3276fd.sharepoint.com/sites/templatehub/TemplateHub/_api/SP.AppContextSite(@target)/web/GetList(@listUrl)/RenderListDataAsStream?@listUrl='/sites/contentTypeHub/templatehub/Template Library'&@target='https://inmetademo.sharepoint.com/sites/contenttypehub/templatehub'&View=9dcf7a8c-e8f6-4866-8984-2465254ebb5f&FilterField1=Editor&FilterValue1=Mohamed Ali Abdi&FilterField2=FSObjType&FilterValue2=0",
data:'{"parameters":{"__metadata":{"type":"SP.RenderListDataParameters"},"ViewXml":"<View><Query><RowLimit>4</RowLimit></Query></View>","RenderOptions":23,"Paging":"","AllowMultipleValueFilterForTaxonomyFields":true}}'
})
.then(
function(data){
console.log(data)
})
@maxali
maxali / CreateDocumentWebApp.js
Last active May 24, 2023 17:28
Create Document Web App Modal
/*
CreateDocument.aspx is in frame with window.frameElement.commitPopup(url) and cancelPopup()
Fix:
create window.on("message | createDocument") that
starts CreateDocument.aspx diaglog in context of SharePoint docLib page.
*/
//Using a generic object.
@maxali
maxali / Set.Single.UserProfileProperty.js
Created December 12, 2017 09:42 — forked from vman/Set.Single.UserProfileProperty.js
SharePoint Online: Set Single Value User Profile property with REST API
(function ($) {
'use strict';
var requestHeaders = {
'X-RequestDigest': $("#__REQUESTDIGEST").val(),
"accept": "application/json; odata=nometadata",
"content-type": "application/json;odata=nometadata"
};
var userData = {
#Azure Resource Manager cmdlets to get hold of the dll. https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-4.0.0
Add-Type -Path "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.ApiManagement\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
#Utility function to get Microsoft Graph Access Token. To know more about this, see my post http://www.vrdmn.com/2017/05/authenticating-to-microsoft-graph-api.html
function Get-MSGraphToken($azuretenantADName, $userName, $userPassword)
{
$AzureADAuthority = "https://login.microsoftonline.com/$azuretenantADName/oauth2/v2.0/authorize"
$resourceURL = "https://graph.microsoft.com/"
$powerShellClientId = "1950a258-227b-4e31-a9cf-717495945fc2"
$userCreds = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential($userName, $userPassword)
$.getJSON(_spPageContextInfo.webAbsoluteUrl + "/_api/sphomeservice/context?$expand=Token,Payload").then( context => {
$.ajax({
url: context.Urls[0] + "/api/v1/sites/feed?start=0&count=3&acronyms=true",
headers: {
"Authorization": "Bearer " + context.Token.access_token,
"sphome-apicontext": context.Payload
}
})
})