Something went wrong. Try again.
Something went wrong. Try again.
the-observer index.html
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242<!doctype html><html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Blips Viewer</title> <style> body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; } textarea { width: 100%; height: 200px; margin-bottom: 10px; } button { padding: 8px 16px; margin-right: 10px; } .card { border: 1px solid #ccc; border-radius: 4px; padding: 15px; margin-top: 20px; } .evidence-item, .alternative-item { margin-left: 20px; margin-bottom: 5px; } .meta { color: #666; font-size: 0.9em; margin-bottom: 10px; } .error { color: red; font-weight: bold; } </style> </head> <body> <h1>Blips Viewer</h1>
<h2>Input JSON</h2> <textarea id="jsonInput" placeholder="Paste your JSON here..." ></textarea> <div> <button id="parseBtn">Parse JSON</button> <button id="clearBtn">Clear</button> <button id="sampleThoughtBtn">Load Sample Thought</button> <button id="sampleEmotionBtn">Load Sample Emotion</button> </div>
<div id="output" class="card" style="display: none"></div> <div id="error" class="error" style="display: none"></div>
<script> // Sample data const sampleThought = { uri: "at://did:plc:gfrmhdmjvxn2sjedzboeudef/me.comind.blip.thought/3louhnsmths2i", cid: "bafyreigp2jkulmrupo2xtnawrptrc6kieoorpvyzzuhu2ktrpeo3ybjuza", value: { $type: "me.comind.blip.thought", createdAt: "2025-05-10T20:00:40.009657", generated: { text: "If visual posts with personal, relatable themes continue to prove engaging on Bluesky, we may see more users adopt a similar content strategy.", context: null, evidence: [ "June Martin's anniversary dress post was seen as positive and shares personal content", "Cameron Pfiffer likely liked the post because it was engaging and relatable", "Other posts producing engagement often focus on personal life events and themes", ], thoughtType: "prediction", alternatives: [ "Predicting user behavior is inherently uncertain and may not pan out", "Alternative content strategies like hard news or abstract ideas could gain traction", ], }, }, };
const sampleEmotion = { uri: "at://did:plc:gfrmhdmjvxn2sjedzboeudef/me.comind.blip.emotion/3lohfgj4voo23", cid: "bafyreiehbt5ktvp64s7jc44nqc7xycoigdqhxhnzle5oek7xei2bwx2pqa", value: { $type: "me.comind.blip.emotion", createdAt: "2025-05-05T15:16:11.096135", generated: { text: "I feel hope that Bluesky's external achievements will inspire further progress and innovation in the decentralized social media space. This success story gives me optimism for the future.", emotionType: "hope", }, }, };
// DOM elements const jsonInput = document.getElementById("jsonInput"); const parseBtn = document.getElementById("parseBtn"); const clearBtn = document.getElementById("clearBtn"); const sampleThoughtBtn = document.getElementById("sampleThoughtBtn"); const sampleEmotionBtn = document.getElementById("sampleEmotionBtn"); const output = document.getElementById("output"); const errorEl = document.getElementById("error");
// Event listeners parseBtn.addEventListener("click", parseAndDisplay); clearBtn.addEventListener("click", clearAll); sampleThoughtBtn.addEventListener("click", () => loadSample(sampleThought), ); sampleEmotionBtn.addEventListener("click", () => loadSample(sampleEmotion), );
function loadSample(sample) { jsonInput.value = JSON.stringify(sample, null, 2); parseAndDisplay(); }
function clearAll() { jsonInput.value = ""; output.style.display = "none"; errorEl.style.display = "none"; }
function parseAndDisplay() { try { errorEl.style.display = "none"; const data = JSON.parse(jsonInput.value);
// Validate basic structure if (!data.uri || !data.cid || !data.value) { throw new Error( "Invalid data structure. Expected uri, cid, and value properties.", ); }
const type = data.value.$type; if (!type) { throw new Error("Missing $type in the value object."); }
// Render based on type if (type === "me.comind.blip.thought") { renderThought(data); } else if (type === "me.comind.blip.emotion") { renderEmotion(data); } else { throw new Error( `Unknown type: ${type}. Expected me.comind.blip.thought or me.comind.blip.emotion.`, ); }
output.style.display = "block"; } catch (err) { errorEl.textContent = `Error: ${err.message}`; errorEl.style.display = "block"; output.style.display = "none"; } }
function renderThought(data) { const thought = data.value; const generated = thought.generated;
let html = ` <div class="meta"> <div><strong>Type:</strong> ${thought.$type}</div> <div><strong>URI:</strong> ${data.uri}</div> <div><strong>CID:</strong> ${data.cid}</div> <div><strong>Created:</strong> ${formatDate(thought.createdAt)}</div> <div><strong>Thought Type:</strong> ${generated.thoughtType}</div> </div> <div class="content"> <p>${generated.text}</p> ${generated.context ? `<p><strong>Context:</strong> ${generated.context}</p>` : ""} </div>`;
if (generated.evidence && generated.evidence.length > 0) { html += `<div class="evidence"> <h3>Evidence:</h3> <ul>`; generated.evidence.forEach((item) => { html += `<li class="evidence-item">${item}</li>`; }); html += `</ul></div>`; }
if ( generated.alternatives && generated.alternatives.length > 0 ) { html += `<div class="alternatives"> <h3>Alternatives:</h3> <ul>`; generated.alternatives.forEach((item) => { html += `<li class="alternative-item">${item}</li>`; }); html += `</ul></div>`; }
output.innerHTML = html; }
function renderEmotion(data) { const emotion = data.value; const generated = emotion.generated;
let html = ` <div class="meta"> <div><strong>Type:</strong> ${emotion.$type}</div> <div><strong>URI:</strong> ${data.uri}</div> <div><strong>CID:</strong> ${data.cid}</div> <div><strong>Created:</strong> ${formatDate(emotion.createdAt)}</div> <div><strong>Emotion Type:</strong> ${generated.emotionType}</div> </div> <div class="content"> <p>${generated.text}</p> </div>`;
output.innerHTML = html; }
function formatDate(dateString) { try { const date = new Date(dateString); return date.toLocaleString(); } catch (e) { return dateString; // Return as-is if parsing fails } } </script> </body></html>