mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-29 20:48:01 +01:00
Added 'Enter' keydown listener to login page
Affects issues: - Close #1557
This commit is contained in:
parent
579d99bc6c
commit
20f7007615
@ -24,6 +24,44 @@
|
|||||||
|
|
||||||
<body class="bg-plan bg-gradient">
|
<body class="bg-plan bg-gradient">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function login() {
|
||||||
|
msg.addClass('hidden');
|
||||||
|
const user = $('#inputUser').val();
|
||||||
|
if (!user || user.length < 1) {
|
||||||
|
return displayError('You need to specify a Username');
|
||||||
|
}
|
||||||
|
if (user.length > 50) {
|
||||||
|
return displayError('Username can be up to 50 characters, yours is ' + user.length);
|
||||||
|
}
|
||||||
|
const password = $('#inputPassword').val();
|
||||||
|
if (!password || password.length < 1) {
|
||||||
|
return displayError('You need to specify a Password');
|
||||||
|
}
|
||||||
|
jsonRequest(`./auth/login?user=${encodeURIComponent(user)}&password=${encodeURIComponent(password)}`, (json, error) => {
|
||||||
|
if (error) {
|
||||||
|
if (error.includes("HTTP 403")) {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
$('#inputPassword').val("");
|
||||||
|
return displayError('Login failed: ' + error);
|
||||||
|
}
|
||||||
|
if (json && json.success) {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const cameFrom = urlParams.get('from');
|
||||||
|
window.location.href = cameFrom ? cameFrom : './';
|
||||||
|
} else {
|
||||||
|
return displayError('Login failed: ' + json.error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('keydown', (event) => {
|
||||||
|
console.log(event.key);
|
||||||
|
if (event.key === 'Enter') login();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<!-- Outer Row -->
|
<!-- Outer Row -->
|
||||||
@ -52,9 +90,9 @@
|
|||||||
id="inputPassword" placeholder="Password"
|
id="inputPassword" placeholder="Password"
|
||||||
type="password">
|
type="password">
|
||||||
</div>
|
</div>
|
||||||
<a class="btn bg-plan btn-user btn-block" href="#" id="login-button">
|
<button class="btn bg-plan btn-user btn-block" href="#" id="login-button">
|
||||||
Login
|
Login
|
||||||
</a>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@ -181,6 +219,10 @@
|
|||||||
<script src="js/logonsine.js"></script>
|
<script src="js/logonsine.js"></script>
|
||||||
<script id="mainScript">
|
<script id="mainScript">
|
||||||
drawSine("decoration");
|
drawSine("decoration");
|
||||||
|
document.getElementById('login-button').addEventListener('click', event => {
|
||||||
|
event.preventDefault();
|
||||||
|
login();
|
||||||
|
});
|
||||||
|
|
||||||
const msg = $(`#fail-msg`);
|
const msg = $(`#fail-msg`);
|
||||||
|
|
||||||
@ -190,36 +232,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#forgot-button').click(() => $('#forgotModal').modal());
|
$('#forgot-button').click(() => $('#forgotModal').modal());
|
||||||
$('#login-button').click(() => {
|
|
||||||
msg.addClass('hidden');
|
|
||||||
const user = $('#inputUser').val();
|
|
||||||
if (!user || user.length < 1) {
|
|
||||||
return displayError('You need to specify a Username');
|
|
||||||
}
|
|
||||||
if (user.length > 50) {
|
|
||||||
return displayError('Username can be up to 50 characters, yours is ' + user.length);
|
|
||||||
}
|
|
||||||
const password = $('#inputPassword').val();
|
|
||||||
if (!password || password.length < 1) {
|
|
||||||
return displayError('You need to specify a Password');
|
|
||||||
}
|
|
||||||
jsonRequest(`./auth/login?user=${encodeURIComponent(user)}&password=${encodeURIComponent(password)}`, (json, error) => {
|
|
||||||
if (error) {
|
|
||||||
if (error.includes("HTTP 403")) {
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
$('#inputPassword').val("");
|
|
||||||
return displayError('Login failed: ' + error);
|
|
||||||
}
|
|
||||||
if (json && json.success) {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const cameFrom = urlParams.get('from');
|
|
||||||
window.location.href = cameFrom ? cameFrom : './';
|
|
||||||
} else {
|
|
||||||
return displayError('Login failed: ' + json.error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user