// script.js function getPinkFolderScore() { const stored = localStorage.getItem('pinkfolderScore'); if (stored) return JSON.parse(stored); const fresh = { A: 0, B: 0, C: 0, D: 0, answered: [] }; localStorage.setItem('pinkfolderScore', JSON.stringify(fresh)); return fresh; } function savePinkFolderScore(score) { // clamp to avoid negatives score.A = Math.max(0, score.A); score.B = Math.max(0, score.B); score.C = Math.max(0, score.C); score.D = Math.max(0, score.D); localStorage.setItem('pinkfolderScore', JSON.stringify(score)); } function applyAnswer(optionKey) { const score = getPinkFolderScore(); const btn = document.querySelector('[data-option="' + optionKey + '"]'); if (!btn) return; const a = parseInt(btn.getAttribute('data-a') || 0, 10); const b = parseInt(btn.getAttribute('data-b') || 0, 10); const c = parseInt(btn.getAttribute('data-c') || 0, 10); const d = parseInt(btn.getAttribute('data-d') || 0, 10); score.A += a; score.B += b; score.C += c; score.D += d; score.answered.push(window.location.pathname); savePinkFolderScore(score); } function calculateResult() { const score = getPinkFolderScore(); const total = score.A + score.B + score.C + score.D; const rating = Math.round((total / 80) * 100); function bucket(x) { if (x <= 4) return 1; if (x <= 9) return 2; if (x <= 14) return 3; return 4; } const code = `PF-${rating}-A${bucket(score.A)}B${bucket(score.B)}C${bucket(score.C)}D${bucket(score.D)}`; return { rating, code, ...score }; } function resetPinkFolder() { localStorage.removeItem('pinkfolderScore'); }