What Do You Want?

I Want My Own _____.
nice.

want to stay connected? get in

What the people want:
Loading what the people want...
(async function () { /* ===================================== SUPABASE CONFIGURATION ===================================== */ 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 COUNTS_URL = SUPABASE_URL + '/rest/v1/rpc/get_heart_counts'; const VOTE_URL = SUPABASE_URL + '/rest/v1/rpc/toggle_vote'; const container = document.getElementById('iwmo-wants'); if (!container) return; const headers = { 'apikey': API_KEY, 'Authorization': 'Bearer ' + API_KEY }; /* ===================================== ANONYMOUS VOTER ===================================== */ let voterId = localStorage.getItem('iwmo_voter_id'); if (!voterId) { voterId = crypto.randomUUID(); localStorage.setItem('iwmo_voter_id', voterId); } /* ===================================== SAVED HEART STATES ===================================== */ let savedVotes = {}; try { savedVotes = JSON.parse( localStorage.getItem('iwmo_votes') ) || {}; } catch { savedVotes = {}; } function saveVotes() { localStorage.setItem( 'iwmo_votes', JSON.stringify(savedVotes) ); } /* ===================================== HEART COUNTS ===================================== */ let heartCounts = {}; let countsAvailable = false; async function fetchHeartCounts() { const response = await fetch(COUNTS_URL, { method: 'POST', headers: { ...headers, 'Content-Type': 'application/json' }, body: '{}', cache: 'no-store' }); if (!response.ok) { throw new Error( 'Heart counts failed: ' + response.status + ' ' + await response.text() ); } const rows = await response.json(); if (!Array.isArray(rows)) { throw new Error( 'Unexpected heart count response' ); } const nextCounts = {}; rows.forEach(row => { const count = Number(row.heart_count); if ( Number.isSafeInteger(count) && count >= 0 ) { nextCounts[row.submission_id] = count; } }); heartCounts = nextCounts; countsAvailable = true; updateDisplayedCounts(); } function updateDisplayedCounts() { container.querySelectorAll( '.iwmo-heart-count' ).forEach(element => { const id = element.dataset.submissionId; element.textContent = countsAvailable ? String(heartCounts[id] ?? 0) : '—'; }); const errorMessage = container.querySelector('.iwmo-count-error'); if (errorMessage) { errorMessage.style.display = countsAvailable ? 'none' : 'block'; } } /* ===================================== LIKE OR UNLIKE A WANT ===================================== */ async function toggleVote(submissionId, heartButton) { if (heartButton.disabled) return; heartButton.disabled = true; try { const response = await fetch(VOTE_URL, { method: 'POST', headers: { ...headers, 'Content-Type': 'application/json' }, body: JSON.stringify({ p_submission_id: submissionId, p_voter_id: voterId, p_vote: 1 }) }); if (!response.ok) { throw new Error( 'Like failed: ' + await response.text() ); } /* UPDATE HEART STATE */ if (savedVotes[submissionId] === 1) { delete savedVotes[submissionId]; } else { savedVotes[submissionId] = 1; } saveVotes(); const liked = savedVotes[submissionId] === 1; heartButton.classList.toggle( 'active', liked ); heartButton.textContent = liked ? '♥' : '♡'; heartButton.setAttribute( 'aria-pressed', String(liked) ); /* REFRESH ACTUAL COUNTS */ try { await fetchHeartCounts(); } catch (countError) { console.error( 'Heart count refresh failed:', countError ); countsAvailable = false; updateDisplayedCounts(); } } catch (error) { console.error('Like failed:', error); } finally { heartButton.disabled = false; } } /* ===================================== LOAD APPROVED SUBMISSIONS ===================================== */ try { const response = await fetch( SUBMISSIONS_URL, { headers } ); if (!response.ok) { throw new Error( 'Could not load submissions' ); } const submissions = await response.json(); /* LOAD COUNTS INDEPENDENTLY */ try { await fetchHeartCounts(); } catch (countError) { countsAvailable = false; console.error( 'Could not load heart counts:', countError ); } container.innerHTML = ''; if (submissions.length === 0) { container.innerHTML = '
' + 'Nothing here yet.' + '
'; return; } /* ===================================== RENDER EACH WANT ===================================== */ submissions.forEach(item => { const entry = document.createElement('div'); entry.className = 'iwmo-want'; let answer = String(item.answer || '').trim(); /* REMOVE DUPLICATED PREFIX */ 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; /* ===================================== HEART CONTROL ===================================== */ const votes = document.createElement('div'); votes.className = 'iwmo-votes'; const heartButton = document.createElement('button'); heartButton.className = 'iwmo-vote'; heartButton.type = 'button'; heartButton.setAttribute( 'aria-label', 'Like this want' ); const liked = savedVotes[item.id] === 1; heartButton.classList.toggle( 'active', liked ); heartButton.textContent = liked ? '♥' : '♡'; heartButton.setAttribute( 'aria-pressed', String(liked) ); heartButton.addEventListener( 'click', function () { toggleVote(item.id, heartButton); } ); /* ===================================== HEART COUNT ===================================== */ const count = document.createElement('span'); count.className = 'iwmo-heart-count'; count.dataset.submissionId = String(item.id); count.textContent = countsAvailable ? String(heartCounts[item.id] ?? 0) : '—'; count.setAttribute( 'aria-label', 'Number of likes' ); /* ASSEMBLE WANT */ votes.appendChild(heartButton); votes.appendChild(count); entry.appendChild(prefix); entry.appendChild(answerText); entry.appendChild(votes); container.appendChild(entry); }); /* COUNT ERROR MESSAGE */ const countError = document.createElement('div'); countError.className = 'iwmo-count-error'; countError.textContent = 'Heart counts temporarily unavailable.'; countError.style.display = countsAvailable ? 'none' : 'block'; container.appendChild(countError); } catch (error) { console.error( 'WANTS wall failed:', error ); container.innerHTML = '
' + 'Could not load wants. ' + 'Please refresh and try again.' + '
'; } })();
(function () { /* ===================================== INITIALIZATION ===================================== */ function initialize() { const sticky = document.getElementById("iwmo-sticky"); const home = document.getElementById("iwmo-home"); const form = document.getElementById("iwmo-sticky-form"); const input = document.getElementById("iwmo-sticky-input"); const submit = document.getElementById("iwmo-sticky-submit"); const error = document.getElementById("iwmo-sticky-error"); const closeButton = document.getElementById("iwmo-sticky-close"); if (![ sticky, home, form, input, submit, error, closeButton ].every(Boolean)) { console.error( "IWMO sticky: Required element missing." ); return; } if (sticky.dataset.ready === "yes") return; sticky.dataset.ready = "yes"; /* ===================================== STATE ===================================== */ let pending = false; let dismissed = false; let answered = false; let ticking = false; /* ===================================== VISIBILITY CONTROL ===================================== */ function updateSticky() { const page = window.location.hash .replace("#", "") .toLowerCase(); const onShop = page === "shop"; const rect = home.getBoundingClientRect(); /* RE-ARM AFTER RETURNING TO HOMEPAGE */ if (rect.bottom >= 70) { dismissed = false; } /* HAS THIS VISITOR ALREADY ANSWERED? */ let alreadyParticipated = false; try { alreadyParticipated = sessionStorage.getItem( "iwmo_has_participated" ) === "yes"; } catch { alreadyParticipated = false; } /* DECIDE WHETHER TO SHOW THE PROMPT */ const shouldShow = !onShop && !dismissed && !answered && !alreadyParticipated && !pending && rect.bottom < 70; sticky.classList.toggle( "visible", shouldShow ); sticky.setAttribute( "aria-hidden", String(!shouldShow) ); if ( !shouldShow && sticky.contains(document.activeElement) ) { document.activeElement.blur(); } ticking = false; } /* OPTIMIZED SCROLL LISTENER */ function onScroll() { if (ticking) return; ticking = true; requestAnimationFrame(updateSticky); } /* ===================================== CLOSE BUTTON ===================================== */ closeButton.addEventListener( "click", function () { dismissed = true; sticky.classList.remove("visible"); sticky.setAttribute("aria-hidden", "true"); if (sticky.contains(document.activeElement)) { document.activeElement.blur(); } form.reset(); error.textContent = ""; error.style.display = "none"; } ); /* ===================================== SUBMIT WANT ===================================== */ form.addEventListener( "submit", async function (event) { event.preventDefault(); if (pending) return; const rawAnswer = input.value.trim(); const displayAnswer = rawAnswer .replace( /^i\s+want\s+my\s+own\b[\s:,-]*/i, "" ) .replace(/[.!?]+$/, "") .trim(); if (!displayAnswer) { error.textContent = "PLEASE ENTER YOUR WANT."; error.style.display = "block"; return; } /* VERIFY HOMEPAGE SUBMISSION HANDLER */ if ( !window.IWMOHomepage || typeof window.IWMOHomepage.submitWant !== "function" ) { error.textContent = "SOMETHING WENT WRONG. PLEASE REFRESH."; error.style.display = "block"; return; } pending = true; error.textContent = ""; error.style.display = "none"; submit.disabled = true; submit.textContent = "..."; try { /* * ONE SHARED SUBMISSION HANDLER * Saves want and displays homepage * confirmation automatically. */ await window.IWMOHomepage.submitWant( rawAnswer ); /* HIDE PROMPT AFTER SUCCESS */ dismissed = true; answered = true; form.reset(); sticky.classList.remove("visible"); sticky.setAttribute("aria-hidden", "true"); if (sticky.contains(document.activeElement)) { document.activeElement.blur(); } /* SCROLL TO HOMEPAGE CONFIRMATION */ const reducedMotion = window.matchMedia( "(prefers-reduced-motion: reduce)" ).matches; window.scrollTo({ top: 0, behavior: reducedMotion ? "auto" : "smooth" }); } catch (err) { console.error( "IWMO sticky submission:", err ); error.textContent = err.message === "PLEASE ENTER YOUR WANT." ? err.message : "SOMETHING WENT WRONG. TRY AGAIN."; error.style.display = "block"; } finally { pending = false; submit.disabled = false; submit.textContent = "SUBMIT"; } } ); /* ===================================== EVENT LISTENERS ===================================== */ window.addEventListener( "scroll", onScroll, { passive: true } ); window.addEventListener( "resize", onScroll ); window.addEventListener( "hashchange", updateSticky ); updateSticky(); } /* ===================================== START WHEN PAGE IS READY ===================================== */ if (document.readyState === "loading") { document.addEventListener( "DOMContentLoaded", initialize, { once: true } ); } else { initialize(); } })();
(function () { function initialize() { const button = document.getElementById('iwmo-back-to-top'); if (!button) return; function updateVisibility() { button.classList.toggle( 'visible', window.scrollY > 400 ); } button.addEventListener('click', function () { window.scrollTo({ top: 0, behavior: window.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ? 'instant' : 'smooth' }); }); window.addEventListener( 'scroll', updateVisibility, { passive: true } ); updateVisibility(); } if (document.readyState === 'loading') { document.addEventListener( 'DOMContentLoaded', initialize, { once: true } ); } else { initialize(); } })();

Maybe We're Here To Decide.

Hi there. I see you've been clicking around where you weren't supposed to. Welcome.

IWMO mad scientist laboratory
×
(function () { const lab = document.getElementById('iwmo-lab-view'); const image = document.querySelector('#iwmo-lab-room img'); const swipeHint = document.getElementById('iwmo-lab-swipe-hint'); let swipeStartX = null; lab?.addEventListener('touchstart', function (e) { swipeStartX = e.touches[0].clientX; }, { passive: true }); lab?.addEventListener('touchmove', function (e) { if (swipeStartX === null) return; const distance = Math.abs(e.touches[0].clientX - swipeStartX); if (distance > 25) { swipeHint?.classList.add('iwmo-hint-hidden'); } }, { passive: true }); lab?.addEventListener('touchend', function () { swipeStartX = null; }, { passive: true }); if (!lab || !image) return; function centerLab() { if (window.innerWidth <= 768) { lab.scrollLeft = (lab.scrollWidth - lab.clientWidth) * 0.43; } } function updateLab() { const isLab = window.location.hash === '#lab'; lab.style.display = isLab ? 'block' : 'none'; if (isLab) { requestAnimationFrame(centerLab); } } image.addEventListener('load', centerLab); window.addEventListener('hashchange', updateLab); window.addEventListener('resize', centerLab); updateLab(); const drawHotspot = document.getElementById('iwmo-draw-hotspot'); drawHotspot?.addEventListener('click', function () { window.location.hash = '#draw'; }); const notebookHotspot = document.getElementById('iwmo-notebook-hotspot'); notebookHotspot?.addEventListener('click', function () { document.dispatchEvent( new CustomEvent('iwmo:open-notebook') ); }); const bonsaiHotspot = document.getElementById('iwmo-bonsai-hotspot'); bonsaiHotspot?.addEventListener('click', function () { document.dispatchEvent( new CustomEvent('iwmo:open-vortex') ); }); })();
(function () { 'use strict'; var experiments = [ ['THE CURRENT WEATHER APP', 'Only tells you the weather RIGHT NOW. Only works outside.'], ['BUM WIPER 9000', "A toilet that wipes your butt for you. Never wash your hands again. Maybe gives you a little spank too."], ['THE JUDGMENT MACHINE', 'A weight-loss machine that watches you eat and judges you. May also be you mother-in-law,'], ['SELF-SERVICE RESTAURANT', 'A restaurant where you cook your own food, serve your own food, buss your own table and wash your own dishes.'], ['INVINCIBLE SOCKS', 'Socks that never get holes, no matter what.'], ['ANIMAL VISION GOGGLES', 'Glasses that let you see everyone’s favorite animal. '], ['THE SELF-TYING NECKTIE', "A necktie that ties itself, so people don't know you can't tie a tie when you wear a clip on."], ['THE SAIL CAR', 'A car with no gas or engine. Just wheels and a giant sail.'], ]; function setup() { var overlay = document.getElementById('iwmo-notebook-overlay'); var close = document.getElementById('iwmo-notebook-close'); var left = document.getElementById('iwmo-idea-left'); var right = document.getElementById('iwmo-idea-right'); var prev = document.getElementById('iwmo-prev-page'); var next = document.getElementById('iwmo-next-page'); var counter = document.getElementById('iwmo-notebook-counter'); var book = document.getElementById('iwmo-book'); if (!overlay || !close || !left || !right || !prev || !next || !counter || !book) { console.error('IWMO Notebook: Required HTML element missing'); return false; } if (overlay.dataset.iwmoEightReady === 'yes') return true; overlay.dataset.iwmoEightReady = 'yes'; document.body.appendChild(overlay); var spread = 0; var busy = false; function add(parent, cls, txt) { var node = document.createElement('div'); node.className = cls; node.textContent = txt; parent.appendChild(node); } function fill(target, data) { target.replaceChildren(); var wrap = document.createElement('div'); wrap.className = 'iwmo-idea'; add(wrap, 'iwmo-idea-text', data[0]); add(wrap, 'iwmo-idea-note', data[1]); target.appendChild(wrap); } function render() { fill(left, experiments[spread * 2]); fill(right, experiments[spread * 2 + 1]); var leftNum = document.getElementById('iwmo-page-left-num'); var rightNum = document.getElementById('iwmo-page-right-num'); if (leftNum) leftNum.textContent = String(spread * 2 + 1).padStart(2,'0'); if (rightNum) rightNum.textContent = String(spread * 2 + 2).padStart(2,'0'); counter.textContent = (spread + 1) + ' / 4'; prev.disabled = spread === 0; next.disabled = spread === 3; } function flip(step) { if (busy || spread + step < 0 || spread + step > 3) return; busy = true; var cls = step > 0 ? 'turn-next' : 'turn-prev'; book.classList.add(cls); window.setTimeout(function () { spread += step; render(); book.classList.remove(cls); busy = false; }, 900); } function closeBook() { overlay.classList.remove('open'); overlay.setAttribute('aria-hidden','true'); } function openBook() { spread = 0; render(); overlay.classList.add('open'); overlay.setAttribute('aria-hidden','false'); close.focus(); } document.addEventListener('iwmo:open-notebook',openBook); close.addEventListener('click',closeBook); prev.addEventListener('click',function () { flip(-1); }); next.addEventListener('click',function () { flip(1); }); overlay.addEventListener('click',function (ev) { if (ev.target === overlay) closeBook(); }); document.addEventListener('keydown',function (ev) { if (!overlay.classList.contains('open')) return; if (ev.key === 'Escape') closeBook(); if (ev.key === 'ArrowRight') flip(1); if (ev.key === 'ArrowLeft') flip(-1); }); window.addEventListener('hashchange',function () { if (window.location.hash !== '#lab') closeBook(); }); render(); console.log('IWMO BAD IDEAS: simplified notebook ready'); return true; } if (!setup()) { document.addEventListener('DOMContentLoaded',setup,{once:true}); window.addEventListener('load',setup,{once:true}); } })();

I Want My Own Stuff

It's in the works.

IWMO black shirt front and back
I WANT MY OWN SHIRT
IN THE WORKS.

nice.

Want to know when it's available?

Original IWMO sticker designs
IWMO STICKERS
IN THE WORKS.

nice.

Want to know when it's available?

(function () { const endpoint = "https://dvgrawagdqbucdezdmsa.supabase.co/functions/v1/shop-interest"; const shop = document.getElementById("iwmo-shop"); if (!shop || shop.dataset.initialized === "true") return; shop.dataset.initialized = "true"; function getVisitorId() { let id = localStorage.getItem("iwmo_shop_visitor"); if (!id) { id = crypto.randomUUID(); localStorage.setItem("iwmo_shop_visitor", id); } return id; } shop.querySelectorAll(".product").forEach(product => { const want = product.querySelector(".want"); const panel = product.querySelector(".notify-panel"); const form = product.querySelector(".notify-form"); const skip = product.querySelector(".notify-skip"); const message = product.querySelector(".notify-message"); want.addEventListener("click", async () => { want.disabled = true; try { const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ product_id: product.dataset.product, visitor_id: getVisitorId() }) }); const result = await response.json(); if (!response.ok || !result.success) { throw new Error("Unable to record interest"); } want.style.display = "none"; panel.style.display = "block"; message.textContent = ""; } catch (error) { message.textContent = ""; alert("Something went wrong. Please try again."); } finally { want.disabled = false; } }); skip.addEventListener("click", () => { panel.style.display = "none"; want.style.display = "block"; }); form.addEventListener("submit", async (event) => { event.preventDefault(); const emailInput = form.querySelector(".notify-email"); const submitButton = form.querySelector(".notify-submit"); const email = emailInput.value.trim(); if (!emailInput.checkValidity()) { emailInput.reportValidity(); return; } submitButton.disabled = true; submitButton.textContent = "SAVING..."; message.textContent = ""; try { const response = await fetch( "https://dvgrawagdqbucdezdmsa.supabase.co/functions/v1/shop-notify", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ product_id: product.dataset.product, email: email }) } ); const result = await response.json(); if (!response.ok || !result.success) { throw new Error("Unable to save notification"); } form.style.display = "none"; skip.style.display = "none"; message.textContent = result.already_registered ? "You're already on the list." : "You're on the list."; } catch (error) { message.textContent = "Something went wrong. Please try again."; } finally { submitButton.disabled = false; submitButton.textContent = "NOTIFY ME →"; } }); }); })();

