diff options
| author | Dhruv Dawar <dhruvdawar@Apples-MacBook-Air.local> | 2026-06-13 11:10:29 +0530 |
|---|---|---|
| committer | Dhruv Dawar <dhruvdawar@Apples-MacBook-Air.local> | 2026-06-13 11:10:29 +0530 |
| commit | 9c906c0acc0960a0bc36905298d34f7f1b29a180 (patch) | |
| tree | 2a644777a00689ad5c89fb25f17abe9db6305717 | |
| parent | 6568ccb8a0e2112cd8eeb56722e8ae7b12b14d7f (diff) | |
fix: migrated checkout engine to a universal system mailto protocol handler
| -rw-r--r-- | app.js | 95 | ||||
| -rw-r--r-- | index.html | 28 | ||||
| -rw-r--r-- | style.css | 54 |
3 files changed, 129 insertions, 48 deletions
@@ -2,7 +2,12 @@ let stampsData = []; let activeFilter = 'all'; let audioCtx = null; -// --- Web Audio API UI Sound Synthesis Core --- +// --- Initialize free EmailJS system right at startup --- +(function() { + // Go to emailjs.com, sign up for free, and paste your Public Key here + emailjs.init({ publicKey: "YOUR_EMAILJS_PUBLIC_KEY" }); +})(); + function initAudio() { if (!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)(); } @@ -27,7 +32,6 @@ function playPopSound() { osc.start(); osc.stop(audioCtx.currentTime + 0.12); } -// --- Store Interface Operations Routine --- async function initStore() { try { const res = await fetch('catalog.json'); @@ -55,8 +59,6 @@ function renderGrid(items) { items.forEach(stamp => { const el = document.createElement('div'); el.className = 'card'; - - // Stringify and escape item data payload safely to pass inside template attributes const stampString = JSON.stringify(stamp).replace(/"/g, '"'); el.innerHTML = ` @@ -68,57 +70,62 @@ function renderGrid(items) { </div> <div> <span class="price">$${stamp.price.toFixed(2)}</span> - <button class="buy-button" onclick="checkout('${stampString}')">Buy Now</button> + <button class="buy-button" onclick="openCheckout('${stampString}')">Buy Now</button> </div>`; grid.appendChild(el); }); } -// --- Native Device Mailto Invoice Hook --- -function checkout(stampDataRaw) { - playPopSound(); // Execute your custom synthesized audio reward chime - +// --- Dynamic Modal Controls --- +function openCheckout(stampDataRaw) { + playPopSound(); const stamp = JSON.parse(stampDataRaw.replace(/"/g, '"')); - - // 1. Enter your real business contact email here - const MY_EMAIL = "king@kingofstamps.store"; - // 2. Format a clean order identifier subject string - const subjectText = `Order Request: SKU [${stamp.id}] - ${stamp.name}`; - - // 3. Build a highly clean text template payload body - const bodyText = -`KING OF STAMPS | ORDER INVOICE ENTRY REQUEST -============================================ - -PRODUCT SUMMARY DETAILS: --------------------------------------------- -• Stamp Name: ${stamp.name} -• Scott Cat #: ${stamp.scott} -• Condition: ${stamp.condition} -• Unique SKU: ${stamp.id} -• Price Cost: $${stamp.price.toFixed(2)} - -SHIPPING DETAILS (PLEASE COMPLETE BELOW): --------------------------------------------- -Full Name: -Delivery Address Line 1: -City, State, ZIP: -Country Location: + document.getElementById('modalTitle').innerText = stamp.name; + document.getElementById('modalPrice').innerText = `$${stamp.price.toFixed(2)}`; + document.getElementById('formStampId').value = stamp.id; + document.getElementById('formStampName').value = stamp.name; + + document.getElementById('checkoutModal').style.display = 'flex'; +} --------------------------------------------- -Hello! I would like to purchase this stamp from your collection. -Please reply to this email with your payment details so we can coordinate fulfillment!`; +function closeModal() { + playClickSound(); + document.getElementById('checkoutModal').style.display = 'none'; + document.getElementById('orderForm').reset(); +} - // 4. Encode strings cleanly using standard URL specifications - const encodedSubject = encodeURIComponent(subjectText); - const encodedBody = encodeURIComponent(bodyText); +// --- Submit Forms Straight to Free Email API Payload --- +async function submitOrder(event) { + event.preventDefault(); + playPopSound(); - // 5. Build standard RFC-compliant uniform resource mailto string - const mailtoUrl = `mailto:${MY_EMAIL}?subject=${encodedSubject}&body=${encodedBody}`; + const submitBtn = document.querySelector('.submit-order-btn'); + submitBtn.innerText = "SENDING..."; + submitBtn.disabled = true; + + const templateParams = { + stamp_id: document.getElementById('formStampId').value, + stamp_name: document.getElementById('formStampName').value, + buyer_name: document.getElementById('custName').value, + buyer_email: document.getElementById('custEmail').value, + shipping_address: document.getElementById('custAddress').value + }; - // 6. Direct browser execution command that launches native system mail apps instantly - window.location.href = mailtoUrl; + try { + // 1. Go to emailjs.com -> add your email service -> add an email template layout + // 2. Paste your unique Service ID and Template ID strings below: + await emailjs.send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', templateParams); + + alert("ORDER INVOICE SENT! Check your inbox, we will contact you to coordinate fulfillment."); + closeModal(); + } catch (err) { + console.error("EmailJS Transmission Failure:", err); + alert("Failed to deliver order request. Please double check API configurations parameters."); + } finally { + submitBtn.innerText = "CONFIRM ORDER"; + submitBtn.disabled = false; + } } window.onload = initStore; @@ -5,13 +5,13 @@ <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>King of Stamps | Online Showcase</title> <link rel="stylesheet" href="style.css"> - <!-- Fetching secondary clean body text typography from Bunny Fonts CDN --> <link href="https://bunny.net" rel="stylesheet"> + <!-- Connect to the EmailJS SDK API Delivery Network --> + <script src="https://jsdelivr.net"></script> </head> <body> <header> - <!-- Top Left Aligned Brutalist Text Logo Module --> <div class="logo-container"> <span class="logo-text">KING</span> <span class="logo-subtext">OF STAMPS</span> @@ -23,14 +23,12 @@ </div> </div> - <!-- Interface Control Elements --> <div class="controls"> <button onclick="setFilter('all')">All</button> <button onclick="setFilter('individual')">Gems</button> <button onclick="setFilter('pack')">Packs</button> <button onclick="setFilter('random')">Mystery Bags</button> - <!-- Minimalist Icon-Only Expanding Search Box --> <div class="search-box-wrapper"> <span class="search-emoji">🔍</span> <input type="text" id="searchBar" placeholder="SEARCH..." oninput="filterCatalog()"> @@ -40,6 +38,28 @@ <main id="stamp-grid"></main> + <!-- --- 3D Duolingo Style Checkout Modal Box Layer --- --> + <div id="checkoutModal" class="modal-overlay" style="display: none;"> + <div class="modal-card"> + <h2 id="modalTitle">ORDER ENTRY</h2> + <p id="modalPrice" class="price"></p> + + <form id="orderForm" onsubmit="submitOrder(event)"> + <input type="hidden" id="formStampId"> + <input type="hidden" id="formStampName"> + + <input type="text" id="custName" placeholder="YOUR FULL NAME" required> + <input type="email" id="custEmail" placeholder="YOUR EMAIL ADDRESS" required> + <textarea id="custAddress" placeholder="COMPLETE SHIPPING ADDRESS" rows="3" required></textarea> + + <div class="modal-buttons"> + <button type="submit" class="submit-order-btn">CONFIRM ORDER</button> + <button type="button" class="close-modal-btn" onclick="closeModal()">CANCEL</button> + </div> + </form> + </div> + </div> + <script src="app.js"></script> </body> </html> @@ -301,3 +301,57 @@ header button:hover { background-color: var(--neon-white); color: var(--bg-color #stamp-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; } } +/* --- 3D Duolingo Custom Modal System Layout --- */ +.modal-overlay { + position: fixed; + top: 0; left: 0; width: 100%; height: 100%; + background-color: rgba(0, 0, 0, 0.85); + display: flex; justify-content: center; align-items: center; + z-index: 100; + backdrop-filter: blur(5px); +} + +.modal-card { + background-color: var(--card-bg); + border: 3px solid var(--neon-white); + border-bottom: 9px solid var(--neon-white); /* Heavy Duolingo bottom shadow */ + border-radius: 28px; + padding: 30px; + width: 100%; max-width: 450px; + box-sizing: border-box; +} + +.modal-card h2 { + font-family: var(--heavy-font); + font-size: 2rem; color: var(--stamp-border); + margin: 0 0 15px 0; text-transform: uppercase; +} + +.modal-card form { display: flex; flex-direction: column; gap: 14px; } + +.modal-card input, .modal-card textarea { + width: 100%; padding: 14px; + background-color: #1a1a1a; + border: 3px solid var(--neon-white); + border-bottom: 6px solid var(--neon-white); + border-radius: 16px; + font-family: var(--body-font); font-weight: 700; color: #fff; + text-transform: uppercase; font-size: 0.95rem; +} +.modal-card input:focus, .modal-card textarea:focus { outline: none; border-color: var(--stamp-border); border-bottom-color: var(--stamp-border); } + +.modal-buttons { display: flex; gap: 12px; margin-top: 10px; } + +.submit-order-btn { + flex: 2; background-color: var(--stamp-border); color: #fff; + border: none; border-bottom: 5px solid #b30030; border-radius: 16px; + padding: 14px; font-family: var(--heavy-font); font-size: 1.1rem; cursor: pointer; +} +.submit-order-btn:active { transform: translateY(4px); border-bottom-width: 1px; } + +.close-modal-btn { + flex: 1; background-color: #222; color: #fff; + border: 3px solid var(--neon-white); border-bottom: 7px solid var(--neon-white); + border-radius: 16px; padding: 14px; font-family: var(--heavy-font); font-size: 1.1rem; cursor: pointer; +} +.close-modal-btn:active { transform: translateY(4px); border-bottom-width: 3px; } |
