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 buildKey(name) { | |
var key = ''; | |
if (name !== undefined) { | |
key = name; | |
key = key.replace(/ /g, '-'); // purge spaces | |
key = key.replace(/&/g, 'and'); // clean ampersand | |
key = key.replace(/[^a-zA-Z0-9-]/g, ''); // remove all non-alphas and non-number and non-dashes | |
key = key.toLowerCase(); | |
} | |
return key; |
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 alpha = { | |
'a': { | |
'random data': {} | |
}, | |
'b': { | |
'more random data': {} | |
} | |
}, // object hash | |
beta = { | |
'a': 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
// Only do anything if jQuery isn't defined | |
if (typeof jQuery == 'undefined') { | |
if (typeof $ == 'function') { | |
// warning, global var | |
thisPageUsingOtherJSLibrary = true; | |
} | |
function getScript(url, success) { |
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 waitForDocument = setInterval(function() { | |
if (document.readyState !== 'complete') return; | |
// or var WIN = window.open(); | |
// if (WIN.document.readyState !== 'complete') return; | |
// if (WIN.opener.document.readyState !== 'complete') return; | |
clearInterval(waitForDocument); | |
// do your work | |
}, 100); |
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
/* ============================================= * | |
queue to fire today ╭∩╮(︶︿︶)╭∩╮ | |
* ============================================= */ | |
function triggerOnTime(cb, hour, minute, pm) { | |
var config = { | |
// set to noon as default |
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
angular.module( 'YOUR_APP.directives' ).directive( 'fixedContent', | |
[ | |
function() { | |
'use strict'; | |
return { | |
restrict: 'A', | |
scope: { | |
fixedBelow: '=', | |
fixedPadding: '=' |
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 extend = function(out) { | |
out = out || {}; | |
for (var i = 1; i < arguments.length; i++) { | |
if (!arguments[i]) | |
continue; | |
for (var key in arguments[i]) { | |
if (arguments[i].hasOwnProperty(key)) | |
out[key] = arguments[i][key]; |
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
// http://jsfiddle.net/vWx8V/ | |
// use `keyCodes` for complete object of keyboard codes | |
'use strict'; | |
var keyCodes = ( function() { | |
var codes = { | |
'backspace' : 8, | |
'tab' : 9, | |
'enter' : 13, |
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
// Try | |
/{(.*?)}/ | |
// That means, match any character between { and }, but don't be greedy - match the shortest string which ends with } (the ? stops * being greedy). The parentheses let you extract the matched portion. | |
// Another way would be |
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
beforeEach(function() { | |
jasmine.addMatchers({ | |
// | |
// actual: data object to check for property | |
// | |
// expected: property or property chain as string | |
// | |
hasRequiredAttribute: function() { | |
return { | |
compare: function(actual, expected) { |
OlderNewer