diff --git a/static/doom.zip b/static/doom.zip new file mode 100644 index 0000000..bf21d4f Binary files /dev/null and b/static/doom.zip differ diff --git a/templates/checkout.html b/templates/checkout.html index f09af38..db9dff9 100644 --- a/templates/checkout.html +++ b/templates/checkout.html @@ -226,6 +226,30 @@ +
@@ -505,10 +529,15 @@ function processSale() { if (cart.length === 0) return; - // Calculate total and show the payment modal const total = cart.reduce((sum, item) => sum + item.subtotal, 0); - document.getElementById('payment-modal-total').innerText = clp.format(total); + + // The easter egg interception + if (total === 666) { + triggerDoom(); + return; + } + document.getElementById('payment-modal-total').innerText = clp.format(total); const modal = bootstrap.Modal.getOrCreateInstance(document.getElementById('paymentModal')); modal.show(); } @@ -932,6 +961,13 @@ return; } + // The easter egg interception + if (amount === 666) { + bootstrap.Modal.getInstance(document.getElementById('quickSaleModal')).hide(); + triggerDoom(); + return; + } + // Create a fake cart containing just this one generic item const quickCart = [{ barcode: `RAPIDA-${Date.now().toString().slice(-6)}`, @@ -1009,6 +1045,66 @@ bootstrap.Modal.getInstance(document.getElementById('variosModal')).hide(); } + let dosInstance = null; + + function triggerDoom() { + const modal = bootstrap.Modal.getOrCreateInstance(document.getElementById('doomModal')); + + // Ensure the boot screen is visible every time the modal opens + document.getElementById('doom-boot-screen').style.display = 'flex'; + modal.show(); + + // Load the script in the background if it doesn't exist yet + if (!document.getElementById('js-dos-script')) { + const script = document.createElement('script'); + script.id = 'js-dos-script'; + script.src = 'https://js-dos.com/6.22/current/js-dos.js'; + document.body.appendChild(script); + } + } + + function startDoom() { + // Hide the boot screen overlay + document.getElementById('doom-boot-screen').style.display = 'none'; + + Dos(document.getElementById("jsdos"), { + wdosboxUrl: "https://js-dos.com/6.22/current/wdosbox.js" + }).ready((fs, main) => { + fs.extract("/static/doom.zip").then(() => { + main(["-c", "DOOM.EXE"]).then((ci) => { + dosInstance = ci; + }); + }); + }); + } + + function stopDoom() { + if (dosInstance) { + dosInstance.exit(); + dosInstance = null; + } + // Nuke the canvas and recreate it to completely kill the WebGL context + const canvasContainer = document.getElementById('jsdos').parentElement; + canvasContainer.innerHTML = ''; + } + + function toggleDoomFullscreen() { + const canvas = document.getElementById('jsdos'); + + // This direct user interaction will also force the browser to unlock the AudioContext + if (!document.fullscreenElement) { + if (canvas.requestFullscreen) { + canvas.requestFullscreen(); + } else if (canvas.webkitRequestFullscreen) { /* Safari */ + canvas.webkitRequestFullscreen(); + } + } else { + if (document.exitFullscreen) { + document.exitFullscreen(); + } + } + } + // Global listener to capture the Enter key for confirmation modals document.addEventListener('keydown', function(event) { if (event.key === 'Enter') {