Skip to content

Commit

Permalink
Ajac and QR code copy remove.
Browse files Browse the repository at this point in the history
  • Loading branch information
d3vilh committed Feb 26, 2024
1 parent 6943b54 commit 0005d7b
Showing 1 changed file with 7 additions and 37 deletions.
44 changes: 7 additions & 37 deletions views/certificates.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,43 +389,13 @@ <h3 class="card-title">OpenVPN Server Control</h3>
// Encode the email body as a URI component
var encodedEmailBody = encodeURIComponent(emailBody);

// Fetch the dynamic QR code image URL from the server
var imageName = $modal.find('.cert-name').text().trim(); // Use the name for the image URL
var qrCodeImageURL = '/displayimage/' + encodeURIComponent(imageName);

// Fetch the QR code image data from the server
$.ajax({
url: qrCodeImageURL,
method: 'GET',
dataType: 'text',
success: function (qrCodeImageData) {
// Create a data URI for the image
var imageBase64 = 'data:image/png;base64,' + qrCodeImageData;

// Create an <img> HTML tag to display the image in the email body
var imageTag = '<img src="' + imageBase64 + '" alt="QR Code Image">';

// Append the image tag to the email body
emailBody; // += '\n\n' + imageTag; // Embedded QR CODE id disabled.
// I cant figureout how to include it as a real image in email.body. My default Apple Mail app refuses to take it as <img> or base64.
// Will contiune to try in future versions. Help would be very much appreciated.
// Encode the updated email body as a URI component
var updatedEncodedEmailBody = encodeURIComponent(emailBody);

// Prepare the updated mailto link with the encoded email address, subject, and body
var mailtoLink = 'mailto:' + encodeURIComponent(emailAddress) +
'?subject=' + encodeURIComponent(emailSubject) +
'&body=' + updatedEncodedEmailBody;

// Open the default email client with the updated mailto link
window.location.href = mailtoLink;
},
error: function () {
// Handle errors if the image data cannot be fetched
alert('Error fetching QR code image data.');
}
});
});
// Prepare the mailto link with the encoded email address, subject, and body
var mailtoLink = 'mailto:' + encodeURIComponent(emailAddress) +
'?subject=' + encodeURIComponent(emailSubject) +
'&body=' + encodedEmailBody;

// Open the default email client with the mailto link
window.location.href = mailtoLink;
});
</script>

0 comments on commit 0005d7b

Please sign in to comment.