Save the World Challenge

Save the World Challenge

Challenge Details

{ alert('Failed to load image.'); }; } function showChallenge() { challengeText.textContent = challenges[currentChallengeIndex]; } function showForm() { document.getElementById('challenge').value = challenges[currentChallengeIndex]; challengeForm.style.display = 'block'; } function skipChallenge() { currentChallengeIndex = (currentChallengeIndex + 1) % challenges.length; showChallenge(); } acceptButton.addEventListener('click', showForm); skipButton.addEventListener('click', function() { skipChallenge(); showChallenge(); }); form.addEventListener('submit', async function(e) { e.preventDefault(); const name = document.getElementById('name').value; const email = document.getElementById('email').value; const challenge = document.getElementById('challenge').value; const dueDate = document.getElementById('due-date').value; // Create PDF const { jsPDF } = window.jspdf; const doc = new jsPDF(); const currentDateTime = new Date().toLocaleString(); doc.setFont('Arial', 'B'); doc.text('Save the World Moment - Reduce Your Carbon Footprint', 20, 10); doc.setFont('Arial', 'Normal'); doc.text(`This is to confirm that ${name}, having an email address of ${email}, has declared on ${currentDateTime}, that they will be completing the challenge: ${challenge} by the system on or before ${dueDate}.`, 20, 20); // Add Preloaded Image if (imageDataUrl) { doc.addImage(imageDataUrl, 'PNG', 20, 40, 160, 80); // Adjust positioning and size as needed doc.save('challenge_declaration.pdf'); } else { alert('Image not available.'); } }); // Preload image before form is shown preloadImage('https://drive.google.com/uc?export=view&id=1ifNJDBAIc7EAutlz-mgJFyu5m4tJzE9f', function() { showChallenge(); }); }); ]]>

Subscribe to receive free email updates:

Related Posts :

0 Response to "Save the World Challenge"

Post a Comment