Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Created February 1, 2011 22:20
Show Gist options
  • Save wilmoore/806837 to your computer and use it in GitHub Desktop.
Save wilmoore/806837 to your computer and use it in GitHub Desktop.
JavaScript Snippets for new projects
// Slightly smaller version of Paul's lightweight log wrapper -- Thanks Paul Irish
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog
window.log=function(){log.history=log.history||[];log.history.push(arguments);this.console&&console.log(Array.prototype.slice.call(arguments))};
/**
* Copyright (c) ####-#### NAME - All rights reserved.
*
* @fileOverview
* @author [email protected]
*/
var ns = ns || {};
ns.core = ns.core || {};
// usage: log('message', this, args);
window.log=function(){log.history=log.history||[];log.history.push(arguments);this.console&&console.log(Array.prototype.slice.call(arguments))};
/**
* @name App
* @memberof core
* @function
* @return void
*/
ns.core.App = (function($){
// @private:
var debug = false,
_debug = function(message) {log(message);},
/**
* Setup ajax
*
* @function
* @memberof ns.core.App
* @name _initAjax
* @return void
*/
_initAjax = function() {
// initialize global ajax functionality
$.ajaxSetup({
async: true,
cache: false,
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
global: true,
ifModified: false,
processData: true,
timeout: 5000,
type: 'POST'
});
};
// @public:
return {
/**
* @name init
* @memberof ns.core.App
* @function
* @return void
*/
init: function() {
$(function(){
// initialize global ajax functionality
_initAjax();
});
// support the chain...right!
return this;
},
/**
* Alias the private _debug method as debug
*
* @name debug
* @memberof ets.core.App
* @function
* @return void
*
*/
debug: _debug
};
})(jQuery).init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment