Skip to content

Instantly share code, notes, and snippets.

@ultim8k
Created July 15, 2013 14:33
Show Gist options
  • Save ultim8k/6000413 to your computer and use it in GitHub Desktop.
Save ultim8k/6000413 to your computer and use it in GitHub Desktop.
A front-end app scaffold
/**
* app template
*/
var app = {}
app.settings = {
init_msg : "Thanks Kostas.\nYou are awesome!"
}
app.consolefix = function(){
var self = this
var s = self.settings
if (typeof console == "undefined") {
this.console = { log: function() {} };
}
return false;
}
app.call = function(data, callback){
var self = this
var s = self.settings
if(callback && typeof callback == 'function'){
callback(data)
}else{
console.log(data || 'I find your lack of data disturbing!')
}
}
app.events = function(){
var self = this
var s = self.settings
window.onhashchange = function(){
if(window.location.hash == '#init'){
self.call(s.init_msg)
}
}
}
app.init = function(){
var self = this
var s = self.settings
self.events()
self.call('app initialized')
}
app.init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment