add password generation functionality

This commit is contained in:
o-psi
2023-12-18 17:34:39 +00:00
parent e0c8b0c30d
commit f0567c1fb7
3 changed files with 110 additions and 64 deletions

View File

@@ -574,6 +574,30 @@ if (isset($_GET['contact_id'])) {
<!-- JavaScript to Show/Hide Password Form Group -->
<script>
function generatePassword(type, id) {
var url = '/ajax.php?get_readable_pass=true';
// Make an AJAX request to the server
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var password = xhr.responseText;
// Set the password value based on the type
if (type == "add") {
document.getElementById("password-add").value = password;
} else if (type == "edit") {
console.log("password-edit-"+id.toString());
document.getElementById("password-edit-"+id.toString()).value = password;
}
}
};
xhr.send();
}
$(document).ready(function() {
$('.authMethod').on('change', function() {
var $form = $(this).closest('.authForm');