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 colorContrastUtil = (function () { | |
/** | |
* Convert Hex value to RGB. | |
* @param {String} hex Color representation | |
* @return {Object} Object with r, g, and b, params. | |
*/ | |
var hexToRgb = function (hex) { | |
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") | |
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; |
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
.filter('phoneNumber', function(){ | |
return function(input){ | |
if(input && (input.length === 7)){ | |
return input.substr(0,3) + '-' + input.substr(3,7); | |
} else if(input.length === 10){ | |
console.log(input); | |
return '(' + input.substr(0,3) + ') ' + input.substr(3,3) + '-' + input.substr(6,4); | |
} | |
return input; | |
}; |
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
if(developer === 'eric' && domain === 'phoenix.edu'){ eric.toggle(); } |
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
/** | |
* Returns new globally unique identifier. | |
* @return {String} identifier in form 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' | |
*/ | |
var getGUID = function(){ | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); | |
return v.toString(16); | |
}); | |
}; |
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 myNamespace = (function () { | |
var myPrivateVar, myPrivateMethod; | |
// A private counter variable | |
myPrivateVar = 0; | |
// A private function which logs any arguments | |
myPrivateMethod = function( foo ) { | |
console.log( foo ); |
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
/** | |
* Trim Polyfill for IE8 and lower. | |
*/ | |
if (!String.prototype.trim) { | |
String.prototype.trim = function () { | |
return this.replace(/^\s+|\s+$/g, ''); | |
}; | |
} |
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
/** | |
* Scrape indicated selectorString element from single or multiple web pages. | |
* @param {Number} numPages Number of pages to scrape. Depends on RESTful pagination. | |
* @param {String} urlRoot Base URL. | |
* @param {String} selectorString jQuery selector string. | |
* @param {Array} returnArray Array of jQuery objects matching the selectorString. | |
* @return {Array} returnArray | |
*/ | |
function consoleScrape(numPages, urlRoot, selectorString, returnArray) { |
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
/** | |
* Takes a string and returns true if its a valid email address. | |
* @param {String} email Email address to be tested for validity. | |
* @return {Boolean} True if valid email, false if not. | |
*/ | |
function isValidEmail(email) { | |
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; | |
return regex.test(email); | |
} |
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 $.grep() or $.map(). |
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
/** | |
* Changes the first character of each word to upper case, and any other characters to lowercase. | |
* @return {String} String formatted as a title. | |
*/ | |
String.prototype.toTitleCase = function() { | |
var title = this.replace(/([^\W_]+[^\s-]*) */g, function(txt) { | |
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); | |
}); |
NewerOlder