This file contains hidden or 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
var oneDigit = { | |
'1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', | |
'6': 'six', '7': 'seven', '8': 'eight', '9': 'nine' | |
}; | |
var teens = { | |
'10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen', | |
'14': 'fourteen', '15': 'fifteen', '16': 'sixteen', | |
'17': 'seventeen', '18': 'eighteen', '19': 'nineteen' | |
}; | |
var twoDigit = { |
This file contains hidden or 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(){ | |
var ready = function(){ | |
//do stuff now! | |
}; | |
var readyCheck = function(){ (document.readyState === 'complete') && ready(); }; | |
if (document.addEventListener){ | |
document.addEventListener('readystatechange', readyCheck, false); | |
} | |
else { |
This file contains hidden or 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 generator(low, high, post){ | |
return function(override){ | |
if (!post || typeof post !== "function") post = function(arg){return arg}; | |
return post( Math.random() * (high - low) + low ); | |
} | |
} | |
//example | |
var rand = generator(0,10); // random doubles between 0 and 10 | |
var rand = generator(1,100,Math.round); // random ints between 1 and 100 |
This file contains hidden or 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
//make sure you have jQuery :) | |
//<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
(function(jQuery){ | |
console.log("adding stuff to jQuery"); | |
jQuery.fn.myExtension = function(){ | |
console.log("I'm asynchronous"); | |
var defer = $.Deferred(); |
This file contains hidden or 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 styleInPage(css, verbose){ | |
if(typeof getComputedStyle== "undefined") | |
getComputedStyle= function(elem){ | |
return elem.currentStyle; | |
} | |
var who, hoo, values= [], val, | |
nodes= document.body.getElementsByTagName('*'), | |
L= nodes.length; | |
for(var i= 0; i<L; i++){ | |
who= nodes[i]; |
This file contains hidden or 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
//scroll to element | |
function scrollTo(el, offset){ | |
el.offsetParent && window.scroll(0, (function(){ | |
var position = 0; | |
do { position += el.offsetTop; } | |
while (el = el.offsetParent); | |
return position - (+offset || 0); | |
})()); | |
} |
This file contains hidden or 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 viewport(){ | |
//create element | |
var el = document.createElement("div"); | |
//style as you wish | |
el.id = 'screenSize'; | |
el.style.position = "fixed"; | |
el.style.width = "100%"; | |
el.style.left = "0px"; | |
el.style.bottom = "5px"; |
This file contains hidden or 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 parseQuery(){ | |
var query = {}; | |
var temp = window.location.search.substring(1).split('&'); | |
for (var i = temp.length; i--;) { | |
var q = temp[i].split('='); | |
query[q.shift()] = q.join('='); | |
} | |
return query; | |
} |
This file contains hidden or 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 firstFunction(next){ | |
console.log('first function'); | |
setTimeout(next, 1000); | |
} | |
function secondFunction(next){ | |
console.log('second function'); | |
setTimeout(next, 1000); | |
} |
This file contains hidden or 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($) { | |
$.fn.hasScrollbar = function() { | |
return this.get(0).scrollHeight > this.height(); | |
} | |
})(jQuery); |
NewerOlder