X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;ds=sidebyside;f=www%2Fjssrc%2Fblerg%2FAPI.js;h=a5aa965100ab75fd91bc344cec2329f4a0fe950f;hb=79a8b4304e691959e39d24fe9438d73bcea1badf;hp=203706a674da60477844ccca4312302ecb89885d;hpb=b1a0c97ba2653976a4b4eb91d989ebf6eafdcc18;p=blerg.git diff --git a/www/jssrc/blerg/API.js b/www/jssrc/blerg/API.js index 203706a..a5aa965 100644 --- a/www/jssrc/blerg/API.js +++ b/www/jssrc/blerg/API.js @@ -32,6 +32,26 @@ enyo.kind({ blerg.API.apiInitialized = true; }, + signup: function(username, password) { + var req = new enyo.Ajax({ + url: baseURL + '/create', + method: 'POST' + }); + req.response(function(inSender, inResponse) { + if (inResponse.status == 'success') { + this.bubble('onSignupSuccess', {username: username}); + } else { + this.bubble('onSignupFailure', {username: username}); + } + }.bind(this)); + req.error(function() { + this.bubble('onSignupFailure', {username: username}); + }.bind(this)); + req.go({ + username: username, + password: password, + }); + }, login: function(username, password) { var req = new enyo.Ajax({ url: baseURL + '/login', @@ -88,6 +108,12 @@ enyo.kind({ entries: inResponse }); }.bind(this)); + req.error(function(inSender, inResponse) { + if (inResponse == 404) + this.bubble('onUserNotFound'); + else + this.bubble('onAPIError', {response: inResponse}); + }.bind(this)); req.go(); }, loadTagRecords: function(type, tag) {