use bootstrap for login and register pages
parent
c556f78562
commit
b5b2454f0b
@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="cp">
|
||||
<head>
|
||||
<title data-localization="main_title">Cryptpad: Log in</title>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<link rel="stylesheet" type="text/css" href="/customize/main.css" />
|
||||
<link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.min.css">
|
||||
<link rel="icon" type="image/png" href="/customize/main-favicon.png" id="favicon"/>
|
||||
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
|
||||
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
|
||||
<script data-main="main" src="/bower_components/requirejs/require.js"></script>
|
||||
<script src="/bower_components/requirejs/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
waitSeconds: 60,
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body class="html">
|
||||
<div id="cryptpadTopBar">
|
||||
<span>
|
||||
<a class="gotoMain" href="/">
|
||||
<img src="/customize/cryptofist_mini.png" class="cryptpad-logo" alt="" /> CryptPad
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<span id="language-selector" class="right dropdown-bar"></span>
|
||||
<span class="right">
|
||||
<a href="/about.html" data-localization="about">About</a>
|
||||
</span>
|
||||
<span class="right">
|
||||
<a href="/privacy.html" data-localization="privacy">Privacy</a>
|
||||
</span>
|
||||
<span class="right">
|
||||
<a href="/terms.html" data-localization="terms">ToS</a>
|
||||
</span>
|
||||
<span class="right">
|
||||
<a href="/contact.html" data-localization="contact">Contact</a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="noscriptContainer">
|
||||
<div class="mainOverlay"></div>
|
||||
<div id="noscript">
|
||||
<noscript>
|
||||
<p>
|
||||
<strong>OOPS</strong> In order to do encryption in your browser, Javascript is really <strong>really</strong> required.
|
||||
</p>
|
||||
<hr>
|
||||
<p>
|
||||
<strong>OUPS</strong> Afin de pouvoir réaliser le chiffrement dans votre navigateur, Javascript est <strong>vraiment</strong> nécessaire.
|
||||
</p>
|
||||
</noscript>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="mainBlock" class="hidden">
|
||||
|
||||
<div id="main">
|
||||
<div class="mainOverlay"></div>
|
||||
<div id="align-container">
|
||||
<div id="main-container">
|
||||
<div id="data" class="hidden">
|
||||
<p class="left" data-localization="main_p1"><!-- Zero Knowledge collaborative realtime editor. Protected from the NSA. --></p>
|
||||
</div>
|
||||
|
||||
<div id="userForm" class="form-group hidden">
|
||||
<input type="text" id="name" name="name" class="form-control" data-localization-placeholder="login_username" autofocus>
|
||||
<input type="password" id="password" name="password" class="form-control" data-localization-placeholder="login_password">
|
||||
<button class="btn btn-primary login first" data-localization="login_login"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -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
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue