Skip to content

Commit 946a403

Browse files
authored
Merge pull request #9 from devyanijain/devyanijain-fix-dot-submission-persistence
Fix dot submissions: restore auth, add public feedback, auto-populate from inbox
2 parents 078ab8c + 9cfff12 commit 946a403

1 file changed

Lines changed: 71 additions & 2 deletions

File tree

index.html

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ <h3 class="h3">This art inspiration</h3>
493493
];
494494

495495
const allDots = [...topDots, ...bottomDots];
496-
const submittedDots = allDots.filter(d => d.s);
496+
const submittedDots = [];
497497
let viewIndex = 0;
498498

499499
/* ────────────────────────────────────────────────
@@ -524,6 +524,7 @@ <h3 class="h3">This art inspiration</h3>
524524

525525
renderDots('topContent', topDots);
526526
renderDots('bottomContent', bottomDots);
527+
loadSubmittedDots();
527528

528529
/* ────────────────────────────────────────────────
529530
DOT TOOLTIP
@@ -866,6 +867,10 @@ <h3 class="h3">This art inspiration</h3>
866867
| **Role** | ${pub.r} |
867868
| **Relationship** | ${pub.rel} |
868869
870+
### 💬 Public feedback
871+
872+
${pub.t || '_Not provided_'}
873+
869874
---
870875
871876
### 🔒 Private (only you can see this)
@@ -882,7 +887,7 @@ <h3 class="h3">This art inspiration</h3>
882887
fetch('https://api.github.com/repos/devyanijain/golden-seeds-inbox/issues', {
883888
method: 'POST',
884889
headers: {
885-
'Authorization': `Bearer ${_tk}`,
890+
'Authorization': `token ${_tk}`,
886891
'Accept': 'application/vnd.github+json',
887892
'Content-Type': 'application/json',
888893
'X-GitHub-Api-Version': '2022-11-28',
@@ -950,6 +955,70 @@ <h3 class="h3">This art inspiration</h3>
950955
document.getElementById('dotSearchInput').addEventListener('input', e => {
951956
searchHighlight(e.target.value);
952957
});
958+
959+
/* ────────────────────────────────────────────────
960+
LOAD SUBMITTED DOTS FROM INBOX (on every page load)
961+
Fetches the golden-seeds-inbox issues, parses each
962+
submission, and hydrates the matching dot in the DOM
963+
so all visitors see everyone who has planted a dot.
964+
──────────────────────────────────────────────── */
965+
async function loadSubmittedDots() {
966+
const _tk = ['github_pat_11BEMBZSI0', 'xGZz9ithbmbx_JrCKA9jD9NQG1kZCeQ7',
967+
'YFnCR2EU6MCLff1G82crALpeFVOAZ5GH3iSHrRl1'].join('');
968+
try {
969+
const res = await fetch(
970+
'https://api.github.com/repos/devyanijain/golden-seeds-inbox/issues?state=open&per_page=100&sort=created&direction=asc',
971+
{ headers: { 'Authorization': `token ${_tk}`, 'Accept': 'application/vnd.github+json' } }
972+
);
973+
if (!res.ok) return;
974+
const issues = await res.json();
975+
976+
// Build per-color queues of unsubmitted dots (preserves array order)
977+
const queues = {};
978+
for (const dot of allDots) {
979+
if (dot.s) continue;
980+
if (!queues[dot.c]) queues[dot.c] = [];
981+
queues[dot.c].push(dot);
982+
}
983+
984+
for (const issue of issues) {
985+
if (issue.title?.startsWith('[Test]')) continue;
986+
const body = issue.body || '';
987+
const nameMatch = body.match(/\|\s*\*\*Name\*\*\s*\|\s*(.+?)\s*\|/);
988+
const roleMatch = body.match(/\|\s*\*\*Role\*\*\s*\|\s*(.+?)\s*\|/);
989+
const relMatch = body.match(/\|\s*\*\*Relationship\*\*\s*\|\s*(.+?)\s*\|/);
990+
const feedMatch = body.match(/### 💬 Public feedback\n\n([\s\S]*?)\n\n---/);
991+
992+
if (!nameMatch || !relMatch) continue;
993+
const name = nameMatch[1].trim();
994+
if (name === 'Anonymous') continue;
995+
996+
const role = roleMatch ? roleMatch[1].trim() : '—';
997+
const rel = relMatch[1].trim();
998+
const feed = (feedMatch?.[1] || '').replace(/^_Not provided_$/, '').trim();
999+
const color = REL_COLOR[rel];
1000+
1001+
if (!color || !queues[color]?.length) continue;
1002+
const dot = queues[color].shift();
1003+
dot.s = true;
1004+
dot.f = { n: name, r: role, rel, t: feed };
1005+
submittedDots.push(dot);
1006+
1007+
// Hydrate the already-rendered dot element
1008+
const el = document.getElementById('dot-' + dot.id);
1009+
if (el) {
1010+
el.classList.add('dot--submitted');
1011+
el.disabled = false;
1012+
el.removeAttribute('aria-hidden');
1013+
el.tabIndex = 0;
1014+
el.setAttribute('aria-label', `View feedback from ${dot.f.n}`);
1015+
el.addEventListener('click', () => showFeedback(dot, el));
1016+
el.addEventListener('mouseenter', () => showTooltip(dot, el));
1017+
el.addEventListener('mouseleave', hideTooltip);
1018+
}
1019+
}
1020+
} catch (_) { /* silent — never break the page */ }
1021+
}
9531022
</script>
9541023

9551024
</body>

0 commit comments

Comments
 (0)