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
// Bootstrap Tab - Return to Last Known on page refresh or back/forward movement. | |
// Using data- attrs to identify tab groups to enable use multiple times on a page | |
$( '[data-tab-group]' ).each( function ( i, o ) { | |
var tabGroup = $( o ); | |
var lastKnownTabId = tabGroup.data( 'tab-group' ); // Tab Group Id, from the data- attr | |
var lastKnownTab = localStorage.getItem( lastKnownTabId ); | |
//Set last known tab back on script load - specific to this Tab Group Id | |
tabGroup.find( ' a[href="#' + lastKnownTab + '"]' ).tab( 'show' ); |
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
// Read and Format Error messages | |
// Using custom ajax request | |
// You may need to get to modelState differently depending on how you make your ajax call | |
// Attached to the jQuery namespace using $.summary = function | |
$.summary = function ( res ) { | |
var errors = [], validationSummary; | |
// eg - res.data.modelState |
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
//Query string reader function attacehd to jQuery namespace | |
$.qs = function ( name ) { | |
name = name.replace( /[\[]/, "\\[" ).replace( /[\]]/, "\\]" ); | |
var regex = new RegExp( "[\\?&]" + name + "=([^&#]*)" ); | |
var results = regex.exec( location.search ); | |
return results == null ? '' : decodeURIComponent( results[1].replace( /\+/g, " " ) ); |
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
//Incomplete | |
$('div a.grid-image').map(function (i, link){ | |
$('body').append('<canvas/>'); | |
var canvas = $('canvas')[i]; | |
var ctx = canvas.getContext('2d'); | |
var img = new Image(); | |
img.crossOrigin = 'anonymous'; | |
img.src = '...'; | |
img.onload = function(){ |
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
protected string RenderRazorViewToString(string viewName, object model) | |
{ | |
ViewData.Model = model; | |
using (var sw = new StringWriter()) { | |
var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName); | |
var viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw); | |
viewResult.View.Render(viewContext, sw); | |
viewResult.ViewEngine.ReleaseView(ControllerContext, viewResult.View); | |
return sw.GetStringBuilder().ToString(); | |
} |
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
<script> | |
// to dynamically set base url by reading the virtual servers path from the url | |
// doesn't work perfectly, causes double load as the first set of script calls fire to the base / url without the vd, then the second set go to the vd url (runtime.js etc) | |
let p = location.pathname.split('/').filter(x => x); | |
let baseHref = '/'; | |
if (!location.origin.includes('localhost:4200')) { | |
baseHref += p[0] + '/' + p[1] + '/' + p[2] + '/'; | |
} | |
console.log('baseHref', baseHref); |
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
import { Inject, Injectable, InjectionToken, LOCALE_ID, Optional } from '@angular/core'; | |
import { DateAdapter } from '@angular/material/core'; | |
import { DateTime, Info } from 'luxon'; | |
export const DATE_LOCALE = new InjectionToken<string>('DATE_LOCALE'); | |
/** Provider for MAT_DATE_LOCALE injection token. */ | |
export const DATE_LOCALE_PROVIDER = { provide: DATE_LOCALE, useExisting: LOCALE_ID }; | |
const ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/; |