Maybe We're Here To Decide.

IWMO ADMIN

Sign in to continue

(function(){ const BASE='https://dvgrawagdqbucdezdmsa.supabase.co'; const KEY='sb_publishable_485DEPFQhcbPuRSSczN9TQ_1HGDCpYn'; const STORE='iwmo_admin_token'; const root=document.getElementById('iwmo-admin-root'); if(!root||root.dataset.ready==='yes')return; root.dataset.ready='yes'; const $=id=>root.querySelector('#'+id); let token=null; function headers(auth=false){ return { apikey:KEY, Authorization:'Bearer '+(auth?token:KEY) }; } async function request(path,options={}){ const response=await fetch(BASE+path,options); if(!response.ok){ const error=new Error('Request failed: '+response.status); error.status=response.status; console.error('IWMO request:',path,response.status); throw error; } if(response.status===204)return null; return response.json(); } function line(parent,cls,text){ const node=document.createElement('div'); node.className=cls; node.textContent=text; parent.appendChild(node); return node; } function note(parent,text,error=false){ parent.replaceChildren(); line(parent,'ia-note'+(error?' ia-error':''),text); } function date(value){ if(!value)return ''; const d=new Date(value); return Number.isNaN(d.getTime())?'':d.toLocaleString(); } function card(parent){ const node=document.createElement('div'); node.className='ia-card'; parent.appendChild(node); return node; } function login(message=''){ token=null; try{sessionStorage.removeItem(STORE)}catch(e){} $('ia-login').hidden=false; $('ia-dashboard').hidden=true; $('ia-password').value=''; $('ia-message').textContent=message; } function dashboard(){ $('ia-login').hidden=true; $('ia-dashboard').hidden=false; $('ia-password').value=''; $('ia-hearts-section').open=false; $('ia-subs-section').open=false; pending(); hearts(); subscribers(); } $('ia-form').addEventListener('submit',async function(event){ event.preventDefault(); const email=$('ia-email').value.trim(); const password=$('ia-password').value; if(!email||!password){ $('ia-message').textContent='Enter your email and password.'; return; } $('ia-signin').disabled=true; $('ia-message').textContent='Signing in...'; try{ const data=await request('/auth/v1/token?grant_type=password',{ method:'POST', headers:{apikey:KEY,'Content-Type':'application/json'}, body:JSON.stringify({email,password}) }); if(!data.access_token)throw new Error('No access token'); token=data.access_token; try{sessionStorage.setItem(STORE,token)}catch(e){} $('ia-message').textContent=''; dashboard(); }catch(error){ $('ia-message').textContent=error.status===400 ?'Could not sign in. Check your email and password.' :error.status===429 ?'Too many attempts. Wait a moment and try again.' :'Could not connect to sign in. Please try again.'; }finally{ $('ia-signin').disabled=false; } }); async function pending(){ const list=$('ia-pending'); note(list,'Loading submissions...'); try{ const rows=await request( '/rest/v1/Submissions?select=id,answer,created_at'+ '&approved=eq.false&reviewed=eq.false&order=created_at.desc', {headers:headers(true)} ); $('ia-pending-count').textContent='('+rows.length+')'; list.replaceChildren(); if(!rows.length){ note(list,'All caught up.'); return; } rows.forEach(item=>{ const box=card(list); line(box,'ia-answer',item.answer||''); line(box,'ia-date',date(item.created_at)); const actions=line(box,'ia-actions',''); const approve=document.createElement('button'); approve.type='button'; approve.textContent='APPROVE'; const deny=document.createElement('button'); deny.type='button'; deny.textContent='DENY'; deny.className='ia-secondary'; actions.append(approve,deny); approve.addEventListener('click',()=>review(item.id,true,approve,deny)); deny.addEventListener('click',()=>review(item.id,false,approve,deny)); }); }catch(error){ $('ia-pending-count').textContent=''; note(list,'Could not load submissions. Try logging out and signing in again.',true); } } async function review(id,approved,a,b){ a.disabled=true; b.disabled=true; try{ const response=await fetch( BASE+'/rest/v1/Submissions?id=eq.'+encodeURIComponent(id), { method:'PATCH', headers:{ ...headers(true), 'Content-Type':'application/json', Prefer:'return=minimal' }, body:JSON.stringify({approved,reviewed:true}) } ); if(!response.ok)throw new Error('Review failed'); await pending(); hearts(); }catch(error){ a.disabled=false; b.disabled=false; window.alert('Could not save that review. Please try again.'); } } async function hearts(){ const list=$('ia-hearts'); note(list,'Loading hearts...'); try{ const [wants,counts]=await Promise.all([ request( '/rest/v1/Submissions?select=id,answer'+ '&approved=eq.true&order=created_at.desc', {headers:headers()} ), request('/rest/v1/rpc/get_heart_counts',{ method:'POST', headers:{...headers(),'Content-Type':'application/json'}, body:'{}', cache:'no-store' }) ]); if(!Array.isArray(wants)||!Array.isArray(counts)){ throw new Error('Unexpected heart data'); } const totals=new Map(counts.map(row=>[ String(row.submission_id),Number(row.heart_count) ])); const rows=wants.map(item=>({ answer:item.answer||'', hearts:totals.get(String(item.id))||0 })).sort((a,b)=>b.hearts-a.hearts); const total=rows.reduce((sum,row)=>sum+row.hearts,0); $('ia-heart-count').textContent='('+total+' total)'; list.replaceChildren(); if(!rows.length){ note(list,'No approved wants yet.'); return; } rows.forEach(row=>{ const box=card(list); const answer=String(row.answer).replace(/^i\s+want\s+my\s+own\s*/i,''); line(box,'ia-answer','I Want My Own '+answer); line(box,'ia-heart','♥ '+row.hearts); }); }catch(error){ $('ia-heart-count').textContent=''; note(list,'Could not load hearts. Close and reopen this section to retry.',true); } } async function subscribers(){ const list=$('ia-subs'); note(list,'Loading subscribers...'); try{ const rows=await request( '/rest/v1/subscribers'+ '?select=email,created_at,submission_id,Submissions(answer)&order=created_at.desc', {headers:headers(true)} ); $('ia-sub-count').textContent='('+rows.length+')'; list.replaceChildren(); if(!rows.length){ note(list,'No subscribers yet.'); return; } rows.forEach(item=>{ const box=card(list); line(box,'ia-answer',item.email||''); let want='No linked submission'; if(item.Submissions&&item.Submissions.answer){ want='I Want My Own '+item.Submissions.answer; }else if(item.submission_id!=null){ want='Submission #'+item.submission_id; } line(box,'ia-want',want); line(box,'ia-date',date(item.created_at)); }); }catch(error){ $('ia-sub-count').textContent=''; note(list,'Could not load subscribers. Try logging out and signing in again.',true); } } $('ia-hearts-section').addEventListener('toggle',function(){ if(this.open&&token)hearts(); }); $('ia-subs-section').addEventListener('toggle',function(){ if(this.open&&token)subscribers(); }); $('ia-logout').addEventListener('click',()=>login()); async function restore(){ let saved=null; try{saved=sessionStorage.getItem(STORE)}catch(e){} if(!saved)return; try{ await request('/auth/v1/user',{ headers:{apikey:KEY,Authorization:'Bearer '+saved} }); token=saved; dashboard(); }catch(error){ login('Your session expired. Please sign in again.'); } } restore(); })();