Skip to content

Instantly share code, notes, and snippets.

//after goldfish has run...
const head = document.head || document.getElementsByTagName('head')[0];
const overrides = document.createElement('style');
overrides.type = 'text/css';
const css = '#menu-items { display:none; } #outer-space { width: 100%; } #component, #component-favourites, #component-layout, #component-settings { display:block; box-shadow: 0 0 2px #d9d9d9; }#component {right: 1200px;}#component-favourites {right: 800px;}#component-layout {right: 400px; }';
if (overrides.styleSheet) {
overrides.styleSheet.cssText = css;
/*
I have used jQuery deferred objects here for the promises but you will want to swap these out for Es6 promises.
Also, hook this up to Flux (Action, Store etc..)
*/
(function(crumbs, $) {
crumbs.PROPERTY_KEY = 'adw.breadcrumbs';
function getRestEndPoint (endpoint) {
return jQuery.ajax({
/*
The console.time functionality can be used for measuring performance of JavaScript functions (outputing processing times to the developer console window)
https://developer.mozilla.org/en-US/docs/Web/API/Console/time
*/
// console.time implementation for IE
if ( window.console && typeof ( window.console.time ) == "undefined") {
console.time = function (name, reset) {
(function (userProfiles, $) {
...
//Store the value in our JSON object
function updateProperty (key, value) {
userProfiles.Current[key] = value;
}
//This method iterates through the nested ugly JSON object array to get what we need (IE9+ or you will need to refactor the array.some functionality)
(function (userProfiles, $) {
userProfiles.Constants = {
EndPoint: '/_api/SP.UserProfiles.PeopleManager/GetMyProperties',
Cache: {
Key: 'ProfileProperties'
}
};
//You've seen this already, move on...
/*
The following code assumes you have a javascript namespace called MyCompany. I recommend you either swap that out for your namespace or create an instance of MyCompany before trying the code
var MyCompany = MyCompany || {};
*/
(function (userProfiles, $) {
//This is where we hold our lovely properties
/*
* PLEASE NOTE: This function makes use of ES6 promises. Make sure you use the appropriate shim or swap this out for the jQuery equivilant if you need this to run of web browsers that do not support this functionality
* https://github.com/stefanpenner/es6-promise
*
* PARAMS
* @key - Local Storage Cache Key
* @url The URL of the REST endpoint
* @alwaysFresh - Boolean representing when to fetch the data when the cache is stale (out of date). When set to true, the result set will be fetched from the endpoint immediately
*
* Get data back from cache or request from the server when the cache is stale:
(function (userProfiles, $) {
userProfiles.Constants = {
EndPoint: '/_api/SP.UserProfiles.PeopleManager/GetMyProperties',
Cache: {
Key: 'ProfileProperties'
}
};
//Object to store the given user's profile properties
@beckettkev
beckettkev / Options.js
Created March 29, 2016 19:59
Goldfish Options
var options = {
title: 'People Search',
termsets: [
{
//the heading of the grouping
title: 'Groups',
//type declares if it is a Termset or a Field in the User Information List
type: 'Termset',
config = {
client_id: <INSERT CLIENT ID GUID>,
redirect_base_uri: <INSERT THE URL OF THE APP>
}