Spaces:
Running
Running
Download app.js from patrickestes/promptproof: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/spaces/patrickestes/promptproof/resolve/main/app.js
- Command line
-
hf download hf://spaces/patrickestes/promptproof/app.js
-
curl -L -o app.js https://huggingface.co/spaces/patrickestes/promptproof/resolve/main/app.js
2.53 kB
| (function () { | |
| var API_URL = 'https://cfjphnpbvvappqlwhktc.supabase.co/functions/v1/promptproof'; | |
| function submitHandler(formId, emailId, roleId, btnId, msgId, cardId, titleId) { | |
| var form = document.getElementById(formId); | |
| if (!form) return; | |
| form.addEventListener('submit', function (e) { | |
| e.preventDefault(); | |
| var emailEl = document.getElementById(emailId); | |
| var btn = document.getElementById(btnId); | |
| var msg = document.getElementById(msgId); | |
| var email = (emailEl.value || '').trim(); | |
| var role = ''; | |
| if (roleId) { | |
| var roleEl = document.getElementById(roleId); | |
| if (roleEl) role = roleEl.value || ''; | |
| } | |
| msg.className = 'form-msg'; | |
| if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email)) { | |
| msg.textContent = 'Enter a valid email address.'; | |
| msg.className = 'form-msg err'; | |
| return; | |
| } | |
| btn.disabled = true; | |
| btn.textContent = 'Joining...'; | |
| fetch(API_URL, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ email: email, role: role }) | |
| }).then(function (r) { return r.json(); }).then(function (data) { | |
| if (data && data.ok) { | |
| form.style.display = 'none'; | |
| var card = document.getElementById(cardId); | |
| var title = document.getElementById(titleId); | |
| if (data.position) { | |
| title.textContent = "You're in. #" + data.position + ' on the list.'; | |
| } | |
| card.style.display = 'block'; | |
| } else { | |
| msg.textContent = (data && data.error) ? data.error : 'Something went wrong. Try again.'; | |
| msg.className = 'form-msg err'; | |
| btn.disabled = false; | |
| btn.textContent = 'Join the waitlist'; | |
| } | |
| }).catch(function () { | |
| msg.textContent = 'Could not reach the server. Try again in a moment.'; | |
| msg.className = 'form-msg err'; | |
| btn.disabled = false; | |
| btn.textContent = 'Join the waitlist'; | |
| }); | |
| }); | |
| } | |
| submitHandler('waitlist-form', 'email', 'role', 'join-btn', 'form-msg', 'success-card', 'success-title'); | |
| submitHandler('waitlist-form-2', 'email-2', null, 'join-btn-2', 'form-msg-2', 'success-card-2', 'success-title-2'); | |
| var obs = new IntersectionObserver(function (entries) { | |
| entries.forEach(function (en) { if (en.isIntersecting) en.target.classList.add('in'); }); | |
| }, { threshold: 0.12 }); | |
| document.querySelectorAll('.reveal').forEach(function (el) { obs.observe(el); }); | |
| })(); | |