Usernames, logging in, validations, etc.

This commit is contained in:
2020-12-29 00:06:44 -08:00
parent bddf7ff040
commit 2a288e2507
9 changed files with 136 additions and 17 deletions
+3
View File
@@ -9,6 +9,9 @@ border-bottom: 2px solid gainsboro;
}
#top-bar-login-box{display:none; width: 100px;margin:0px;border:1px solid gray !important; background-image:"" !important}
#top-bar-username{width:200px;font-size:15px}
.uk-subnav-pill > * > :first-child{
padding: 0px 50px !important;
}
+51
View File
@@ -4,6 +4,57 @@ window.jQuery = $;
window.$ = $;
window.UIkit = UIkit;
window.show_login_box = () => {
$("#top-bar-username a").hide();
$("#top-bar-login-box").show().focus();
}
window.hide_login_box = () => {
$("#top-bar-username a").show();
$("#top-bar-login-box").hide()
}
$('#top-bar-login-box').on('keyup keypress', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode === 13) {
e.preventDefault();
return false;
}
});
$("#top-bar-login-box").keyup(function(e) {
if (e.keyCode == "13") {
login();
}
});
window.login = () => {
var CSRF_TOKEN = $("input[name=_csrf_token]").val();
var username = $("#top-bar-login-box").val();
$.ajax({
url: "/api/join",
method: 'POST',
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRF-Token", CSRF_TOKEN);
},
data: {
username: username
}
}).done(function(response) {
console.log(response);
UIkit.notification(response['data']);
hide_login_box();
$("#top-bar-username a").text(response['username']);
});
}
window.deleteCard = (id) => {
var CSRF_TOKEN = $("input[name=_csrf_token]").val();
$.ajax({