function generateKey() {
// Create the overlay dynamically
var overlay = document.createElement('div');
overlay.className = 'overlay';
// Create the small screen dynamically
var generateKeyScreen = document.createElement('div');
generateKeyScreen.className = 'generate-key-screen';
// Generate random public and private keys
var publicKey = generateRandomKey();
var privateKey = generateRandomKey();
// Add input fields for Name, Public Key, Private Key, Key Type, and Created
generateKeyScreen.innerHTML = `
`;
// Append the overlay and small screen to the body
document.body.appendChild(overlay);
document.body.appendChild(generateKeyScreen);
// Display the overlay and small screen
overlay.style.display = 'block';
generateKeyScreen.style.display = 'block';
}
function generateRandomKey() {
// Generate a random string as a key (you might want to use a more robust key generation method)
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
}
function getCurrentDate() {
// Get the current date and format it as 'YYYY-MM-DD'
return new Date().toISOString().split('T')[0];
}
function copyToClipboard(elementId) {
// Copy the text from the specified input field to the clipboard
var element = document.getElementById(elementId);
element.select();
document.execCommand('copy');
// Optionally, you can provide feedback to the user (e.g., display a tooltip)
alert('Copied to clipboard: ' + element.value);
}
function saveKey() {
// Retrieve values from input fields
var name = document.getElementById('name').value;
var publicKey = document.getElementById('publicKey').value;
var privateKey = document.getElementById('privateKey').value;
var created = document.getElementById('created').value;
// Create a new table row with the key information
var newRow = document.createElement('tr');
newRow.innerHTML = `