Skip to content

Instantly share code, notes, and snippets.

@Aymkdn
Aymkdn / jsonpost.xml
Last active January 2, 2019 17:17
Post JSON using YQL Open Table
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Johannes Charman</author>
<description>JSON pages that need post data (this table is based on htmlpost by Christian Heilmann)</description>
<sampleQuery>select * from {table} where url='http://search.twitter.com/search.json' and postdata="q=test"</sampleQuery>
<documentationURL></documentationURL>
</meta>
<bindings>
<select itemPath="" produces="XML">
@Aymkdn
Aymkdn / CompareLibrairies.js
Created May 18, 2017 08:11
Use node to compare two Sharepoint librairies and copy the source to the destination. It will create the folders and files, but it will also update the Modified date and Modifier author in the destination to match the source
// Command: node index.js "http://my.site.com/my_root/my_source_libary/" "http://my.othersite.com/my_root/my_destination_libary/"
if (process.argv.length !== 4) throw "ERROR: please provide the source and the destination on the command line";
const colors = require('colors');
// load credentials
const credentials = require('../credentials');
const $SP = require('sharepointplus');
const sp = $SP().auth(credentials);
var requestdigest = '';
// contains the references to the items to update in the dest lib
@Aymkdn
Aymkdn / Date.parseFrom.js
Created January 30, 2017 11:02
Date.parseFrom() permits to parse a string to a JavaScript Date
/**
* Parse a string to a Date
* @param {String} strDate
* @param {String} format Supported format including YYYY, YY, MM, M, DD, D, with - and / separators
* @return {Date|Throw} the JS Date object, or throw Error("Invalid Date") if strDate is invalid
* @compatibility IE9+
* @example
* Date.parseFrom("1/10/2017", "MM/DD/YYYY"); // -> new Date(2017,0,10)
*/
Date.parseFrom=function(strDate, format) {
@Aymkdn
Aymkdn / loadExt.js
Last active December 31, 2022 04:32
To load JS and CSS files with vanilla JavaScript
// long version
function loadExt(files, after) {
var _this=this;
_this.files = files;
_this.js = [];
_this.head = document.getElementsByTagName("head")[0];
_this.after = after || function(){};
_this.loadStyle = function(file) {
var link = document.createElement("link");
link.rel = "stylesheet";
@Aymkdn
Aymkdn / method1a.js
Last active October 27, 2016 08:02
Examples to retrieve a manager in Sharepoint 2013
// Retrieve Manager for a username
// using REST API
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
var accountName = 'domain\\login';
// I suppose you use jQuery
$.ajax({
url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='" + encodeURIComponent(accountName) + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
@Aymkdn
Aymkdn / multiple_approve.js
Created September 15, 2016 08:26
Multiple Approve/Reject in Sharepoint 2010 (jQuery + approval.js)
/*! jQuery v3.1.0 | (c) jQuery Foundation | jquery.org/license */
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.1.0",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null!=a?a<0?this[a+this.length]:this[a]:f.call(this)},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.p
@Aymkdn
Aymkdn / tiny_http.js
Created July 12, 2016 06:55
Tiny HTTP Get/Post
/*
m: method ("get", "post")
u: url
c: callback (with 'xhr' as a parameter)
a: async (true / default) or sync (false)
d: post_data (the data to post)
*/
function tiny_http(m,u,c,a,d){var _xhr=new(this.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP");with(_xhr)onreadystatechange=function(){4^readyState||c(_xhr)},open(m,u,a),"post"===m.toLowerCase()?setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"):"",send(d)}
@Aymkdn
Aymkdn / PeopleSearch_parameters.md
Last active June 1, 2020 23:22
Create a Sharepoint 2013 native People Picker in JavaScript (using jQuery, or using SharepointPlus)

Details about some of the options.

SearchPrincipalSource

The principal sources to search.

  • All (15) – Search all principal sources.
  • MembershipProvider (4) – Search the current membership provider.
  • None (0) – Search no principal sources.
  • RoleProvider (8) – Search the current role provider.
  • UserInfoList (1) – Search the user information list.
@Aymkdn
Aymkdn / popup_draggable.html
Last active April 27, 2019 04:45
Draggable DIV cross-browser (from IE8) with pure JavaScript
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="popup" style="background-color:green;position:absolute;top:0px;left:0px;width:250px;height:250px;z-index:9999;box-shadow: 6px 6px 5px #888888;border-radius:6px;border:1px solid #4f4f4f;">
<div id="popup_bar" style="width:100%;background-color:#aaff66;position:relative;top:0;border-radius:6px 6px 0 0; text-align:center;height:24px;cursor:move">Title</div>
<p>Content of the popup</p>
</div>
</body>
@Aymkdn
Aymkdn / getid.js
Created October 21, 2015 06:42
Find the User ID from the User Information List in Sharepoint
// http://aymkdn.github.io/SharepointPlus/symbols/%24SP%28%29.html#.getUserInfo
$SP().getUserInfo("domain\\john_doe", function(info) {
if (typeof info === "string") {
console.log("Error:"+info); // there was a problem so we show it
} else
console.log("User ID = "+info.ID)
});
// query the User Information List
$SP().list("User Information List", "http://site.collection/root/dir").get({