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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 checkPopupBlocked(poppedWindow) { | |
setTimeout(function(){doCheckPopupBlocked(poppedWindow);}, 5000); | |
} | |
function doCheckPopupBlocked(poppedWindow) { | |
var result = false; | |
try { | |
if (typeof poppedWindow == 'undefined') { |
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
app.directive('infiniteScroll', [ | |
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) { | |
return { | |
link: function(scope, elem, attrs) { | |
var checkWhenEnabled, handler, scrollDistance, scrollEnabled; | |
$window = angular.element($window); | |
elem.css('overflow-y', 'scroll'); | |
elem.css('overflow-x', 'hidden'); | |
elem.css('height', 'inherit'); | |
scrollDistance = 0; |
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
// generate a random username | |
var randomName = function() { | |
var animals = ['pigeon', 'seagull', 'bat', 'owl', 'sparrows', 'robin', 'bluebird', 'cardinal', 'hawk', 'fish', 'shrimp', 'frog', 'whale', 'shark', 'eel', 'seal', 'lobster', 'octopus', 'mole', 'shrew', 'rabbit', 'chipmunk', 'armadillo', 'dog', 'cat', 'lynx', 'mouse', 'lion', 'moose', 'horse', 'deer', 'raccoon', 'zebra', 'goat', 'cow', 'pig', 'tiger', 'wolf', 'pony', 'antelope', 'buffalo', 'camel', 'donkey', 'elk', 'fox', 'monkey', 'gazelle', 'impala', 'jaguar', 'leopard', 'lemur', 'yak', 'elephant', 'giraffe', 'hippopotamus', 'rhinoceros', 'grizzlybear']; | |
var colors = ['silver', 'gray', 'black', 'red', 'maroon', 'olive', 'lime', 'green', 'teal', 'blue', 'navy', 'fuchsia', 'purple']; | |
return colors[Math.floor(Math.random() * colors.length)] + '-' + animals[Math.floor(Math.random() * animals.length)]; | |
}; |
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
/* Detects ftp | ftps | http | https and prepends http:// if none */ | |
function ensureUrlScheme(url) { | |
if (!/^(((f|ht)tps?)|chrome-extension):\/\//i.test(url)) { | |
url = "http://" + url; | |
} | |
return url; | |
} | |
/* Detects the scheme of the url, removes it */ | |
function detachUrlScheme(url) { |
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
/// Replace element with it's first child | |
Utils.replaceWithChild = function(element) { | |
var child = angular.element(element[0].firstChild); | |
Utils.mergeAttributes(element, child); | |
element.replaceWith(child); | |
} | |
/// Copy attributes from sourceElement to targetElement, merging their values if the attribute is already present | |
Utils.mergeAttributes = function(sourceElement, targetElement) { | |
var arr = sourceElement[0].attributes; |
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
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
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 inherits = require('inherits'); | |
var Game = require('crtrdg-gameloop'); | |
var Entity = require('crtrdg-entity'); | |
var Keyboard = require('crtrdg-keyboard'); | |
var canvas = document.createElement('canvas'); | |
canvas.id = 'game'; | |
var body = document.getElementsByTagName('body')[0]; |
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
/*! | |
Math.uuid.js (v1.4) | |
http://www.broofa.com | |
mailto:robert@broofa.com | |
Copyright (c) 2010 Robert Kieffer | |
Dual licensed under the MIT and GPL licenses. | |
*/ | |
/* |
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
/** | |
* A list of JavaScript key codes to reference by name. | |
* From 'Foundation HTML5 Animation with JavaScript': http://amzn.com/1430236655?tag=html5anim-20 | |
*/ | |
var keycode = { | |
BACKSPACE: 8, | |
TAB: 9, | |
ENTER: 13, | |
COMMAND: 15, |
OlderNewer