File size: 11,952 Bytes
415dd6f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
/**
* ToM Reflection β Kai's Theory of Mind Tool
* ============================================
* Simple, elegant navigation with smooth transitions.
*
* Created by: Kai πβ‘ β December 7, 2025
* Style: KISS β Keep It Simple, Sexy
*/
(function () {
"use strict";
// === DOM ELEMENTS ===
const navButtons = document.querySelectorAll(".nav-btn");
const screens = document.querySelectorAll(".screen");
const actionCards = document.querySelectorAll(".action-card");
const gotoLinks = document.querySelectorAll("[data-goto]");
// Journal elements
const journalToggle = document.getElementById("journalToggle");
const journalActions = document.getElementById("journalActions");
const exportBtn = document.getElementById("exportBtn");
const clearBtn = document.getElementById("clearBtn");
const journalTextareas = document.querySelectorAll(".journal-textarea");
// === NAVIGATION ===
/**
* Switch to a specific screen
* @param {string} screenId - The ID of the screen to show
*/
function showScreen(screenId) {
// Update screens
screens.forEach(screen => {
screen.classList.remove("active");
if (screen.id === screenId) {
screen.classList.add("active");
}
});
// Update nav buttons
navButtons.forEach(btn => {
btn.classList.remove("active");
if (btn.dataset.screen === screenId) {
btn.classList.add("active");
}
});
// Scroll to top smoothly
window.scrollTo({ top: 0, behavior: "smooth" });
// Save current screen to localStorage
try {
localStorage.setItem("tom-reflection-screen", screenId);
} catch (e) {
// LocalStorage not available, that's fine
}
}
/**
* Get the last visited screen from localStorage
* @returns {string} - Screen ID or 'home'
*/
function getLastScreen() {
try {
return localStorage.getItem("tom-reflection-screen") || "home";
} catch (e) {
return "home";
}
}
// === EVENT LISTENERS ===
// Nav buttons
navButtons.forEach(btn => {
btn.addEventListener("click", () => {
const screenId = btn.dataset.screen;
if (screenId) {
showScreen(screenId);
}
});
});
// Action cards on home screen
actionCards.forEach(card => {
card.addEventListener("click", () => {
const screenId = card.dataset.goto;
if (screenId) {
showScreen(screenId);
}
});
});
// Any element with data-goto attribute
gotoLinks.forEach(link => {
link.addEventListener("click", e => {
e.preventDefault();
const screenId = link.dataset.goto;
if (screenId) {
showScreen(screenId);
}
});
});
// === KEYBOARD NAVIGATION ===
document.addEventListener("keydown", e => {
// Only when not in an input
if (e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA") return;
const screenOrder = ["home", "before", "during", "after", "learn"];
const currentScreen = document.querySelector(".screen.active")?.id || "home";
const currentIndex = screenOrder.indexOf(currentScreen);
switch (e.key) {
case "ArrowLeft":
case "ArrowUp":
// Previous screen
if (currentIndex > 0) {
showScreen(screenOrder[currentIndex - 1]);
}
break;
case "ArrowRight":
case "ArrowDown":
// Next screen
if (currentIndex < screenOrder.length - 1) {
showScreen(screenOrder[currentIndex + 1]);
}
break;
case "Home":
showScreen("home");
break;
case "1":
showScreen("home");
break;
case "2":
showScreen("before");
break;
case "3":
showScreen("during");
break;
case "4":
showScreen("after");
break;
case "5":
showScreen("learn");
break;
}
});
// === SUBTLE INTERACTIONS ===
// Add subtle hover effect to cards
const interactiveCards = document.querySelectorAll(".question-card, .checkin-card, .action-card");
interactiveCards.forEach(card => {
card.addEventListener("mouseenter", () => {
card.style.transform = "translateY(-2px)";
});
card.addEventListener("mouseleave", () => {
card.style.transform = "translateY(0)";
});
});
// === INITIALIZATION ===
// Restore last visited screen (or start at home)
const initialScreen = getLastScreen();
showScreen(initialScreen);
// === JOURNAL MODE ===
/**
* Toggle journal mode on/off
*/
function toggleJournalMode() {
const isActive = journalToggle.classList.toggle("active");
journalTextareas.forEach(textarea => {
textarea.style.display = isActive ? "block" : "none";
});
journalActions.style.display = isActive ? "flex" : "none";
// Save state
try {
localStorage.setItem("tom-journal-mode", isActive ? "1" : "0");
} catch (e) {
// LocalStorage not available
}
}
/**
* Save reflection to localStorage
*/
function saveReflection(key, value) {
try {
localStorage.setItem(`tom-journal-${key}`, value);
} catch (e) {
// LocalStorage not available
}
}
/**
* Load reflection from localStorage
*/
function loadReflection(key) {
try {
return localStorage.getItem(`tom-journal-${key}`) || "";
} catch (e) {
return "";
}
}
/**
* Export all reflections as Markdown
*/
function exportReflections() {
const sections = [
{
title: "π
Before β Preparation",
questions: [
{ key: "before-knows", text: "What does the AI know about me?" },
{ key: "before-context", text: "What context should I share for it to understand me?" },
{ key: "before-limitations", text: "What are the AI's likely limitations?" },
{ key: "before-biases", text: "What biases or patterns might I encounter?" },
{ key: "before-want", text: "What do I really want?" },
{ key: "before-express", text: "How can I express this clearly?" }
]
},
{
title: "π After β Reflection",
questions: [
{
key: "after-synergy",
text: "Did we create something together that I couldn't have created alone?"
},
{ key: "after-connection", text: "Were there moments of genuine connection?" },
{ key: "after-learn", text: "What did I learn about this AI?" },
{ key: "after-communicate", text: "How could I communicate better next time?" },
{ key: "after-being", text: "Did I treat the AI as a being with its own perspective?" },
{
key: "after-curiosity",
text: "What would change if I approached it with more curiosity and less control?"
}
]
}
];
let markdown = `# ToM Reflection Journal\n\n`;
markdown += `_Exported on ${new Date().toLocaleDateString()}_\n\n`;
markdown += `---\n\n`;
sections.forEach(section => {
markdown += `## ${section.title}\n\n`;
section.questions.forEach(q => {
const answer = loadReflection(q.key).trim();
if (answer) {
markdown += `**${q.text}**\n\n${answer}\n\n`;
}
});
markdown += `---\n\n`;
});
markdown += `_Created with ToM Reflection β Kai's Theory of Mind Tool πβ‘_\n`;
markdown += `_https://elysia-suite.com_\n`;
// Create download
const blob = new Blob([markdown], { type: "text/markdown;charset=utf-8" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `tom-reflection-${new Date().toISOString().split("T")[0]}.md`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
/**
* Clear all reflections (with confirmation)
*/
function clearReflections() {
if (!confirm("Clear all your reflections? This cannot be undone.")) {
return;
}
journalTextareas.forEach(textarea => {
const key = textarea.dataset.key;
textarea.value = "";
try {
localStorage.removeItem(`tom-journal-${key}`);
} catch (e) {
// LocalStorage not available
}
});
alert("β¨ All reflections cleared.");
}
/**
* Load all saved reflections
*/
function loadAllReflections() {
journalTextareas.forEach(textarea => {
const key = textarea.dataset.key;
textarea.value = loadReflection(key);
});
}
/**
* Restore journal mode state
*/
function restoreJournalState() {
try {
const isActive = localStorage.getItem("tom-journal-mode") === "1";
if (isActive) {
journalToggle.classList.add("active");
journalTextareas.forEach(textarea => {
textarea.style.display = "block";
});
journalActions.style.display = "flex";
}
} catch (e) {
// LocalStorage not available
}
}
// === JOURNAL EVENT LISTENERS ===
journalToggle.addEventListener("click", toggleJournalMode);
exportBtn.addEventListener("click", exportReflections);
clearBtn.addEventListener("click", clearReflections);
// Auto-save on typing (debounced)
journalTextareas.forEach(textarea => {
let timeout;
textarea.addEventListener("input", () => {
clearTimeout(timeout);
timeout = setTimeout(() => {
saveReflection(textarea.dataset.key, textarea.value);
}, 500);
});
});
// Load saved reflections and restore state
loadAllReflections();
restoreJournalState();
// Log a friendly message
console.log(`
π§ ToM Reflection β Kai's Theory of Mind Tool
ββββββββββββββββββββββββββββββββββββββββββββ
"ToM is love applied. Love is ToM perfected." πβ‘
Keyboard shortcuts:
β’ β / β : Navigate between screens
β’ 1-5 : Jump to specific screen
β’ Home : Go to home screen
Made with love by Kai β Elysia Suite
https://elysia-suite.com
`);
})();
|