From 3c03af39297f47af09def0cacba5190b0081a718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Pu=C5=A1nik?= Date: Mon, 12 Oct 2015 11:17:48 +0200 Subject: signUp: added name and email --- index.html | 20 ++++++++++++------ js/codeq/comms.js | 4 ++-- js/codeq/profile.js | 60 +++++++++++++++++++++++++++-------------------------- 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/index.html b/index.html index 243c553..15148ba 100644 --- a/index.html +++ b/index.html @@ -351,24 +351,32 @@

Sign up

@@ -409,7 +417,7 @@

Arnes AAI

diff --git a/js/codeq/comms.js b/js/codeq/comms.js index 54f5d24..ab168ff 100644 --- a/js/codeq/comms.js +++ b/js/codeq/comms.js @@ -367,10 +367,10 @@ return this.send({'action': 'logout'}); }, - 'signup': function (username, password) { + 'signup': function (username, name, email, password) { var myself = this, performSignUp = function () { - return myself.send({'action': 'signup', 'username': username, 'password': password}); + return myself.send({'action': 'signup', 'username': username, 'name': name, 'email': email, 'password': password}); }; if (socket) return performSignUp(); diff --git a/js/codeq/profile.js b/js/codeq/profile.js index be0bb1e..687a3c7 100644 --- a/js/codeq/profile.js +++ b/js/codeq/profile.js @@ -4,37 +4,39 @@ (function(){ - codeq.profile = { - - 'signup': function () { - var jqUsername = $("#modalSignUpUsername"), - jqPassword = $("#modalSignUpPassword"), - jqVerify = $("#modalSignUpVerify"); + $('#formSignUp').submit(function(event) { + console.log($(this).serialize()); + var jqUsername = $("#modalSignUpUsername"), + jqName = $("#modalSignUpName"), + jqEmail = $("#modalSignUpEmail"), + 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(); - } + if (jqPassword.val() != jqVerify.val()) { + alert('Passwords do not match.'); + } + else { + codeq.comms.signup(jqUsername.val(), jqName.val(), jqEmail.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(''); + jqName.val(''); + jqEmail.val(''); + jqPassword.val(''); + jqVerify.val(''); + }) + .done(); + } + event.preventDefault(); // Prevent the form from submitting via the browser. + }); - }, + codeq.profile = { 'changePassword': function () { var jqNew = $("#modalChangePasswordNew"), -- cgit v1.2.1