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 toFunc(v){ | |
if(typeof(v) == "function") return v; | |
if(typeof(v) == "string"){ | |
if( | |
window[v] != undefined && | |
typeof(window[v]) == "function" | |
){ | |
return window[v]; | |
} | |
try { |
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 saveAs(text, filename){ | |
var pom = document.createElement('a'); | |
pom.setAttribute('href', 'data:text/plain;charset=urf-8,'+encodeURIComponent(text)); | |
pom.setAttribute('download', filename); | |
pom.click(); | |
}; |
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
Math.__proto__.randInt = function(min, max){ | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
}; |
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.replaceAll = function(search, replacement) { | |
var target = this; | |
return target.replace(new RegExp(search, 'g'), replacement); | |
}; |
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 getScrollbarWidth () { | |
var inner = document.createElement('p'); | |
inner.style.width = "100%"; | |
inner.style.height = "200px"; | |
var outer = document.createElement('div'); | |
outer.style.position = "absolute"; | |
outer.style.top = "0px"; | |
outer.style.left = "0px"; | |
outer.style.visibility = "hidden"; | |
outer.style.width = "200px"; |
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.hasAttr=function(a){var b=$(this).attr(a);return void 0!==typeof b&&b!==!1}; | |
$.fn.getFormData = function(){ | |
var data = {}; | |
$(this).find("input, select, textarea").each(function(i, input){ | |
var $input = $(input); | |
if($input.hasAttr("name")){ | |
if($input.attr("type") && $input.hasAttr("type") && $input.attr("type").toLowerCase() == "checkbox"){ | |
if($input.is(":checked")){ | |
data[$input.attr("name")] = true; | |
} else { |
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); | |
}; |
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)); | |
}; |
OlderNewer