codice:
var CONST_NS = function( ){ 	 	this._ANONYMOUS_ACCESS = "anonymous";	 	 };  var Controller = function( conf ){ 	 	var config = {"allowedAccesses":[CONST_NS._ANONYMOUS_ACCESS]}; 	 	//Contains function name:[params] 	var bootStrapSequence = {"steps":["_checkLogin"]}; 	 	var _construct = function( conf ){ 						 		if( conf["allowedAccesses"] !== "undefined" ){ 		 			config["allowedAccesses"] = conf["allowedAccesses"]; 		 		} 		 		//Launches bootstrap sequence 		for( var i in bootStrapSequence["steps"] ){ 			 			if( !eval( bootStrapSequence["steps"][i] + "( )" ) ){ 				 				return; 				 			} 			 			alert( "Done: Controller->" + bootStrapSequence[i] ); 			 		} 			 	}( conf );	 	 	//Checks if at least one of the allowed accesses is set in session 	var _checkLogin = function( ){ 		 		alert( "checkLogin" ); 		 		var loggedAccesses = AccessManager.checkLogin( ); 		 		for( var i in loggedAccesses ){ 						 			for( var k in config.allowedAccesses ){ 					 				 				if( loggedAccesses[i] == config.allowedAccesses[k]  ){ 					 					return true; 					 				} 				 			} 			 		} 		 		return false; 		 	}; 	 };  var AccessManager = new function( ){ 	 	var loggedAccesses = {"loggedAccesses":[CONST_NS._ANONYMOUS_ACCESS]}; 	 	this.login = function( ){ 				 	}; 	 	this.logout = function( ){ 		 	}; 	 	this.checkLogin = function( ){ 		 		return loggedAccesses; 		 	}; 	 };	  //Document ready $(document).ready( function( ){ 	 	var pageController = new Controller( {"allowedAccesses":[CONST_NS._ANONYMOUS_ACCESS]} ); 	 });