diff options
Diffstat (limited to 'js/codeq/profile.js')
-rw-r--r-- | js/codeq/profile.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/js/codeq/profile.js b/js/codeq/profile.js index 5dcda05..be0bb1e 100644 --- a/js/codeq/profile.js +++ b/js/codeq/profile.js @@ -3,6 +3,62 @@ */
(function(){
+
+ codeq.profile = {
+
+ 'signup': function () {
+ var jqUsername = $("#modalSignUpUsername"),
+ jqPassword = $("#modalSignUpPassword"),
+ jqVerify = $("#modalSignUpVerify");
+
+ if (jqUsername.val() == "" || jqPassword.val() == "" || jqVerify.val() == "") {
+ alert('Some fields are empty.');
+ }
+ else if (jqPassword.val() != jqVerify.val()) {
+ alert('Passwords do not match.');
+ }
+ else {
+ codeq.comms.signup(jqUsername.val(), jqPassword.val())
+ .then(function (data) {
+ //back to login
+ $('#modalSignUp').modal('hide');
+ alert('Welcome '+ jqUsername.val() +'. Thanks for signing up.');
+ $('#modalLogIn').modal('show');
+ //assume user wants to sign-in with signed username
+ $("#username").val(jqUsername.val());
+ //clear
+ jqUsername.val('');
+ jqPassword.val('');
+ jqVerify.val('');
+ })
+ .done();
+ }
+
+ },
+
+ 'changePassword': function () {
+ var jqNew = $("#modalChangePasswordNew"),
+ jqVerify = $("#modalChangePasswordVerify");
+
+ if (jqNew.val() == "" || jqVerify.val() == "") {
+ alert('Some fields are empty.');
+ }
+ else if (jqNew.val() != jqVerify.val()) {
+ alert('Passwords do not match.');
+ }
+ else {
+ codeq.comms.changePassword(jqNew.val())
+ .then(function (data) {
+ $('#modalChangePassword').modal('hide');
+ jqNew.val('');
+ jqVerify.val('');
+ alert('Password changed.');
+ })
+ .done();
+ }
+ }
+ };
+
codeq.globalStateMachine.register('profile',{
'enter': function(){
|