diff --git a/couchpotato/static/scripts/api.js b/couchpotato/static/scripts/api.js new file mode 100644 index 0000000..f39ec6f --- /dev/null +++ b/couchpotato/static/scripts/api.js @@ -0,0 +1,29 @@ +var ApiClass = new Class({ + + setup: function(options){ + var self = this + + self.options = options; + }, + + request: function(type, options){ + var self = this; + + var r_type = self.options.is_remote ? 'JSONP' : 'JSON'; + return new Request[r_type](Object.merge({ + 'callbackKey': 'json_callback', + 'method': 'get', + 'url': self.createUrl(type), + }, options)).send() + }, + + createUrl: function(action, params){ + return this.options.url + (action || 'default') + '/' + (params ? '?'+Object.toQueryString(params) : '') + }, + + getOption: function(name){ + return this.options[name] + } + +}); +window.Api = new ApiClass() \ No newline at end of file diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index c9ccf37..8899d48 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -117,37 +117,6 @@ var CouchPotato = new Class({ }); window.App = new CouchPotato(); -var ApiClass = new Class({ - - setup: function(options){ - var self = this - - self.options = options; - }, - - request: function(type, options){ - var self = this; - - var r_type = self.options.is_remote ? 'JSONP' : 'JSON'; - return new Request[r_type](Object.merge({ - 'callbackKey': 'json_callback', - 'method': 'get', - 'url': self.createUrl(type), - }, options)).send() - }, - - createUrl: function(action, params){ - return this.options.url + (action || 'default') + '/' + (params ? '?'+Object.toQueryString(params) : '') - }, - - getOption: function(name){ - return this.options[name] - } - -}); -window.Api = new ApiClass() - - var Route = new Class({ defaults: {},