JavaScript: getAbsoluteUrl

Published on

/* Returns the absolute url. Usage: getAbsoluteUrl(‘/something’); http://davidwalsh.name/something reference: http://davidwalsh.name/essential-javascript-functions */ var getAbsoluteUrl = (function() { var a; return function(url) { if(!a) a = document.createElement(‘a’); a.href = url; return a.href; }; })();

JavaScript: debounce

Published on

/* Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. If `immediate` is passed, trigger the function on the leading edge, instead of the trailing. Usage: var myEfficientFn = debounce(function() { // All the taxing … Continue reading JavaScript: debounce

CSS: clearfixHack

Published on

/* Float Clearing http://nicolasgallagher.com/micro-clearfix-hack */ .group:after { content: ” “; /* 1 */ display: table; /* 2 */ clear: both; } .group { *zoom: 1; /* 3 */ }

JavaScript: callerName

Published on

/* callerName determines the name of the calling function. */ function callerName() { try { var myCallee = arguments.callee; var hisCallee = myCallee.caller.arguments.callee; var hisCallerName = hisCallee.caller.name; if (isNoE(hisCallerName)) { var hisCallersFunction = hisCallee.caller.toString(); if (!isNoE(hisCallersFunction)) { hisCallerName = fBetween(hisCallersFunction, “function”, “(“); } } hisCallerName = trim(hisCallerName); } catch (e) { hisCallerName = “”; } … Continue reading JavaScript: callerName