Add spinner and translate the register page

pull/1/head
yflory 8 years ago
parent 562e5b8c70
commit 2807ad9dc3

@ -290,6 +290,9 @@ define(function () {
out.register_importRecent = "Importer l'historique (Recommendé)"; out.register_importRecent = "Importer l'historique (Recommendé)";
out.register_acceptTerms = "J'accepte <a href='/terms.html'>les conditions d'utilisation</a>"; out.register_acceptTerms = "J'accepte <a href='/terms.html'>les conditions d'utilisation</a>";
out.register_rememberPassword = "Je vais me souvenir de mes identifiants"; out.register_rememberPassword = "Je vais me souvenir de mes identifiants";
out.register_passwordsDontMatch = "Les mots de passe doivent être identiques!";
out.register_mustAcceptTerms = "Vous devez accepter les conditions d'utilisation.";
out.register_mustRememberPass = "Nous ne pouvons pas réinitialiser votre mot de passe si vous l'oubliez. C'est important que vous vous en souveniez!";
// index.html // index.html

@ -289,8 +289,11 @@ define(function () {
out.login_unhandledError = 'An unexpected error occured :('; out.login_unhandledError = 'An unexpected error occured :(';
out.register_importRecent = "Import pad history (Recommended)"; out.register_importRecent = "Import pad history (Recommended)";
out.register_acceptTerms = "I accept <a href='/terms.html'>the terms of use</a>"; out.register_acceptTerms = "I accept <a href='/terms.html'>the terms of service</a>";
out.register_rememberPassword = "I will remember my login name and password"; out.register_rememberPassword = "I will remember my login name and password";
out.register_passwordsDontMatch = "Passwords do not match!";
out.register_mustAcceptTerms = "You must accept the terms of service.";
out.register_mustRememberPass = "We cannot reset your password if you forget it. It's very important that you remember it!";
// index.html // index.html

@ -10,6 +10,8 @@ define([
Login: Login, Login: Login,
}; };
var Messages = Cryptpad.Messages;
$(function () { $(function () {
var $main = $('#mainBlock'); var $main = $('#mainBlock');
@ -71,20 +73,40 @@ define([
/* basic validation */ /* basic validation */
if (passwd !== confirmPassword) { // do their passwords match? if (passwd !== confirmPassword) { // do their passwords match?
return void Cryptpad.alert('passwords do not match!'); // XXX return void Cryptpad.alert(Messages.register_passwordsDontMatch);
} }
if (!doesAccept) { // do they accept the terms of service? if (!doesAccept) { // do they accept the terms of service?
return void Cryptpad.alert('you must accept the terms of service'); // XXX return void Cryptpad.alert(Messages.register_mustAcceptTerms);
} }
if (!doesPromise) { // do they promise to remember their password? if (!doesPromise) { // do they promise to remember their password?
return void Cryptpad.alert("We cannot reset your password if you forget it. It's very important that you remember it!"); // XXX return void Cryptpad.alert(Messages.register_mustRememberPass);
} }
Cryptpad.addLoadingScreen(Messages.login_hashing);
Login.loginOrRegister(uname, passwd, true, function (err, result) { Login.loginOrRegister(uname, passwd, true, function (err, result) {
if (err) { return void Cryptpad.alert(err); } if (err) {
console.log(result); switch (err) {
case 'NO_SUCH_USER':
Cryptpad.removeLoadingScreen(function () {
Cryptpad.alert(Messages.login_noSuchUser);
});
break;
case 'INVAL_USER':
Cryptpad.removeLoadingScreen(function () {
Cryptpad.alert(Messages.login_invalUser);
});
break;
case 'INVAL_PASS':
Cryptpad.removeLoadingScreen(function () {
Cryptpad.alert(Messages.login_invalPass);
});
break;
default: // UNHANDLED ERROR
Cryptpad.errorLoadingScreen(Messages.login_unhandledError);
}
}
var proxy = result.proxy; var proxy = result.proxy;
localStorage.User_hash = result.userHash; localStorage.User_hash = result.userHash;
@ -97,7 +119,9 @@ define([
proxy.login_name = uname; proxy.login_name = uname;
Cryptpad.whenRealtimeSyncs(result.realtime, function () { Cryptpad.whenRealtimeSyncs(result.realtime, function () {
document.location.href = '/drive/'; Cryptpad.login(result.userHash, result.userName, function () {
document.location.href = '/drive/';
});
}); });
}); });
}); });

Loading…
Cancel
Save