diff options
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/Botleagues.js | 22 | ||||
-rw-r--r-- | src/js/BotleaguesApi.js | 19 | ||||
-rw-r--r-- | src/js/BotleaguesCallback.js | 5 | ||||
-rw-r--r-- | src/js/forms.js | 11 |
4 files changed, 38 insertions, 19 deletions
diff --git a/src/js/Botleagues.js b/src/js/Botleagues.js new file mode 100644 index 0000000..fd8ed21 --- /dev/null +++ b/src/js/Botleagues.js @@ -0,0 +1,22 @@ +function Botleagues(){} + +Botleagues.url = 'https://api.local.botleagues.camilstaps.nl'; + +Botleagues.request = function(user_options, callback) { + var options = { + endpoint: null, + method: 'GET', + dataType: 'json', + done: function(data) { + callback(data); + } + }; + for (var name in user_options) { + options[name] = user_options[name]; + } + + var url = Botleagues.url + '/' + options['endpoint']; + delete options['endpoint']; + + jQuery.ajax(url, options); +};
\ No newline at end of file diff --git a/src/js/BotleaguesApi.js b/src/js/BotleaguesApi.js deleted file mode 100644 index c37adab..0000000 --- a/src/js/BotleaguesApi.js +++ /dev/null @@ -1,19 +0,0 @@ -function BotleaguesApi(){} - -BotleaguesApi.url = 'https://api.local.botleagues.camilstaps.nl'; - -BotleaguesApi.request = function(user_options) { - var options = { - endpoint: null, - method: 'GET', - dataType: 'jsonp' - }; - for (var name in user_options) { - options[name] = user_options[name]; - } - - var url = BotleaguesApi.url + options['endpoint']; - delete options['endpoint']; - - jQuery.ajax(url, options); -}
\ No newline at end of file diff --git a/src/js/BotleaguesCallback.js b/src/js/BotleaguesCallback.js new file mode 100644 index 0000000..4c05262 --- /dev/null +++ b/src/js/BotleaguesCallback.js @@ -0,0 +1,5 @@ +function BotleaguesCallback(){} + +BotleaguesCallback.register = function(data) { + console.log(data); +};
\ No newline at end of file diff --git a/src/js/forms.js b/src/js/forms.js new file mode 100644 index 0000000..5ad9959 --- /dev/null +++ b/src/js/forms.js @@ -0,0 +1,11 @@ +$('form.form-register').submit(function(){ + Botleagues.request({ + endpoint: 'user', + method: 'POST', + data: { + email: $(this).find('input[name="email"]').val(), + password: $(this).find('input[name="password"]').val() + } + }, BotleaguesCallback.register); + event.preventDefault(); +});
\ No newline at end of file |