What Do You Want?

I Want My Own _________.

SOMETHING WENT WRONG. TRY AGAIN.
const SUPABASE_URL = 'https://dvgrawagdqbucdezdmsa.supabase.co/rest/v1/'; const SUPABASE_KEY = 'sb_publishable_485DEPFQhcbPuRSSczN9TQ_1HGDCpYn'; const iwmoForm = document.getElementById("iwmo-form"); const iwmoSubmit = document.getElementById("iwmo-submit"); const iwmoSuccess = document.getElementById("iwmo-success"); const iwmoError = document.getElementById("iwmo-error"); iwmoForm.addEventListener("submit", async function(event) { event.preventDefault(); iwmoError.style.display = "none"; iwmoSubmit.disabled = true; iwmoSubmit.textContent = "..."; const formData = new FormData(iwmoForm); const answer = formData.get("answer"); const email = formData.get("email"); try { const supabaseResponse = await fetch( SUPABASE_URL + 'rpc/submit_want', { method: 'POST', headers: { 'apikey': SUPABASE_KEY, 'Authorization': 'Bearer ' + SUPABASE_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ p_answer: answer }) } ); if (!supabaseResponse.ok) { throw new Error("Supabase submission failed"); } const submissionId = await supabaseResponse.json(); if (email) { const emailResponse = await fetch( SUPABASE_URL + 'subscribers', { method: 'POST', headers: { 'apikey': SUPABASE_KEY, 'Authorization': 'Bearer ' + SUPABASE_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email.trim(), submission_id: submissionId }) } ); if (!emailResponse.ok) { throw new Error("Email signup failed"); } } iwmoForm.reset(); iwmoForm.style.display = "none"; iwmoSuccess.style.display = "flex"; } catch (error) { console.error(error); iwmoSubmit.disabled = false; iwmoSubmit.textContent = "SUBMIT"; iwmoError.style.display = "block"; } });

Maybe We're Here To Decide What We Want

What The People Want:

