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
var isLeapYear = function(year) { | |
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; | |
} | |
, getDaysInMonth = function(month, year) { | |
return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; | |
} | |
; |
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
if (Object.defineProperty && Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(Element.prototype, "textContent") && !Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get) { | |
(function() { | |
var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText"); | |
Object.defineProperty(Element.prototype, "textContent", | |
{ | |
get: function() { | |
return innerText.get.call(this); | |
}, | |
set: function(s) { | |
return innerText.set.call(this, s); |
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
var _formatCount = function(sec) { | |
return { | |
w: Math.floor(sec / 86400 / 7),//weeks | |
d: Math.floor(sec / 86400 % 7),//days | |
h: Math.floor(sec / 3600 % 24),//hours | |
m: Math.floor(sec % 3600 / 60),//minutes | |
s: Math.floor(sec % 3600 % 60)//seconds | |
}; | |
}; |
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
<img src="data:image/png;base64,R0lGODlhFAAUAIAAAP///wAAACH5BAEAAAAALAAAAAAUABQAAAIRhI+py+0Po5y02ouz3rz7rxUAOw==" /> |
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
var getFileExtension = function(theFile) { | |
return theFile.split('.').pop(); | |
}; | |
getFileExtension('myfile.js');//returns 'js' |
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
var stripFQDN = function(theURL) { | |
return theURL.replace(/^.*\/\/[^\/]+/, ''); | |
}; | |
//_stripFQDN('https://gist.github.com/assets/application-f348fb986aecf8d3b65e959e23f6a29f.css'); | |
//returns '/assets/application-f348fb986aecf8d3b65e959e23f6a29f.css' |
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
/* | |
using jQuery AJAX as an example, though we do not leverage jQuery in our Production app. | |
This technique can be used anywhere with injected data/functionality | |
*/ | |
$.ajax({ | |
url: theTemplate.filePath, | |
success: function(data) { | |
/* | |
Take the raw data of the file, insert it into a new function, and execute it. | |
Bypasses need for callbacks, instantly executes it without delay, and does it without using `eval`. |
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
Handlebars.getTemplate = function(name) { | |
if (Handlebars.templates === undefined || Handlebars.templates[name] === undefined) { | |
$.ajax({ | |
url : 'templatesfolder/' + name + '.handlebars', | |
success : function(data) { | |
if (Handlebars.templates === undefined) { | |
Handlebars.templates = {}; | |
} | |
Handlebars.templates[name] = Handlebars.compile(data); | |
}, |
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
var arrErrors = []; | |
window.onerror = function(msg, fileURL, lineNum) { | |
arrErrors.push({ msg: msg, file: fileURL, line: lineNum }); | |
}; | |
setInterval(function() { | |
sendToServer(arrErrors); | |
arrErrors = []; | |
}, 5000); | |
sendToServer(arrErrors) { |
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
/** | |
* SHIM to add `Date.now` functionality if it is not available, based off of EcmaScript 5. | |
* The `Date.now()` function returns a `number` value that is the time value designating the UTC date and time of the occurrence of the call to `now`. | |
* @see {@link http://es5.github.com/#x15.9.4.4} | |
* @global | |
* @method | |
* @name Date.now | |
* @example var dtNow = Date.now(); | |
* @returns {date} Number value that is the time value designating the UTC data dn time of the time of the call to this | |
*/ |
NewerOlder