Keegan Watkins keeganwatkins

View class-def.js
1 2 3 4 5 6 7 8 9 10
// This is a fairly common pattern. First, define a constructor...
var Person = function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
};
 
// ...then define some methods by mixing into the prototype
$.extend(Person.prototype, {
sayHello: function() {
console.log('Hello, I\'m ' + this.getFullName());
View array-shuffle.js
1 2 3 4 5 6 7 8 9 10
var shuffle = function(source) {
var ret = Array.prototype.slice.call(source),
len = source.length,
i = len,
rand, temp;
while (i--) {
rand = parseInt( Math.random() * len, 10 );
temp = ret[ i ];
ret[ i ] = ret[ rand ];
View jquery.singularize.js
1 2 3 4 5 6 7 8 9 10
// jQuery UI sugar: an easy way to limit a plugin generated by the widget
// factory down to the first element. This is useful for widgets like dialog
// and mediaplayer that should be instantiated/configured individually.
$.widget.singularize = function(widgetName) {
// Keep a reference to the auto-generated plugin, so that we can use it later
var widget = $.fn[ widgetName ],
slice = Array.prototype.slice;
// Abort is widget doesn't exist to avoid creating random properties on $.fn
if (!widget || !($.isFunction(widget))) {
View iDevice.js
1 2 3 4 5
var isIDevice = navigator.platform.toLowerCase() in {
"ipod": true,
"ipad": true,
"iphone": true
};
Something went wrong with that request. Please try again.