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
const stringToDOM = str => new DOMParser().parseFromString(str, 'text/html').body.childNodes[0]; |
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
String.prototype.extract = function(start, finish){ | |
var s = this.indexOf(start); | |
if(s == -1) return ""; | |
var e = this.indexOf(finish, s + start.length); | |
if(e == -1) return ""; | |
return this.substring(s + start.length, e); | |
} |
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
$.fn.animateTransform = function(/* [start,] end [, duration] [, callback] */){ | |
var start = null, end = null, duration = 400, callback = function(){}; | |
for(var i=0; i<arguments.length; i++){ | |
if(typeof(arguments[i]) == "string"){ | |
if(!start) start = arguments[i]; | |
else end = arguments[i]; | |
} else if(typeof(arguments[i]) == "number"){ | |
duration = arguments[i]; | |
} else if(typeof(arguments[i]) == "function"){ | |
callback = arguments[i]; |
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
jQuery.fn.selectText = function(){ | |
var doc = document; | |
var element = this[0]; | |
if (doc.body.createTextRange) { | |
var range = document.body.createTextRange(); | |
range.moveToElementText(element); | |
range.select(); | |
} else if (window.getSelection) { | |
var selection = window.getSelection(); | |
var range = document.createRange(); |
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
$.fn.attrs = function(){ | |
var attributes = {}; | |
if(this.length){ | |
$.each( this[0].attributes, function( index, attr ) { | |
attributes[ attr.name ] = attr.value; | |
}); | |
} | |
return attributes; | |
}; |
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
function roundTo(number, to){ | |
return (Math.round(number * (1/to)) / (1/to)); | |
}; |
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
function containsObject(a,b){for(var c in a)if(!b[c]||a[c]!=b[c])return!1;return!0} |
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
function validCSS(property, value){ | |
var $el = $("<div></div>"); | |
$el.css(property, value); | |
return ($el.css(property) == value); | |
} |
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
function betterParseFloat(num){ | |
num = (num+"").replace(new RegExp(",", 'g'), ""); // Remove commas | |
return (num.length==0)?0:(isNaN(parseFloat(num)))?betterParseFloat(num.substr(1)):parseFloat(num); | |
}; |
NewerOlder