Loading what the people want...
(async function () { const SUPABASE_URL = 'https://dvgrawagdqbucdezdmsa.supabase.co'; const API_KEY = 'sb_publishable_485DEPFQhcbPuRSSczN9TQ_1HGDCpYn'; const SUBMISSIONS_URL = SUPABASE_URL + '/rest/v1/Submissions?select=id,answer&approved=eq.true&order=created_at.desc'; const container = document.getElementById('iwmo-wants'); /* Give this browser its own anonymous voter ID */ let voterId = localStorage.getItem('iwmo_voter_id'); if (!voterId) { voterId = crypto.randomUUID(); localStorage.setItem('iwmo_voter_id', voterId); } /* Remember this browser's votes */ let savedVotes = {}; try { savedVotes = JSON.parse(localStorage.getItem('iwmo_votes')) || {}; } catch { savedVotes = {}; } function saveVotes() { localStorage.setItem('iwmo_votes', JSON.stringify(savedVotes)); } async function toggleVote(submissionId, vote, upButton, downButton) { upButton.disabled = true; downButton.disabled = true; try { const response = await fetch( SUPABASE_URL + '/rest/v1/rpc/toggle_vote', { method: 'POST', headers: { 'apikey': API_KEY, 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ p_submission_id: submissionId, p_voter_id: voterId, p_vote: vote }) } ); if (!response.ok) { throw new Error(await response.text()); } const currentVote = savedVotes[submissionId]; if (currentVote === vote) { delete savedVotes[submissionId]; } else { savedVotes[submissionId] = vote; } saveVotes(); upButton.classList.toggle( 'active', savedVotes[submissionId] === 1 ); downButton.classList.toggle( 'active', savedVotes[submissionId] === -1 ); } catch (error) { console.error('Vote failed:', error); } upButton.disabled = false; downButton.disabled = false; } try { const response = await fetch(SUBMISSIONS_URL, { headers: { 'apikey': API_KEY, 'Authorization': 'Bearer ' + API_KEY } }); if (!response.ok) { throw new Error('Could not load submissions'); } const submissions = await response.json(); container.innerHTML = ''; if (submissions.length === 0) { container.innerHTML = '
Nothing here yet.
'; return; } submissions.forEach(item => { const entry = document.createElement('div'); entry.className = 'iwmo-want'; let answer = item.answer.trim(); /* Remove "I want my own" if they already typed it */ answer = answer.replace(/^i\s+want\s+my\s+own\s*/i, ''); const prefix = document.createElement('div'); prefix.className = 'iwmo-prefix'; prefix.textContent = 'I Want My Own'; const answerText = document.createElement('div'); answerText.className = 'iwmo-answer'; answerText.textContent = answer; /* Voting controls */ const votes = document.createElement('div'); votes.className = 'iwmo-votes'; const upButton = document.createElement('button'); upButton.className = 'iwmo-vote'; upButton.type = 'button'; upButton.textContent = '👍'; upButton.setAttribute('aria-label', 'Like'); const downButton = document.createElement('button'); downButton.className = 'iwmo-vote'; downButton.type = 'button'; downButton.textContent = '👎'; downButton.setAttribute('aria-label', 'Dislike'); if (savedVotes[item.id] === 1) { upButton.classList.add('active'); } if (savedVotes[item.id] === -1) { downButton.classList.add('active'); } upButton.addEventListener('click', function () { toggleVote(item.id, 1, upButton, downButton); }); downButton.addEventListener('click', function () { toggleVote(item.id, -1, upButton, downButton); }); votes.appendChild(upButton); votes.appendChild(downButton); entry.appendChild(prefix); entry.appendChild(answerText); entry.appendChild(votes); container.appendChild(entry); }); } catch (error) { console.error(error); container.innerHTML = ''; } })();
IWMO ADMIN
Sign in to continue
(async function () { const SUPABASE_URL = 'https://dvgrawagdqbucdezdmsa.supabase.co'; const API_KEY = 'sb_publishable_485DEPFQhcbPuRSSczN9TQ_1HGDCpYn'; let accessToken = null; const loginArea = document.getElementById('iwmo-login'); const dashboard = document.getElementById('iwmo-dashboard'); const loginButton = document.getElementById('iwmo-login-button'); const loginMessage = document.getElementById('iwmo-login-message'); const list = document.getElementById('iwmo-admin-list'); const voteList = document.getElementById('iwmo-vote-list'); const subscriberList = document.getElementById('iwmo-subscriber-list'); /* ---------------- LOGIN ---------------- */ loginButton.addEventListener('click', login); document .getElementById('iwmo-password') .addEventListener('keydown', function(event) { if (event.key === 'Enter') { login(); } }); async function login() { const email = document.getElementById('iwmo-email').value.trim(); const password = document.getElementById('iwmo-password').value; if (!email || !password) { loginMessage.textContent = 'Enter your email and password.'; return; } loginButton.disabled = true; loginMessage.textContent = 'Signing in...'; try { const response = await fetch( SUPABASE_URL + '/auth/v1/token?grant_type=password', { method: 'POST', headers: { 'apikey': API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email, password: password }) } ); const data = await response.json(); if (!response.ok || !data.access_token) { throw new Error( data.error_description || data.msg || 'Login failed' ); } accessToken = data.access_token; sessionStorage.setItem( 'iwmo_admin_token', accessToken ); loginArea.style.display = 'none'; dashboard.style.display = 'block'; await loadSubmissions(); await loadVotes(); await loadSubscribers(); } catch (error) { console.error(error); loginMessage.textContent = 'Could not sign in. Check your email and password.'; } finally { loginButton.disabled = false; } } /* ---------------- LOAD ---------------- */ async function loadSubmissions() { list.innerHTML = '
Loading submissions...
'; try { const response = await fetch( SUPABASE_URL + '/rest/v1/Submissions' + '?select=id,answer,created_at' + '&approved=eq.false' + '&reviewed=eq.false' + '&order=created_at.desc', { headers: { 'apikey': API_KEY, 'Authorization': 'Bearer ' + accessToken } } ); if (!response.ok) { throw new Error('Could not load submissions'); } const submissions = await response.json(); list.innerHTML = ''; if (submissions.length === 0) { list.innerHTML = '
All caught up.
'; return; } submissions.forEach(function(item) { const card = document.createElement('div'); card.className = 'iwmo-admin-card'; const answer = document.createElement('div'); answer.className = 'iwmo-admin-answer'; answer.textContent = item.answer; const date = document.createElement('div'); date.className = 'iwmo-admin-date'; date.textContent = new Date(item.created_at).toLocaleString(); const actions = document.createElement('div'); actions.className = 'iwmo-admin-actions'; const approve = document.createElement('button'); approve.className = 'iwmo-approve'; approve.textContent = 'APPROVE'; const deny = document.createElement('button'); deny.className = 'iwmo-deny'; deny.textContent = 'DENY'; approve.addEventListener( 'click', function() { reviewSubmission( item.id, true, card, approve, deny ); } ); deny.addEventListener( 'click', function() { reviewSubmission( item.id, false, card, approve, deny ); } ); actions.appendChild(approve); actions.appendChild(deny); card.appendChild(answer); card.appendChild(date); card.appendChild(actions); list.appendChild(card); }); } catch (error) { console.error(error); list.innerHTML = '
Could not load submissions.
'; } } /* ---------------- VOTE ACTIVITY ---------------- */ async function loadVotes() { voteList.innerHTML = '
Loading votes...
'; try { const response = await fetch( SUPABASE_URL + '/rest/v1/rpc/get_vote_summary', { method: 'POST', headers: { 'apikey': API_KEY, 'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json' } } ); if (!response.ok) { throw new Error('Could not load votes'); } const votes = await response.json(); voteList.innerHTML = ''; if (votes.length === 0) { voteList.innerHTML = '
No votes yet.
'; return; } votes.forEach(function(item) { const card = document.createElement('div'); card.className = 'iwmo-vote-card'; const answer = document.createElement('div'); answer.className = 'iwmo-vote-answer'; answer.textContent = 'I Want My Own ' + item.answer; const stats = document.createElement('div'); stats.className = 'iwmo-vote-stats'; stats.textContent = '👍 ' + item.thumbs_up + ' 👎 ' + item.thumbs_down + ' NET ' + (item.net_votes > 0 ? '+' : '') + item.net_votes; card.appendChild(answer); card.appendChild(stats); voteList.appendChild(card); }); } catch (error) { console.error(error); voteList.innerHTML = '
Could not load votes.
'; } } /* ---------------- SUBSCRIBERS ---------------- */ async function loadSubscribers() { subscriberList.innerHTML = '
Loading subscribers...
'; try { const response = await fetch( SUPABASE_URL + '/rest/v1/subscribers?select=email,created_at,submission_id,Submissions(answer)&order=created_at.desc', { headers: { 'apikey': API_KEY, 'Authorization': 'Bearer ' + accessToken } } ); if (!response.ok) { throw new Error('Could not load subscribers'); } const subscribers = await response.json(); subscriberList.innerHTML = ''; if (subscribers.length === 0) { subscriberList.innerHTML = '
No subscribers yet.
'; return; } subscribers.forEach(function(item) { const card = document.createElement('div'); card.className = 'iwmo-subscriber-card'; const email = document.createElement('div'); email.className = 'iwmo-subscriber-email'; email.textContent = item.email; const want = document.createElement('div'); want.className = 'iwmo-subscriber-want'; want.textContent = item.Submissions && item.Submissions.answer ? 'I Want My Own ' + item.Submissions.answer : 'Submission #' + item.submission_id; const date = document.createElement('div'); date.className = 'iwmo-subscriber-date'; date.textContent = new Date(item.created_at).toLocaleDateString(); card.appendChild(email); card.appendChild(want); card.appendChild(date); subscriberList.appendChild(card); }); } catch (error) { console.error(error); subscriberList.innerHTML = '
Could not load subscribers.
'; } } /* ---------------- APPROVE / DENY ---------------- */ async function reviewSubmission( id, approved, card, approveButton, denyButton ) { approveButton.disabled = true; denyButton.disabled = true; try { const response = await fetch( SUPABASE_URL + '/rest/v1/Submissions?id=eq.' + encodeURIComponent(id), { method: 'PATCH', headers: { 'apikey': API_KEY, 'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json', 'Prefer': 'return=minimal' }, body: JSON.stringify({ approved: approved, reviewed: true }) } ); if (!response.ok) { throw new Error( 'Could not update submission' ); } card.remove(); if ( list.querySelectorAll( '.iwmo-admin-card' ).length === 0 ) { list.innerHTML = '
All caught up.
'; } } catch (error) { console.error(error); approveButton.disabled = false; denyButton.disabled = false; alert( 'Something went wrong. Try again.' ); } } /* ---------------- LOG OUT ---------------- */ document .getElementById('iwmo-logout') .addEventListener('click', function() { accessToken = null; sessionStorage.removeItem( 'iwmo_admin_token' ); dashboard.style.display = 'none'; loginArea.style.display = 'block'; document.getElementById( 'iwmo-password' ).value = ''; loginMessage.textContent = ''; }); /* ---------------- EXISTING SESSION ---------------- */ const savedToken = sessionStorage.getItem( 'iwmo_admin_token' ); if (savedToken) { accessToken = savedToken; loginArea.style.display = 'none'; dashboard.style.display = 'block'; await loadSubmissions(); await loadVotes(); await loadSubscribers(); } })();