License
by velo_ninja
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>License Activation</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="app">
<h1>License Activation</h1>
<p>Status: <span id="status">Not Activated</span></p>
<button id="activateBtn" onclick="activateLicense()">Activate License</button>
</div>
<script src="script.js"></script>
</body>
</html>
JavaScript
// Function to verify license using API
async function verifyLicense(key) {
try {
console.log('Verifying license with server...');
const response = await fetch('https://your-server.com/api/verify-license', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ licenseKey: key })
});
const data = await response.json();
return data.isValid;
} catch (error) {
console.error('Error verifying license:', error);
return false;
}
}
// Function to activate the license
async function activateLicense() {
console.log('Activating license...');
const licenseKey = prompt('Enter your license key:');
if (licenseKey) {
console.log('License key entered:', licenseKey);
const isValidLicense = await verifyLicense(licenseKey);
if (isValidLicense) {
console.log('License verified successfully.');
document.getElementById('status').textContent = 'Activated';
document.getElementById('activateBtn').style.display = 'none';
} else {
console.error('Invalid license key!');
alert('Invalid license key!');
}
} else {
console.error('Invalid license key!');
alert('Invalid license key!');
}
}