diff --git a/customize.dist/main.css b/customize.dist/main.css index 76346f5ee..9677d8495 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -845,8 +845,8 @@ html.cp, .cp #main_other #userForm { float: right; display: inline-block; - width: 350px; - max-width: 35%; + width: 400px; + max-width: 40%; padding: 10px; box-sizing: border-box; font-family: lato, Helvetica, sans-serif; diff --git a/customize.dist/src/less/cryptpad.less b/customize.dist/src/less/cryptpad.less index da70070b3..14afb67d5 100644 --- a/customize.dist/src/less/cryptpad.less +++ b/customize.dist/src/less/cryptpad.less @@ -389,8 +389,8 @@ body.html { #userForm { float: right; display: inline-block; - width: 350px; - max-width: 35%; + width: 400px; + max-width: 40%; padding: 10px; box-sizing: border-box; font-family: lato, Helvetica, sans-serif; diff --git a/www/login/index.html b/www/login/index.html new file mode 100644 index 000000000..2a54f2a05 --- /dev/null +++ b/www/login/index.html @@ -0,0 +1,81 @@ + + + + Cryptpad: Log in + + + + + + + + + + + + + +
+ + + CryptPad + + + + + + About + + + Privacy + + + ToS + + + Contact + +
+ +
+
+
+ +
+
+ + + + + + diff --git a/www/login/main.js b/www/login/main.js new file mode 100644 index 000000000..26f673cf2 --- /dev/null +++ b/www/login/main.js @@ -0,0 +1,96 @@ +define([ + '/common/cryptpad-common.js', + '/customize/languageSelector.js', + '/common/login.js', + '/bower_components/jquery/dist/jquery.min.js', +], function (Cryptpad, LS, Login) { + var $ = window.$; + + var APP = window.APP = { + Cryptpad: Cryptpad, + }; + + $(function () { + var $main = $('#mainBlock'); + + // Language selector + var $sel = $('#language-selector'); + Cryptpad.createLanguageSelector(undefined, $sel); + $sel.find('button').addClass('btn').addClass('btn-secondary'); + $sel.show(); + + $(window).click(function () { + $('.cryptpad-dropdown').hide(); + }); + + // main block is hidden in case javascript is disabled + $main.removeClass('hidden'); + + // Make sure we don't display non-translated content (empty button) + $main.find('#data').removeClass('hidden'); + + if (Cryptpad.isLoggedIn()) { + // already logged in, redirect to drive + document.location.href = '/drive/'; + return; + } else { + $main.find('#userForm').removeClass('hidden'); + } + + /* Log in UI */ + // deferred execution to avoid unnecessary asset loading + var loginReady = function (cb) { + if (Login) { + if (typeof(cb) === 'function') { cb(); } + return; + } + require([ + ], function (_Login) { + Login = Login || _Login; + if (typeof(cb) === 'function') { cb(); } + }); + }; + loginReady(); + + var $uname = $('#name'); + + var $passwd = $('#password') + // background loading of login assets + // enter key while on password field clicks signup + .on('keyup', function (e) { + if (e.which !== 13) { return; } // enter + $('button.login').click(); + }); + + $('button.login').click(function (e) { + loginReady(function () { + var uname = $uname.val(); + var passwd = $passwd.val(); + + Login.loginOrRegister(uname, passwd, false, function (err, result) { + if (!err) { + // successful validation and user already exists + // set user hash in localStorage and redirect to drive + localStorage.User_hash = result.userHash; + document.location.href = '/drive/'; + + return; + } + switch (err) { + case 'NO_SUCH_USER': + Cryptpad.alert('Invalid username or password. Try again, or sign up'); // XXX + break; + case 'INVAL_USER': + Cryptpad.alert('Username required'); // XXX + break; + case 'INVAL_PASS': + Cryptpad.alert('Password required'); // XXX + break; + default: // UNHANDLED ERROR + } + }); + }); + }); + }); +}); + diff --git a/www/register/index.html b/www/register/index.html index 0976f9360..e53ed9cf3 100644 --- a/www/register/index.html +++ b/www/register/index.html @@ -6,62 +6,80 @@ Cryptpad: login - + - + +
+ + + CryptPad + + -
-
- -
-
- - -
-
-
- - + + + About + + + Privacy + + + ToS + + + Contact +
+
+
+
+ +
+
+ + + + + + diff --git a/www/register/main.js b/www/register/main.js index 703e3c99e..3ea0bf0ab 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -10,6 +10,34 @@ define([ Login: Login, }; + $(function () { + var $main = $('#mainBlock'); + + // Language selector + var $sel = $('#language-selector'); + Cryptpad.createLanguageSelector(undefined, $sel); + $sel.find('button').addClass('btn').addClass('btn-secondary'); + $sel.show(); + + $(window).click(function () { + $('.cryptpad-dropdown').hide(); + }); + + // main block is hidden in case javascript is disabled + $main.removeClass('hidden'); + + // Make sure we don't display non-translated content (empty button) + $main.find('#data').removeClass('hidden'); + + if (Cryptpad.isLoggedIn()) { + // already logged in, redirect to drive + document.location.href = '/drive/'; + return; + } else { + $main.find('#userForm').removeClass('hidden'); + } + }); + // text and password input fields var $uname = $('#username'); var $passwd = $('#password');