Skip to content

Instantly share code, notes, and snippets.

Avatar

Phil Harding phillipharding

View GitHub Profile
@phillipharding
phillipharding / pdogs-urlshortener-google.js
Created Aug 22, 2014
Javascript module for shortening URLs using Google (goo.gl)
View pdogs-urlshortener-google.js
(function($,window) {
"use strict";
window.pdogs = window.pdogs || {};
pdogs.urlshortener = function() {
var
_googlAPIKey = '<YOUR GOOGLE APIKey HERE>',
_module = { shorten: shorten };
return _module;
@phillipharding
phillipharding / linktodocument-original.js
Created Sep 1, 2014
Link To Document Validate - Original
View linktodocument-original.js
function ValidateInput()
{ULSvlv:;
var form = document.forms.aspnetForm;
var folderUrl = form.ctl00_PlaceHolderMain_ctl01_ctl01_UrlInput.value;
var name = form.ctl00_PlaceHolderMain_ctl01_ctl01_NameInput.value;
if (name == null ||
folderUrl == null ||
typeof(name) == "undefined" ||
typeof(folderUrl) == "undefined" ||
name.length == 0 ||
View linktodocumentvalidate-new.js
window.ValidateInput = function()
{ULSvlv:;
var L_ItemOrFolderNameTooLong_Ex = "The specified document name or URL is too long. The URL must be less than 255 characters and no more than 128 characters for the document name.\nPlease enter a shorter document name or URL.";
var L_EnterValidUrl_Text_Ex = "Enter a valid document name and URL. Valid URLs must begin with \u0027http:\u0027 or \u0027https:\u0027 and must be less than 255 characters.";
var form = document.forms.aspnetForm;
var folderUrl = form.ctl00_PlaceHolderMain_ctl01_ctl01_UrlInput.value;
var name = form.ctl00_PlaceHolderMain_ctl01_ctl01_NameInput.value;
if (name == null ||
folderUrl == null ||
View fixupnewlinkpage.js
(function (window) {
// are we on the NewLink.aspx page
if (!window.location.href.match(/_layouts\/NewLink.aspx\?/gi)) return;
/* is it for adding an item of a content type
inheriting the 'Document Link' content type item? */
var params=window.location.search.split('?')[1].split('&');
var s=$rb.grep(params, function(e) {
var p = e.split('=');
return (p.length > 1) && p[0].match(/ContentTypeId/gi) && p[1].match(/^0x01010A/gi);
View linktodocument.aspx
<%@ Assembly Name='Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' %>
<%@ Register TagPrefix='SharePoint' Namespace='Microsoft.SharePoint.WebControls' Assembly='Microsoft.SharePoint' %>
<%@ Import Namespace='System.IO' %>
<%@ Import Namespace='Microsoft.SharePoint' %>
<%@ Import Namespace='Microsoft.SharePoint.Utilities' %>
<%@ Import Namespace='Microsoft.SharePoint.WebControls' %>
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<meta name='progid' content='SharePoint.Link' />
<!--[if gte mso 9]><SharePoint:CTFieldRefs runat=server Prefix="mso:" FieldList="FileLeafRef,URL"><xml>
View Office 365 SharePoint REST with Minimalmetadata.js
news.popular.getPosts = function() {
var
p = new $.Deferred(),
r = {
url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getbytitle('Posts')/items?$select=Id,Title,PublishedDate,LikesCount,NumCommentsId,PostCategoryId&$orderby=PublishedDate desc"
+ getFilter(),
type: 'GET',
headers: { ACCEPT: 'application/json;odata=minimalmetadata' }
};
$.ajax(r)
@phillipharding
phillipharding / Get AppWeb and HostWeb Lists.js
Last active Aug 29, 2015
Get AppWeb and HostWeb Lists using the SharePoint 2013 REST API
View Get AppWeb and HostWeb Lists.js
// jQuery DOM ready
$(function() {
JSRequest.EnsureSetup();
$(".content-body").empty().show();
getAppWebLists();
getHostWebLists();
});
function getAppWebLists() {
var
@phillipharding
phillipharding / Get AppWeb Lists using a Promises Pattern.js
Created Nov 27, 2014
Get AppWeb Lists using a Promises Pattern (or chaining) Allowing for Enrichment/Further Processing
View Get AppWeb Lists using a Promises Pattern.js
/* jQuery DOM ready */
$(function() {
JSRequest.EnsureSetup();
GetAppWebLists()
.then(EnrichData)
.then(RenderAppWebLists)
.fail(function(error) {
$(".content-body").html(error).show();
});
@phillipharding
phillipharding / Dynamic-Load-JS-CSS-Resource.js
Created Dec 11, 2014
Dynamically load a JS or CSS file
View Dynamic-Load-JS-CSS-Resource.js
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 / Orchestrate-DynamicLoading-Resources.js
Last active Aug 29, 2015
A small module for orchestrating and dynamically loading JS or CSS resources using Promises.
View Orchestrate-DynamicLoading-Resources.js
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,