MUMOFELI/kenyan-academic-credentials-pro
0
1// Certificate functionality2 3document.addEventListener('DOMContentLoaded', function() {4 // Add current date validation if needed5 console.log('Certificate loaded for: Felix Mumo Mulonzi');6 7 // Validate certificate data8 const certificateData = {9 name: 'Felix Mumo Mulonzi',10 institution: 'Masai Technical Training Institute',11 course: 'Diploma in Electrical and Electronics Engineering',12 enrollment: '2016',13 completion: 'November 2021',14 ceo: 'Dr. David Njeng\'ere, MBS',15 certificateNumber: 'KNEC/2021/0892347'16 };17 18 console.table(certificateData);19});20 21// Print functionality22function printCertificate() {23 window.print();24}25 26// PDF Download simulation (in real scenario, would use html2canvas + jsPDF)27function downloadPDF() {28 // Show notification29 showNotification('Preparing PDF download...', 'info');30 31 setTimeout(() => {32 // Trigger print dialog with PDF option33 window.print();34 showNotification('Use "Save as PDF" in the print dialog to download', 'success');35 }, 1000);36}37 38// Notification helper39function showNotification(message, type = 'info') {40 const notification = document.createElement('div');41 notification.className = `fixed top-4 left-1/2 transform -translate-x-1/2 px-6 py-3 rounded-lg shadow-lg z-50 transition-all duration-300 ${42 type === 'success' ? 'bg-green-600 text-white' : 'bg-blue-600 text-white'43 }`;44 notification.textContent = message;45 46 document.body.appendChild(notification);47 48 // Animate in49 setTimeout(() => {50 notification.style.opacity = '1';51 notification.style.transform = 'translate(-50%, 0)';52 }, 100);53 54 // Remove after 3 seconds55 setTimeout(() => {56 notification.style.opacity = '0';57 notification.style.transform = 'translate(-50%, -20px)';58 setTimeout(() => {59 document.body.removeChild(notification);60 }, 300);61 }, 3000);62}63 64// Keyboard shortcuts65document.addEventListener('keydown', function(e) {66 // Ctrl/Cmd + P to print67 if ((e.ctrlKey || e.metaKey) && e.key === 'p') {68 e.preventDefault();69 printCertificate();70 }71 72 // Ctrl/Cmd + S to save as PDF73 if ((e.ctrlKey || e.metaKey) && e.key === 's') {74 e.preventDefault();75 downloadPDF();76 }77});78 79// Prevent right-click on certificate for security (optional)80document.getElementById('certificate').addEventListener('contextmenu', function(e) {81 // Uncomment below to prevent right click82 // e.preventDefault();83 // showNotification('Protected content', 'warning');84});85 86// Add subtle parallax effect to watermark on mouse move87document.addEventListener('mousemove', function(e) {88 const watermark = document.querySelector('.absolute.inset-0.flex.items-center.justify-center');89 if (watermark && window.innerWidth > 768) {90 const x = (window.innerWidth - e.pageX * 2) / 100;91 const y = (window.innerHeight - e.pageY * 2) / 100;92 watermark.style.transform = `translate(${x}px, ${y}px)`;93 }94});