// ══ EDIT YOUR CONTACT DETAILS HERE ═════════════════════════════════════ // Leave a value empty ('' or []) to hide it from the page. var CONTACT = window.SITE_CONTACT || { email: '', phone: '', hours: '', whatsapp: '', address: [] }; // ════════════════════════════════════════════════════════════════════════ // Refuse to run inside another site's frame if (window.top !== window.self) { document.documentElement.style.display = 'none'; try { window.top.location = window.self.location.href; } catch (e) {} throw new Error('PicSpot AI cannot be shown inside another site.'); } function $(id) { return document.getElementById(id); } document.querySelectorAll('.year').forEach(function (n) { n.textContent = new Date().getFullYear(); }); // ── Contact details ──────────────────────────────────────────────────── if (CONTACT.address && CONTACT.address.length) { CONTACT.address.forEach(function (line) { var span = document.createElement('span'); span.textContent = line; $('address').appendChild(span); }); $('way-address').hidden = false; } if (CONTACT.email) { $('email-link').textContent = CONTACT.email; $('email-link').href = 'mailto:' + CONTACT.email; $('way-email').hidden = false; } if (CONTACT.phone) { $('phone-link').textContent = CONTACT.phone; $('phone-link').href = 'tel:' + CONTACT.phone.replace(/[^+\d]/g, ''); $('hours').textContent = CONTACT.hours || ''; $('way-phone').hidden = false; } if (!CONTACT.email && !CONTACT.phone && !(CONTACT.address && CONTACT.address.length)) $('ways-card').hidden = true; $('send-whatsapp').hidden = !CONTACT.whatsapp; $('send-email').hidden = !CONTACT.email; $('send-help').textContent = CONTACT.email && CONTACT.whatsapp ? 'Your message opens in your email app or WhatsApp, ready to send.' : CONTACT.email ? 'Your message opens in your email app, ready to send.' : CONTACT.whatsapp ? 'Your message opens in WhatsApp, ready to send.' : ''; // ── Message form ─────────────────────────────────────────────────────── // The page has no server of its own for messages, so it hands the finished message to the visitor's email app or WhatsApp function note(text, kind) { var n = $('note'); n.textContent = text; n.className = 'note show ' + (kind || 'error'); } function buildMessage() { var name = $('c-name').value.trim(); var phone = $('c-phone').value.trim(); var topic = $('c-topic').value; var message = $('c-message').value.trim(); if (!name) { note('Enter your name.'); $('c-name').focus(); return null; } if (message.length < 10) { note('Write a short message so we know how to help.'); $('c-message').focus(); return null; } return { subject: topic + ' from ' + name, body: message + '\n\n' + name + (phone ? '\nPhone: ' + phone : '') }; } $('contact-form').addEventListener('submit', function (e) { e.preventDefault(); if (!CONTACT.email) { note('This form is not connected yet.'); return; } var m = buildMessage(); if (!m) return; window.location.href = 'mailto:' + CONTACT.email + '?subject=' + encodeURIComponent(m.subject) + '&body=' + encodeURIComponent(m.body); note('Your email app should now be open with the message. Press send there to deliver it.', 'ok'); }); $('send-whatsapp').addEventListener('click', function () { var m = buildMessage(); if (!m) return; window.open('https://wa.me/' + CONTACT.whatsapp + '?text=' + encodeURIComponent(m.subject + '\n\n' + m.body), '_blank', 'noopener'); note('WhatsApp should now be open with the message. Press send there to deliver it.', 'ok'); }); if (!CONTACT.email && !CONTACT.whatsapp) note('Contact details have not been added yet.');