Skip to content

Instantly share code, notes, and snippets.

@koohq
koohq / sp-loginasanother.js
Created November 12, 2017 10:21
Bookmarklet for switching login user on SharePoint pages (Licensed under CC0)
javascript:(function(){LoginAsAnother(_spPageContextInfo.webServerRelativeUrl.replace(/^\/$/,'')+'/_layouts/15/CloseConnection.aspx?loginasanotheruser=true',0)})();
@koohq
koohq / sp-contextitemhelper.js
Created November 12, 2017 10:15
Get/Update for SPListItem at DispForm
/**
* sp-contextitemhelper.js
* Provide functions that manupilates the context list item (displayed now).
* Assumed for showing/updating hidden fields at the browser.
*
* (c) 2017 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
var SPContextItemHelper = (function() {
var clientCtx = SP.ClientContext.get_current();
@koohq
koohq / sp-fielddisplaynamechanger.js
Created November 9, 2017 16:25
Changing the display name of field on the SharePoint List view
/**
* sp-fielddisplaynamechanger.js
* Provides a function to create a function that changes the display name of field.
* The created function is use for JSLink on SharePoint list view pages.
*
* (c) 2017 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
var SPFieldDisplayNameChanger = (function() {
function create(nameMapping) {
@koohq
koohq / sp-pdfpreview.js
Created November 5, 2017 17:50
A snippet to enable the PDF file preview by using 'filePreview.js'.
/**
* sp-pdfpreview.js
*
* (c) 2017 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
(function enablePDFPreview() {
ExecuteOrDelayUntilScriptLoaded(function() {
filePreviewManager.previewers.extensionToPreviewerMap.pdf = [embeddedWACPreview, WACImagePreview];
embeddedWACPreview.dimensions.pdf = { width: 379, height: 252 };
@koohq
koohq / jquery.sp-viewheaderfreezer.js
Last active January 8, 2018 11:55
Freezing of the SharePoint List/Library header
/**
* jquery.sp-viewheaderfreezer v1.0.0
* jQuery plugin to freeze the list-view-header on SharePoint pages.
*
* (c) 2017 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
(function($, cn) {
$.fn.freezeSPViewHeader = function(h, w) {
var $t = this;
@koohq
koohq / Use.ps1
Created November 3, 2017 18:46
A helper script to provide the method like "using" statement
<##
# Use.ps1
#
# (c) 2016 koohq. Licensed under CC0.
# https://creativecommons.org/publicdomain/zero/1.0/legalcode
#>
function Use
{
[CmdletBinding()]
@koohq
koohq / Config.ps1
Created November 3, 2017 08:27
A helper script for access to App.config by PowerShell
<##
# Config.ps1
#
# (c) 2017 koohq. Licensed under CC0.
# https://creativecommons.org/publicdomain/zero/1.0/legalcode
#>
function Initialize-AppConfigFile
{
[CmdletBinding()]
@koohq
koohq / Query.ps1
Created November 3, 2017 03:55
A helper script for query to MSSQL by PowerShell
<##
# Query.ps1
#
# (c) 2016 koohq. Licensed under CC0.
# https://creativecommons.org/publicdomain/zero/1.0/legalcode
#>
function Use
{
[CmdletBinding()]