rendered paste bodyvar Controls = Class.create();Controls.prototype = { options : { url : 'actions/controls.php', api_url: 'actions/admin.php' }, _controls : { 'login' : 0, 'user' : 0, 'collections' : 0, 'marker' : 0, 'logout' : 0 }, initialize : function (opts) { if(opts) Object.extend(this.options, opts); }, fetch_control : function(name) { if(this._controls[name] == 0) { var params = "name=" + name; var opts = {method: 'get', parameters: params, onSuccess: this._register_control.bind(this)}; new Ajax.Request(this.options.url, opts); } }, release_control : function(name) { if(this._controls[name].unload) this._controls[name].unload(this); this._controls[name] = 0; }, _register_control : function(request) { var response; var control = Class.create(); eval('response = ' + request.responseText + ';'); if(response) { if(response.meta.html) { response.insertion(); } control.prototype = response.control; this._controls[response.meta.control_name] = new control({uri: this.options.api_url}); } }, init_control_list : function(controls) { Object.extend(this._controls, controls); }};