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
/* Taken from http://wave.google.com/maintenance/index.html / Google */ | |
var cloudMoved = false; | |
var cloud2Moved = false; | |
var cloud3Moved = false; | |
var WAVE_TIME = 6000; | |
$(init); | |
function init() |
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
// "elem" is an element within the document, visible to the user | |
elem.style.display = "none"; | |
elem.style.display = "block"; |
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
/** | |
* Random number generator, never returns the same number | |
* more than once, only returns integers. | |
* @param min minimum number, inclusive | |
* @param max maximum number, inclusive | |
* Both @params are optional | |
*/ | |
var generateRandomNumber = (function(){ | |
var used = {}; |
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
var script = document.createElement('script'); | |
var code = "alert('foo');"; | |
try{ | |
script.appendChild(document.createTextNode(code)) | |
} catch(e) { | |
// IE | |
script.text = code; | |
} |
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(yourNodes).append(jQuery('<a>Click</a>').click(function(){ | |
var self = this.parentNode, // parentNode is a single element within yourNodes | |
loading = $('<div>LOADING</div>').appendTo(self), | |
id = self.id.replace(/^edit/,''); | |
// Retrieve textarea from server | |
jQuery.get('/getDataForTextArea?id=' + id, function(textareaValue){ | |
loading.remove(); |
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
/// Run this code in any browser | |
function RegularConstructor () { | |
} | |
RegularConstructor.prototype = { | |
meth1: function(){}, | |
meth2: function(){}, | |
meth3: function(){}, |
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 getSomething( a, b, c ) { | |
// Multiple return points aren't always bad ya' know! | |
if ( !(a && b && c) ) { return; } | |
// Continue with function, | |
// we know a, b and c are truthy values! | |
return /* whatever */; | |
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
new SiteTraverser({ | |
limit: 100, | |
check: function(source){ | |
return /<title>/.test(source) ? | |
new SiteTraverser.Success("Title Found!") : new SiteTraverser.Failure("No Title!"); | |
}, | |
httpError: function(xhr){ | |
return new SiteTraverser.Failure("Request failed.", 'Error code: ' + xhr.status); | |
} | |
}).go(); |
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
// @author James Padolsey | |
// originally posted @ http://stackoverflow.com/questions/1837056 | |
Array.prototype.binarySearch = function(v) { | |
/* ARRAY MUST BE SORTED */ | |
if ( !this.length ) { return false; } | |
if ( this[0] === v ) { return 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
$(ELEMENT).animate({ | |
left: [ 200, 'easeInOut' ], | |
top: [ 100, 'easeInSine' ], | |
width: 500 | |
}, 1000, 'linear'); | |
// The "linear" easing will only be used for the | |
// "width" property as the other two ("top" & "left") | |
// have their own easing functions to follow. |