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 decimalmark(num){ | |
return num.toString().split("").reverse().join("").replace(/(\d{3})/g, "$1,").replace(/,$/, "").split("").reverse().join(""); | |
} |
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
// todo: | |
// // allow html | |
// msg = text string | |
// lps = letters per second | |
// see eg http://jsfiddle.net/afahy/NGPYz/2/ | |
$.fn.typeout = function(msg, lps){ | |
var textLen, timer, interval, that, currStep; |
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
/* | |
Probably dangerous extensions to jquery-tmpl, allows you to set variables and exec code | |
* so not tested--don't blame me when it explodes | |
* see eg http://jsfiddle.net/afahy/GmGsp/2/ | |
Usage: adds {{set}} and {{exec}} template tags to templates | |
{{set(varname) value}} | |
{{=varname}} |
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 dev scaffolding */ | |
(function(global, $){ | |
var doc = global.document; | |
$.noConflict(); | |
$.bindReady = $.fn.ready; | |
$.ele = $.fn.init; | |
$.docRoot = new $.ele(doc); | |
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
// to be used in eg: | |
// element.addEventListener("keypress", numericOnly, false); | |
var numericOnly = function(e){ | |
var key = e.charCode || e.keyCode; | |
if((key < 37 || key > 40) && ((key > 19 && key < 48) || (key > 57 && key < 126))) { | |
e.preventDefault(); | |
this.value = this.value.replace(/[^0-9]/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
// See eg http://jsfiddle.net/sCQxU/1/ | |
HTMLElement.prototype.delegate = function(type, filter, callback){ | |
var fn = function(e){ | |
var ele = e.target; | |
if(filter(ele)){ | |
callback.apply(ele, arguments); | |
} | |
} | |
this.addEventListener(type, fn, true); |
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
/* | |
Toggles visibility of content by clicking .summary | |
Given eg: | |
<div class="details"> | |
<p class="summary">Summary</p> | |
<p>Full</p> | |
</div> |
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
// allows you to log an object while staying in the chain | |
(function($){ | |
var console = ("console" in window) ? window.console : { "log": alert, "dir": alert }; | |
$.extend($.fn, { | |
log: function(){ | |
console.log(this); | |
return this; | |
}, |
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
// everyone's new favorite closure pattern: | |
(function(window,document,undefined){ ... })(this,this.document); | |
// minified: | |
(function(b,a,c){ ... })(this,this.document); | |
// which means all uses of window/document/undefined inside the closure | |
// will be single-lettered, so big gains in minification. | |
// it also will speed up scope chain traversal a tiny tiny little bit. |
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
// simple timer function, piggybacking on jquery animate() | |
// accepts normal animate callbacks, like step and complete, props like duration | |
// returns object with props for percent complete and start time | |
(function($){ | |
$.timer = (function(){ | |
var f = function(params){ |