Add a spinner when hashing the password and translate homepage

pull/1/head
yflory 8 years ago
parent 3b1bd2f720
commit 3aa03225c9

@ -112,33 +112,43 @@ define([
}); });
$('button.login').click(function (e) { $('button.login').click(function (e) {
loginReady(function () { Cryptpad.addLoadingScreen(Messages.login_hashing);
var uname = $uname.val(); // We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password
var passwd = $passwd.val(); window.setTimeout(function () {
loginReady(function () {
Login.loginOrRegister(uname, passwd, false, function (err, result) { var uname = $uname.val();
if (!err) { var passwd = $passwd.val();
// successful validation and user already exists Login.loginOrRegister(uname, passwd, false, function (err, result) {
// set user hash in localStorage and redirect to drive if (!err) {
localStorage.User_hash = result.userHash; // successful validation and user already exists
document.location.href = '/drive/'; // set user hash in localStorage and redirect to drive
Cryptpad.login(result.userHash, result.userName, function () {
return; document.location.href = '/drive/';
} });
switch (err) { return;
case 'NO_SUCH_USER': }
Cryptpad.alert('Invalid username or password. Try again, or sign up'); // XXX switch (err) {
break; case 'NO_SUCH_USER':
case 'INVAL_USER': Cryptpad.removeLoadingScreen(function () {
Cryptpad.alert('Username required'); // XXX Cryptpad.alert(Messages.login_noSuchUser);
break; });
case 'INVAL_PASS': break;
Cryptpad.alert('Password required'); // XXX case 'INVAL_USER':
break; Cryptpad.removeLoadingScreen(function () {
default: // UNHANDLED ERROR 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);
}
});
}); });
}); }, 0);
}); });
/* End Log in UI */ /* End Log in UI */

@ -282,6 +282,15 @@ define(function () {
out.login_accessDrive = 'Accédez à votre drive'; out.login_accessDrive = 'Accédez à votre drive';
out.login_orNoLogin = 'ou'; out.login_orNoLogin = 'ou';
out.login_noSuchUser = "Nom d'utilisateur ou mot de passe invalide. Veuillez vous inscrire ou réessayer.";
out.login_invalUser = "Nom d'utilisateur requis";
out.login_invalPass = 'Mot de passe requis';
out.login_unhandledError = "Une erreur inattendue s'est produite :(";
out.register_importRecent = "Importer l'historique (Recommendé)";
out.register_acceptTerms = "J'accepte <a href='/terms.html'>les conditions d'utilisation</a>";
out.register_rememberPassword = "Je vais me souvenir de mes identifiants";
// index.html // index.html
//out.main_p1 = 'CryptPad est l\'éditeur collaboratif en temps réel <strong>zero knowledge</strong>. Le chiffrement est effectué depuis votre navigateur, ce qui protège les données contre le serveur, le cloud, et la NSA. La clé de chiffrement est stockée dans l\'<a href="https://fr.wikipedia.org/wiki/Identificateur_de_fragment">identifieur de fragment</a> de l\'URL qui n\'est jamais envoyée au serveur mais est accessible depuis javascript, de sorte qu\'en partageant l\'URL, vous donnez l\'accès au pad à ceux qui souhaitent participer.'; //out.main_p1 = 'CryptPad est l\'éditeur collaboratif en temps réel <strong>zero knowledge</strong>. Le chiffrement est effectué depuis votre navigateur, ce qui protège les données contre le serveur, le cloud, et la NSA. La clé de chiffrement est stockée dans l\'<a href="https://fr.wikipedia.org/wiki/Identificateur_de_fragment">identifieur de fragment</a> de l\'URL qui n\'est jamais envoyée au serveur mais est accessible depuis javascript, de sorte qu\'en partageant l\'URL, vous donnez l\'accès au pad à ceux qui souhaitent participer.';

@ -283,8 +283,13 @@ define(function () {
out.login_accessDrive = 'Access your drive'; out.login_accessDrive = 'Access your drive';
out.login_orNoLogin = 'or'; out.login_orNoLogin = 'or';
out.login_noSuchUser = 'Invalid username or password. Try again, or sign up';
out.login_invalUser = 'Username required';
out.login_invalPass = 'Password required';
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</a>"; out.register_acceptTerms = "I accept <a href='/terms.html'>the terms of use</a>";
out.register_rememberPassword = "I will remember my login name and password"; out.register_rememberPassword = "I will remember my login name and password";
// index.html // index.html

@ -734,7 +734,7 @@ define([
}; };
var LOADING = 'loading'; var LOADING = 'loading';
common.addLoadingScreen = function () { common.addLoadingScreen = function (loadingText) {
if ($('#' + LOADING).length) { if ($('#' + LOADING).length) {
$('#' + LOADING).show(); $('#' + LOADING).show();
return; return;
@ -744,7 +744,7 @@ define([
$container.append('<img class="cryptofist" src="/customize/cryptofist_small.png" />'); $container.append('<img class="cryptofist" src="/customize/cryptofist_small.png" />');
var $spinner = $('<div>', {'class': 'spinnerContainer'}); var $spinner = $('<div>', {'class': 'spinnerContainer'});
var loadingSpinner = common.spinner($spinner).show(); var loadingSpinner = common.spinner($spinner).show();
var $text = $('<p>').text(Messages.loading); var $text = $('<p>').text(loadingText || Messages.loading);
$container.append($spinner).append($text); $container.append($spinner).append($text);
$loading.append($container); $loading.append($container);
$('body').append($loading); $('body').append($loading);

@ -12,6 +12,7 @@ define([
$(function () { $(function () {
var $main = $('#mainBlock'); var $main = $('#mainBlock');
var Messages = Cryptpad.Messages;
// Language selector // Language selector
var $sel = $('#language-selector'); var $sel = $('#language-selector');
@ -63,33 +64,43 @@ define([
}); });
$('button.login').click(function (e) { $('button.login').click(function (e) {
loginReady(function () { Cryptpad.addLoadingScreen(Messages.login_hashing);
var uname = $uname.val(); // We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password
var passwd = $passwd.val(); window.setTimeout(function () {
loginReady(function () {
Login.loginOrRegister(uname, passwd, false, function (err, result) { var uname = $uname.val();
if (!err) { var passwd = $passwd.val();
// successful validation and user already exists Login.loginOrRegister(uname, passwd, false, function (err, result) {
// set user hash in localStorage and redirect to drive if (!err) {
localStorage.User_hash = result.userHash; // successful validation and user already exists
document.location.href = '/drive/'; // set user hash in localStorage and redirect to drive
Cryptpad.login(result.userHash, result.userName, function () {
return; document.location.href = '/drive/';
} });
switch (err) { return;
case 'NO_SUCH_USER': }
Cryptpad.alert('Invalid username or password. Try again, or sign up'); // XXX switch (err) {
break; case 'NO_SUCH_USER':
case 'INVAL_USER': Cryptpad.removeLoadingScreen(function () {
Cryptpad.alert('Username required'); // XXX Cryptpad.alert(Messages.login_noSuchUser);
break; });
case 'INVAL_PASS': break;
Cryptpad.alert('Password required'); // XXX case 'INVAL_USER':
break; Cryptpad.removeLoadingScreen(function () {
default: // UNHANDLED ERROR 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);
}
});
}); });
}); }, 0);
}); });
}); });
}); });

Loading…
Cancel
Save