aboutsummaryrefslogtreecommitdiff
path: root/src/js/Botleagues.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/Botleagues.coffee')
-rw-r--r--src/js/Botleagues.coffee22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/js/Botleagues.coffee b/src/js/Botleagues.coffee
index 6be7a0e..f090e4b 100644
--- a/src/js/Botleagues.coffee
+++ b/src/js/Botleagues.coffee
@@ -32,17 +32,31 @@ $.cookie.json = true
options =
method: 'GET'
dataType: 'json'
- complete: (data) ->
- callback data.responseJSON
+ statusCode:
+ 200: (data, status, jqxhr) ->
+ if status == 'parsererror'
+ callback {}
+ else
+ callback data
+ 201: (jqxhr) ->
+ new_options = options
+ new_options.method = 'GET'
+ jQuery.ajax jqxhr.getResponseHeader('Location'), new_options
+ 500: (jqxhr) ->
+ console.log 500
+ console.log jqxhr
+ callback jqxhr.responseJSON
url = Botleagues.url + '/' + user_options.endpoint
delete user_options.callback
delete user_options.endpoint
+ new_options = options
+
for key, option of user_options
- options[key] = option
+ new_options[key] = option
- jQuery.ajax url, options
+ jQuery.ajax url, new_options
return