|
|
|
@ -13,12 +13,103 @@ function initializeLicense() {
|
|
|
|
if (storedLicense) {
|
|
|
|
if (storedLicense) {
|
|
|
|
// Valider la licence stockée
|
|
|
|
// Valider la licence stockée
|
|
|
|
validateStoredLicense(storedLicense);
|
|
|
|
validateStoredLicense(storedLicense);
|
|
|
|
|
|
|
|
// Afficher les infos de licence
|
|
|
|
|
|
|
|
displayLicenseInfo(storedLicense);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Afficher la page de licence
|
|
|
|
// Afficher la page de licence
|
|
|
|
showLicenseModal();
|
|
|
|
showLicenseModal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function displayLicenseInfo(license) {
|
|
|
|
|
|
|
|
console.log("Displaying license info...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Chercher le container du badge
|
|
|
|
|
|
|
|
const container = document.getElementById('license-badge-container');
|
|
|
|
|
|
|
|
if (!container) {
|
|
|
|
|
|
|
|
console.error("license-badge-container not found");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Créer le badge
|
|
|
|
|
|
|
|
const badge = document.createElement('div');
|
|
|
|
|
|
|
|
badge.id = 'license-badge';
|
|
|
|
|
|
|
|
badge.style.cssText = `
|
|
|
|
|
|
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
|
|
padding: 12px 20px;
|
|
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
|
|
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
|
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
min-width: 200px;
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let badgeText = '✓ Licence Activée';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Si c'est une licence d'essai
|
|
|
|
|
|
|
|
if (license.startsWith('TRIAL-')) {
|
|
|
|
|
|
|
|
const daysRemaining = getTrialDaysRemaining(license);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (daysRemaining <= 0) {
|
|
|
|
|
|
|
|
badgeText = '⏱️ Essai expiré';
|
|
|
|
|
|
|
|
badge.style.background = 'linear-gradient(135deg, #f44336 0%, #da190b 100%)';
|
|
|
|
|
|
|
|
} else if (daysRemaining <= 2) {
|
|
|
|
|
|
|
|
badgeText = `⚠️ ${daysRemaining} jour${daysRemaining > 1 ? 's' : ''} restant${daysRemaining > 1 ? 's' : ''}`;
|
|
|
|
|
|
|
|
badge.style.background = 'linear-gradient(135deg, #ff9800 0%, #f57c00 100%)';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
badgeText = `⏱️ Essai: ${daysRemaining} jours`;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
badge.textContent = badgeText;
|
|
|
|
|
|
|
|
badge.onclick = function() {
|
|
|
|
|
|
|
|
alert('Licence: ' + license.substring(0, 50) + '...\n\nClique sur le logo pour gérer ta licence.');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
container.appendChild(badge);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ajouter un hover effect
|
|
|
|
|
|
|
|
badge.addEventListener('mouseenter', function() {
|
|
|
|
|
|
|
|
this.style.transform = 'translateY(-3px)';
|
|
|
|
|
|
|
|
this.style.boxShadow = '0 6px 25px rgba(102, 126, 234, 0.5)';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
badge.addEventListener('mouseleave', function() {
|
|
|
|
|
|
|
|
this.style.transform = 'translateY(0)';
|
|
|
|
|
|
|
|
this.style.boxShadow = '0 4px 15px rgba(102, 126, 234, 0.3)';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getTrialDaysRemaining(trialLicense) {
|
|
|
|
|
|
|
|
// Extraire le timestamp du license (format: TRIAL-timestamp)
|
|
|
|
|
|
|
|
const parts = trialLicense.split('-');
|
|
|
|
|
|
|
|
if (parts.length !== 2) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const timestamp = parseInt(parts[1]);
|
|
|
|
|
|
|
|
if (isNaN(timestamp)) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Créer la date de création
|
|
|
|
|
|
|
|
const createdDate = new Date(timestamp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ajouter 7 jours
|
|
|
|
|
|
|
|
const expirationDate = new Date(createdDate.getTime() + (7 * 24 * 60 * 60 * 1000));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calculer les jours restants
|
|
|
|
|
|
|
|
const now = new Date();
|
|
|
|
|
|
|
|
const daysRemaining = Math.ceil((expirationDate - now) / (1000 * 60 * 60 * 24));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("Trial created:", createdDate);
|
|
|
|
|
|
|
|
console.log("Trial expires:", expirationDate);
|
|
|
|
|
|
|
|
console.log("Days remaining:", daysRemaining);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Math.max(0, daysRemaining);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showLicenseModal() {
|
|
|
|
function showLicenseModal() {
|
|
|
|
console.log("Showing license modal");
|
|
|
|
console.log("Showing license modal");
|
|
|
|
|
|
|
|
|
|
|
|
@ -161,6 +252,8 @@ function validateLicenseInput() {
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
closeLicenseModal();
|
|
|
|
closeLicenseModal();
|
|
|
|
|
|
|
|
// Afficher les infos de licence
|
|
|
|
|
|
|
|
displayLicenseInfo(licenseInput);
|
|
|
|
}, 1500);
|
|
|
|
}, 1500);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
showLicenseMessage('Format de licence invalide', 'error');
|
|
|
|
showLicenseMessage('Format de licence invalide', 'error');
|
|
|
|
@ -168,7 +261,7 @@ function validateLicenseInput() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function skipLicense() {
|
|
|
|
function skipLicense() {
|
|
|
|
// Créer une licence d'essai valide 7 jours
|
|
|
|
// Créer une licence d'essai avec timestamp (format: TRIAL-timestamp)
|
|
|
|
const trialLicense = 'TRIAL-' + Date.now();
|
|
|
|
const trialLicense = 'TRIAL-' + Date.now();
|
|
|
|
setCookie(LICENSE_STORAGE_KEY, trialLicense, 7);
|
|
|
|
setCookie(LICENSE_STORAGE_KEY, trialLicense, 7);
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,6 +274,8 @@ function skipLicense() {
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
closeLicenseModal();
|
|
|
|
closeLicenseModal();
|
|
|
|
|
|
|
|
// Afficher les infos de licence
|
|
|
|
|
|
|
|
displayLicenseInfo(trialLicense);
|
|
|
|
}, 1500);
|
|
|
|
}, 1500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|