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, 'collection_browser': 0, 'collection_editables': 0, 'collection_editor': 0 }, initialize : function (opts) { if(opts) Object.extend(this.options, opts); }, fetch_control : function (name, args) { if(this._controls[name] == 0) { var params = "name=" + name; if(args) { params += '&' + args; } 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); delete this._controls[name]; this._controls[name] = 0; }, _register_control : function(request) { var response; var control = Class.create(); var local_opts = { uri: this.options.api_url}; eval('response = ' + request.responseText + ';'); if(response) { if(response.meta.html) { response.insertion(); } control.prototype = response.control; if(response.opts) { Object.extend(local_opts, response.opts); } this._controls[response.meta.control_name] = new control(local_opts); } }, init_control_list : function(controls) { Object.extend(this._controls, controls); }};