Skip to content

Instantly share code, notes, and snippets.

@rhysburnie
rhysburnie / jquery-ajax-dataFilter.js
Last active January 17, 2022 22:02
jQuery ajax dataFilter to remove scripts from html string to prevent script execution if loading string into a temp dom element
function dfStripScripts = function(data, type)
{
// incase the response is full html with scripts remove them
type = type || 'text';
if(type=='html'||type=='text'){
/*return data.replace(/<script.*>.*?<\/script>/gi, '');*/
return data.replace(/<script.*?>([\w\W\d\D\s\S\0\n\f\r\t\v\b\B]*?)<\/script>/gi, '');
}
return data;
};
@rhysburnie
rhysburnie / jquery.imgload.js
Last active December 16, 2015 06:59
onload image event plugin
/*!
* @author: Rhys Burnie [rb]
*
* MIT license
*/
;(function($){
$.fn.extend({
/**
* .imgload
@mixin instrinsic-ratio($width, $height, $position: relative)
{
@if unit($width) != unit($height) {
@warn "@include instrinsic-ratio-wrapper: $width and $height must share the same unit type, supplied was: #{$width} / #{$height}";
}
$w: to-unitless($width);
$h: to-unitless($height);
$ratio: $h / $w;
$percent: $ratio * 100%;