Current Path : /data/web/virtuals/51568/virtual/www/menu/ |
Current File : /data/web/virtuals/51568/virtual/www/menu/menu-login.js |
$("#menu-login").keyup(function (event) { if (event.keyCode == 13) { $("#logLogin").click(); } }); $("#menu-logout").keyup(function (event) { if (event.keyCode == 13) { $("#logLogout").click(); } }); $("#pass-change").keyup(function (event) { if (event.keyCode == 13) { $("#passChange").click(); } }); $("#passVisible").on("click", function () { let stav = $("#passVisible").attr("pass-visible"); if (stav == "0") { $("#passVisible").attr("pass-visible", "1").html(`<i class="far fa-eye-slash"></i>`);; $("#password").attr("type", "text"); } else { $("#passVisible").attr("pass-visible", "0").html(`<i class="far fa-eye"></i>`);; $("#password").attr("type", "password"); } }); $("#oldPassVisible").on("click", function () { $("#errChangePass").addClass("d-none"); let stav = $("#oldPassVisible").attr("oldpass-visible"); if (stav == "0") { $("#oldPassVisible").attr("oldpass-visible", "1").html(`<i class="far fa-eye-slash"></i>`); $("#oldPassword").attr("type", "text"); } else { $("#oldPassVisible").attr("oldpass-visible", "0").html(`<i class="far fa-eye"></i>`); $("#oldPassword").attr("type", "password"); } }); $("#newPassVisible").on("click", function () { $("#errChangePass").addClass("d-none"); let stav = $("#newPassVisible").attr("newpass-visible"); if (stav == "0") { $("#newPassVisible").attr("newpass-visible", "1").html(`<i class="far fa-eye-slash"></i>`); $("#newPassword").attr("type", "text"); $("#groupConfirmPassword").toggleClass("d-none"); } else { $("#newPassVisible").attr("newpass-visible", "0").html(`<i class="far fa-eye"></i>`); $("#newPassword").attr("type", "password"); $("#groupConfirmPassword").toggleClass("d-none"); } }); function logLogout() { $.ajax({ url: "menu/logout.php", type: 'POST', dataType: 'HTML', data: {}, success: function (result) { $('#dialogy').html(""); window.location = "index.php"; } }); } function logLogin() { let user = $("#user").val(), rememberme = $('#userrememberme:checked').val(), password = $("#password").val(); user = (user.length > 0) ? user.trim() : user; password = (password.length > 0) ? password.trim() : password; rememberme = (rememberme === undefined) ? '0' : '1'; if (password.length * user.length === 0) { $("#errLogin").html('Jméno a heslo musíš zadat.'); $("#errLogin").removeClass("d-none"); } else { $.ajax({ url: "menu/login.php", type: 'POST', dataType: 'HTML', data: { 'user': user, 'password': password, 'rememberme': rememberme, }, success: function (result) { if (result.length>0) { let navrat = result.split("#"); succ = navrat[1].trim(); if (succ == 'true') { $('#menu-login').modal('hide'); $('#dialogy').html(""); window.location = "./index.php"; } else { if (navrat[0].length > 0) { $("#errLogin").html(navrat[0]); } else { $("#errLogin").html('Chybné přihlašovací údaje.'); } $("#errLogin").removeClass("d-none"); } } } }); } } function passChange() { let oldPassword = $("#oldPassword").val(), newPassword = $("#newPassword").val(), confirmPassword = $("#confirmPassword").val(), newPassVisible = $("#newPassVisible").attr("newpass-visible"), err = false; /* console.log(oldPassword); console.log(newPassword); */ if (oldPassword.length > 0) { oldPassword = oldPassword.trim(); } if (newPassword.length > 0) { newPassword = newPassword.trim(); } if (oldPassword.length * newPassword.length == 0) { err = true; $("#errChangePass").html("Mělo by být vyplněno staré i nové heslo."); $("#errChangePass").removeClass("d-none"); } else if (oldPassword === newPassword) { err = true; $("#errChangePass").html("Staré a nové heslo se shodují."); $("#errChangePass").removeClass("d-none"); } else if ((newPassVisible == "0") && (newPassword !== confirmPassword)) { err = true; $("#errChangePass").html("Nové heslo a jeho potvrzení se musí shodovat."); $("#errChangePass").removeClass("d-none"); } if (!err) { $.ajax({ url: "menu/loginChangePassword.php", type: 'POST', dataType: 'HTML', data: { 'oldPassword': oldPassword, 'newPassword': newPassword }, success: function (result) { console.log(result); let navrat = result.split("#"); succ = navrat[1].trim(); if (succ == 'true') { $("#errChangePass").addClass("d-none"); $('#pass-change').modal('hide'); $("#menu-changepassword-success").modal("show"); } else { $("#errChangePass").html(navrat[0]); $("#errChangePass").removeClass("d-none"); } } }); } } $("#menu-changepassword-success").on('hide.bs.modal', function () { $.ajax({ url: "menu/logout.php", type: 'POST', dataType: 'HTML', data: {}, success: function (result) { $('#dialogy').html(""); window.location = "index.php"; } }); });