This file contains hidden or 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 getTimeSince(start, end) { | |
var msSince = (end - start); | |
var msInDay = 24*60*60*1000 | |
, msInHour = 60*60*1000 | |
, msInMinute = 60*1000 | |
, msInSecond = 1000; | |
if (msSince > msInDay) { // greater than one day | |
return parseInt(msSince / msInDay).toString() + 'd Ago'; |
This file contains hidden or 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 getQuerystringParamByName(name) { | |
name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]'); | |
var regexS = '[\\?&]' + name + '=([^&#]*)' | |
, regex = new RegExp(regexS) | |
, results = regex.exec(window.location.search); | |
if(!results) { | |
return ''; | |
} |
This file contains hidden or 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
============================================================== | |
MODULE :: hello.js | |
============================================================== | |
module.exports = function hello(name) { | |
this.name = name; | |
this.sayIt = function() { | |
return "Hello " + this.name; | |
}; |
This file contains hidden or 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 hello(name) { | |
this.name = name; | |
this.sayIt = function(callback) { | |
var self = this; | |
setTimeout(function() { | |
callback("Hello " + self.name); | |
}, Math.random()*1000); | |
}; | |
}; |
This file contains hidden or 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
// Chatham Namespace for exposing javascript functionality | |
// We can expose all of our functionality via this one global var | |
var CHATHAM = CHATHAM || {}; | |
CHATHAM.namespace = function (namespace_name_string) { | |
var parts = namespace_name_string.split('.'), | |
parent = CHATHAM, | |
i, cnt; | |
// remove the first part of the string which will be 'CHATHAM' |
This file contains hidden or 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
//uses the following syntax to create an object with private properties | |
// and functions. You expose the properties and functions you need publicly in the | |
// return object.... The immediate function allows us to have private scope for | |
// certain things | |
// Create a new namespace | |
CHATHAM.namespace('CHATHAM.utils.gridmgr'); | |
CHATHAM.utils.gridmgr = (function(){ |