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
const ColorBrightness = (color, percent) => { | |
//default percent to itself or the new percentage | |
percent = percent || 0; | |
// guard clause for out of range | |
if(percent > 100 || percent < -100) return; | |
// converting whole numbers down to percentages. | |
if(percent > 1 || percent < -1){ | |
console.log('assuming percentages as whole number between -100 and 100'); |
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
// Paramters: lookupFieldName - Internal name of field | |
// lookupFieldValue - ID of lookup item | |
SP.CamlQuery.createLookupQuery = function SP_CamlQuery$createLookupQuery(lookupFieldName,lookupFieldValue){ | |
this.lookupFieldName = lookupFieldName || null; | |
if(this.lookupFieldName === null){ | |
console.error('Missing Parameter(s): lookupFieldname and lookupFieldValue'); | |
return; | |
} | |
this.lookupFieldValue = lookupFieldValue || null; |
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
SP.ClientContext.prototype.executeQuery = function(){ | |
if(window.jQuery){ | |
var d = $.Deferred(); | |
this.executeQueryAsync( | |
function() { d.resolve(arguments); }, | |
function() { d.reject(arguments); } | |
); | |
return d.promise(); | |
} | |
else{ |
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
/* | |
* Created by Rajiv Gomer | |
* Released under the MIT license | |
* Date: 2018-01-11 | |
* Tested using SharePoint 2013/16/19 Classic Mode | |
* Parameters: 1. URL (string, Required) | |
* 2. Url Title (Default: URL) | |
* 3. Timer (Integer, Default: 10) | |
* 4. Override (boolean, Default: false, true makes the countdown timer clickable to stop the redirect) | |
* Usage: 1. SP.Redirect("<Required string: URL>") |
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
Object.prototype.clone = function(){ | |
var obj = (this instanceof Date) ? new Date(this) : (this instanceof Array) ? [] : {}; | |
if(obj instanceof Date) | |
return obj; | |
for(i in this){ | |
if(i == 'clone') | |
continue; | |
(this[i] && typeof this[i] == 'object') ? obj[i] = this[i].clone() : obj[i] = this[i]; | |
} | |
return obj; |
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
HTMLElement.prototype.setBgColor = function(r,g,b){ | |
var el = this; | |
var generateLuminance = function(r,g,b){ | |
return (0.299*r)+(0.587*g)+(0.114*b); | |
} | |
el.style.backgroundColor = 'rgb('+r+','+g+','+b+')'; | |
if(generateLuminance > 138){ | |
el.style.color = 'rgb(0,0,0)'; | |
} | |
else{ |
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
/* | |
* Created by Rajiv Gomer | |
* Released under the MIT license | |
* Date: 2019-01-17 | |
* Tested using SharePoint 2013 On-Prem | |
* Usage: 1. Add to MasterPage as site level custom action. | |
* 2. Activate Search by pressing "Ctrl+Shift+F" OR "F3" | |
* 3. Deactivate Search bar by clicking out of window or Escape key. | |
*/ |
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
/* Adds isAfter, isBefore, and isBetween functions to the Date object | |
* isAfter(<Date Object>) OR isAfter('MM/DD/YYYY') | |
* isBefore(<Date Object>) OR isBefore('MM/DD/YYYY') | |
* isBetween(<Start Date Object>, <End Date Object>) OR isBetween('MM/DD/YYYY','MM/DD/YYYY') | |
* | |
* Assuming todays' date is 12/25/2018 | |
* var date = new Date(); | |
* date.isAfter('12/12/2018') returns true; | |
* date.isBefore('12/12/2018') returns false; | |
* date.isBetween('12/1/2018','12/31/2018') returns true; |
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
var siteurl = _spPageContextInfo.webAbsoluteUrl; | |
var formDigest; | |
var generateCustomAction = function(location,sequence,title,description,url){ | |
location = location || 'ScriptLink'; | |
sequence = sequence || 1000; | |
title = title || 'Test Custom Action'; | |
description = description || 'Test Description'; | |
url = url || '~sitecollection/Style Library/scripts/jquery-3.3.1.js'; | |
return JSON.stringify({ | |
'__metadata': { |
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
/*! | |
* Title: SP.List.recycleItems.js | |
* Created by Rajiv Gomer | |
* Released under the MIT license | |
* Date: 2018-03-09 | |
* Tested using SharePoint 2013 On-Prem | |
* Parameters: 1. Required: List View Name (string) | |
* Usage: 1. SP.List.recycleItems('<List View Name>'); | |
* Usage: 2. new SP.ClientContext.get_context().get_web().get_lists().getByTitle('<List Name>').recycleItems('<List View Name>'); | |
*/ |
NewerOlder