Skip to content

Instantly share code, notes, and snippets.

View phillipharding's full-sized avatar

Phil Harding phillipharding

View GitHub Profile
@phillipharding
phillipharding / Orchestrate-DynamicLoading-Resources.js
Last active August 29, 2015 14:11
A small module for orchestrating and dynamically loading JS or CSS resources using Promises.
window.UT = window.UT || {};
UT.Masterpage = function() {
var
_jqui = null,
_wap = null,
_kom = null,
_sps = null,
_module = {
LoadJQueryUI: UT$Masterpage$LoadJQueryUI,
LoadKnockout: UT$Masterpage$LoadKnockout,
@phillipharding
phillipharding / Dynamic-Load-JS-CSS-Resource.js
Created December 11, 2014 16:52
Dynamically load a JS or CSS file
function LoadResource(url, afterUi) {
var
p = new $.Deferred(),
resource = null,
headOrBody = document.getElementsByTagName(typeof afterUi !== 'undefined' && afterUi ? "body" : "head")[0];
if (url.match(/.js$/gi)) {
resource = document.createElement("script");
resource.type = "text/javascript";
if (resource.readyState) { // IE
@phillipharding
phillipharding / SharePoint-2013-ScriptEditorWebPart.xml
Created January 12, 2015 12:50
SharePoint 2013 Script Editor webPart
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.ScriptEditorWebPart, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/>
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">$Resources:core,ScriptEditorWebPartTitle;</property>
<property name="Description" type="string">$Resources:core,ScriptEditorWebPartDescription;</property>
@phillipharding
phillipharding / SharePoint 2013 Content Editor WebPart.xml
Created January 12, 2015 12:51
SharePoint 2013 Content Editor WebPart
<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>House-Rules-Info</Title>
<FrameType>None</FrameType>
<Description></Description>
<IsIncluded>true</IsIncluded>
<FrameState>Normal</FrameState>
<MissingAssembly>Cannot import this Web Part.</MissingAssembly>
<PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge>
<IsIncludedFilter />
<Assembly>Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<html>
<head/>
<body>
<div id='embedded-feed' style='height:500px;width:100%;'></div>
<script src='https://c64.assets-yammer.com/assets/platform_embed.js' type='text/javascript'></script>
<script>
yam.connect.embedFeed({
container: '#embedded-feed',
network: 'sharepointusergroupukcommunity',
/*feedType: 'group',
@phillipharding
phillipharding / load-synchronise-execution-multiple-scripts.js
Created January 26, 2015 14:26
Load and Synchronise Execution of Multiple Scripts using Promises
/* load and synchronise execution of 2 or more scripts */
var
upsuModulesLoaded = [
RB.Masterpage.LoadResourceFromTenantRoot("_catalogs/masterpage/Buzz365/js/siteusage.js"),
RB.Masterpage.LoadResourceFromTenantRoot("_catalogs/masterpage/Buzz365/js/userprofile.js")
];
$.when.apply($, upsuModulesLoaded)
.done(function() {
RB.Masterpage.Log("Masterpage>>userprofile.js and siteusage.js have loaded");
var waitCount = 0;
@phillipharding
phillipharding / Set Indexable PropertyBag property.ps1
Last active August 29, 2015 14:14
Set an PropertyBag property as Indexable (Queryable via Search)
cls
Add-PSSnapin Microsoft.SharePoint.Powershell -ea SilentlyContinue
$w = Get-SPWeb "http://pub.pdogs.local/news"
$allProps = $w.AllProperties
$allProps.Keys | ? { $_ -match "^vti_indexedpropertykeys" } | % { "$_ = [$($allProps[$_])]" }
Write-Host
$propertyName = "MyWebTemplateID"
# indexedpropertykey must be base64 encoded value of the unicode string
@phillipharding
phillipharding / Set an PropertyBag property as Indexable (Queryable via Search) using CSOM + Powershell.ps1
Last active October 20, 2015 08:51
Set a PropertyBag property as Indexable (Queryable via Search) using CSOM + Powershell
function Set-PropertyBag {
param (
[string]$PropertyName,
[string]$PropertyValue = $null,
[bool]$Indexable = $false,
[Microsoft.SharePoint.Client.Web]$Web,
[Microsoft.SharePoint.Client.ClientContext]$ClientContext
)
process {
$indexedPropertyBagKey = "vti_indexedpropertykeys"
<View WebPartZoneID="wpzHeader" WebPartOrder="0" List="Lists/PromotedLinks" DefaultView="FALSE" BaseViewID="1" Hidden="TRUE">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="ListName" type="string">{$ListId:Documents;}</property>
<property name="ListId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">$ListId:Documents;</property>