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
| /** | |
| * @file Functionality for checking and manipulating classes on DOM Elements (i.e., checking if an element has a class, | |
| * removing a class from an element, and adding a class to an element. Updated to use better naming conventions, | |
| * use array joins instead if string concats (operation speed), and boolean returns to more easily be able to tell when | |
| * functions performed successfully within an app | |
| * @author Josh Rhoades <http://joshuarhoades.com/> | |
| * @added 04/25/13 | |
| * @version 1.0.0 | |
| * @see {@link https://gist.github.com/jelmerdemaat/4107273|Original before fork} | |
| * @see {@link http://www.avoid.org/?p=78} |
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
| /** | |
| * This function will qet all queryString elements available by name (key), if no matches are found, it returns `FALSE`. Revised 3/18/13 for performance, | |
| * drastically faster operation now, and using dependency injection for unit testing abilities. Typically this should be stored in a sub-namespace like `.utils` | |
| * @version 0.0.3 | |
| * @method | |
| * @name getQueryString | |
| * @param {string} key - queryString parameter to match on | |
| * @param {object} theContext The object to fetch against, allows for dependency injection/testability. If not passed in, function will default to use | |
| * the global `window` object | |
| * @returns {boolean} Returns `FALSE` if no match |
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 | |
| */ |
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
| 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
| /* | |
| 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
| 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
| 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
| <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 _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 | |
| }; | |
| }; |
OlderNewer