{"id":142,"date":"2026-05-31T17:44:10","date_gmt":"2026-05-31T17:44:10","guid":{"rendered":"https:\/\/camp.wiserighteous.org\/?page_id=142"},"modified":"2026-05-31T18:08:35","modified_gmt":"2026-05-31T18:08:35","slug":"step-1-identify-unrighteous-behavior-patterns-method-2","status":"publish","type":"page","link":"https:\/\/camp.wiserighteous.org\/index.php\/step-1-identify-unrighteous-behavior-patterns-method-2\/","title":{"rendered":"Step 1 \u2013 Identify Unrighteous Behavior Patterns (Method 2)"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=yes\">\n    <title>Cognitive\u2011Behavioural Pattern Audit | Righteous Growth<\/title>\n    <style>\n        * {\n            box-sizing: border-box;\n        }\n        body {\n            font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;\n            max-width: 1100px;\n            margin: 0 auto;\n            padding: 20px;\n            background: #f1f5f9;\n            color: #0f172a;\n        }\n        h3, h4 {\n            color: #1e293b;\n        }\n        .step-card {\n            background: white;\n            border-radius: 28px;\n            box-shadow: 0 8px 20px rgba(0,0,0,0.08);\n            padding: 24px 30px;\n            margin-bottom: 30px;\n            border: 1px solid #e2e8f0;\n        }\n        .section-title {\n            border-left: 6px solid #3b82f6;\n            padding-left: 16px;\n            margin: 20px 0 16px;\n            font-weight: 700;\n        }\n        .form-group {\n            margin-bottom: 20px;\n        }\n        label {\n            font-weight: 600;\n            display: block;\n            margin-bottom: 6px;\n        }\n        textarea, input, select {\n            width: 100%;\n            padding: 10px 14px;\n            border: 1px solid #cbd5e1;\n            border-radius: 20px;\n            font-family: inherit;\n            font-size: 0.95rem;\n        }\n        .distortion-list, .belief-list {\n            display: flex;\n            flex-wrap: wrap;\n            gap: 10px;\n            margin: 12px 0;\n        }\n        .distortion-option, .belief-option {\n            background: #eef2ff;\n            padding: 6px 16px;\n            border-radius: 40px;\n            cursor: pointer;\n            font-size: 0.85rem;\n            transition: 0.1s;\n        }\n        .distortion-option.selected, .belief-option.selected {\n            background: #3b82f6;\n            color: white;\n        }\n        button {\n            background: #3b82f6;\n            color: white;\n            border: none;\n            padding: 10px 24px;\n            border-radius: 40px;\n            font-weight: 600;\n            cursor: pointer;\n            margin-right: 12px;\n            margin-top: 12px;\n        }\n        button.secondary {\n            background: #64748b;\n        }\n        button.outline {\n            background: white;\n            border: 1px solid #3b82f6;\n            color: #3b82f6;\n        }\n        .worksheet {\n            background: #fef9e6;\n            border-left: 6px solid #f59e0b;\n            padding: 20px;\n            border-radius: 24px;\n            margin: 20px 0;\n        }\n        .dashboard-stats {\n            display: flex;\n            flex-wrap: wrap;\n            gap: 20px;\n            margin-bottom: 20px;\n        }\n        .stat-card {\n            background: white;\n            padding: 12px 18px;\n            border-radius: 24px;\n            flex: 1;\n            box-shadow: 0 2px 6px rgba(0,0,0,0.05);\n        }\n        .hidden {\n            display: none;\n        }\n        hr {\n            margin: 24px 0;\n        }\n        .flex-btns {\n            display: flex;\n            flex-wrap: wrap;\n            gap: 10px;\n            margin-top: 20px;\n        }\n        @media (max-width: 700px) {\n            .step-card { padding: 16px; }\n        }\n    <\/style>\n<\/head>\n<body>\n\n<h3>\ud83e\udde0 Cognitive\u2011Behavioural Pattern Audit<\/h3>\n<p style=\"margin-bottom: 24px;\">A structured, deep audit of one unrighteous incident. Identify automatic thoughts, emotions, distortions, core beliefs, and create a restructuring plan.<\/p>\n\n<!-- STEP 1: Incident form -->\n<div id=\"incidentForm\" class=\"step-card\">\n    <h4>\ud83d\udccb Step 1: Describe the incident<\/h4>\n    <div class=\"form-group\">\n        <label>\ud83d\udcc5 Date (approximate)<\/label>\n        <input type=\"date\" id=\"incidentDate\">\n    <\/div>\n    <div class=\"form-group\">\n        <label>\ud83d\udd0d What happened? (Be specific \u2013 situation, who, what, where)<\/label>\n        <textarea id=\"situation\" rows=\"3\" placeholder=\"Example: My supervisor criticised my report in front of colleagues. I felt humiliated and then made an excuse that the deadline was unrealistic.\"><\/textarea>\n    <\/div>\n    <div class=\"form-group\">\n        <label>\ud83d\udcad Automatic thoughts (What ran through your mind immediately?)<\/label>\n        <textarea id=\"autoThoughts\" rows=\"3\" placeholder=\"Example: 'He always picks on me. Everyone thinks I'm incompetent. I should just quit.'\"><\/textarea>\n    <\/div>\n    <div class=\"form-group\">\n        <label>\ud83d\ude16 Emotions &#038; physical sensations (Rate intensity 0-10)<\/label>\n        <div style=\"display: flex; gap: 12px; flex-wrap: wrap;\">\n            <input type=\"text\" id=\"emotion1\" placeholder=\"e.g., Anger (8)\" style=\"width: auto; flex:1;\">\n            <input type=\"text\" id=\"emotion2\" placeholder=\"e.g., Shame (7)\" style=\"width: auto; flex:1;\">\n            <input type=\"text\" id=\"emotion3\" placeholder=\"e.g., Anxiety (6)\" style=\"width: auto; flex:1;\">\n        <\/div>\n    <\/div>\n    <div class=\"form-group\">\n        <label>\u26a1 What did you do afterward? (Behavioural reaction)<\/label>\n        <textarea id=\"behaviour\" rows=\"2\" placeholder=\"Example: I left the meeting early, vented to a coworker, then avoided my supervisor for two days.\"><\/textarea>\n    <\/div>\n    <div class=\"form-group\">\n        <label>\ud83c\udfaf Which unrighteous patterns do you recognise? (select all that apply)<\/label>\n        <div id=\"patternTags\" class=\"distortion-list\"><\/div>\n    <\/div>\n    <div class=\"flex-btns\">\n        <button id=\"submitIncidentBtn\">Continue to Cognitive Distortions \u2192<\/button>\n        <button id=\"viewDashboardBtn\" class=\"secondary\">\ud83d\udcca View Dashboard (All audits)<\/button>\n    <\/div>\n<\/div>\n\n<!-- STEP 2: Cognitive distortions + core beliefs -->\n<div id=\"distortionsForm\" class=\"step-card hidden\">\n    <h4>\ud83e\udde9 Step 2: Identify cognitive distortions<\/h4>\n    <p>Select any distortions that appear in your automatic thoughts or situation interpretation.<\/p>\n    <div id=\"distortionsList\" class=\"distortion-list\"><\/div>\n    <div class=\"form-group\">\n        <label>\u2795 Any other distortion not listed? (optional)<\/label>\n        <input type=\"text\" id=\"customDistortion\" placeholder=\"e.g., 'Emotional reasoning'\">\n    <\/div>\n    <h4>\ud83c\udfdb\ufe0f Step 3: Underlying core beliefs<\/h4>\n    <p>Select the core beliefs that may be driving your reaction.<\/p>\n    <div id=\"coreBeliefsList\" class=\"belief-list\"><\/div>\n    <div class=\"form-group\">\n        <label>\u2795 Other core belief<\/label>\n        <input type=\"text\" id=\"customBelief\" placeholder=\"e.g., 'I must never fail'\">\n    <\/div>\n    <div class=\"flex-btns\">\n        <button id=\"backToIncidentBtn\" class=\"outline\">\u2190 Back<\/button>\n        <button id=\"generateWorksheetBtn\">Generate Restructuring Worksheet \u2192<\/button>\n    <\/div>\n<\/div>\n\n<!-- STEP 3: Restructuring worksheet + save -->\n<div id=\"worksheetPanel\" class=\"step-card hidden\">\n    <h4>\ud83d\udcdd Restructuring Worksheet<\/h4>\n    <div id=\"worksheetContent\" class=\"worksheet\"><\/div>\n    <div class=\"flex-btns\">\n        <button id=\"saveAuditBtn\">\ud83d\udcbe Save this audit &#038; add to dashboard<\/button>\n        <button id=\"newAuditBtn\" class=\"secondary\">+ New Incident<\/button>\n    <\/div>\n<\/div>\n\n<!-- DASHBOARD (shows all saved audits) -->\n<div id=\"dashboardPanel\" class=\"step-card hidden\">\n    <h4>\ud83d\udcc8 Audit Dashboard \u2013 Patterns &#038; Progress<\/h4>\n    <div id=\"dashboardStats\" class=\"dashboard-stats\"><\/div>\n    <div id=\"auditList\"><\/div>\n    <div class=\"flex-btns\">\n        <button id=\"closeDashboardBtn\" class=\"outline\">\u2190 Back to new audit<\/button>\n        <button id=\"resetAllDataBtn\" style=\"background:#b91c1c;\">\ud83d\uddd1\ufe0f Delete all data<\/button>\n    <\/div>\n<\/div>\n\n<script>\n    \/\/ ------------------- STORAGE -------------------\n    let audits = [];  \/\/ each audit: { id, date, situation, autoThoughts, emotions, behaviour, patternTags, distortions, coreBeliefs, restructuring }\n    const STORAGE_KEY = \"righteous_cbt_audits\";\n    \n    \/\/ Temporary holding for current audit (before saving)\n    let currentAudit = {\n        incidentDate: \"\",\n        situation: \"\",\n        autoThoughts: \"\",\n        emotions: [],\n        behaviour: \"\",\n        patternTags: [],\n        distortions: [],\n        coreBeliefs: []\n    };\n    \n    \/\/ Predefined lists\n    const availablePatterns = [\n        \"Blaming\", \"Avoiding\", \"Reacting quickly\", \"Pride\", \"Lying\",\n        \"Gossip\", \"Controlling\", \"Excuses\", \"Hiding\", \"Broken promise\", \"Admitting wrong\"\n    ];\n    const distortionOptions = [\n        \"All-or-nothing thinking\", \"Overgeneralisation\", \"Mental filter\", \"Disqualifying the positive\",\n        \"Jumping to conclusions (mind reading)\", \"Jumping to conclusions (fortune telling)\",\n        \"Magnification (catastrophising)\", \"Minimisation\", \"Emotional reasoning\", \"Should statements\",\n        \"Labeling\", \"Personalisation\", \"Blaming\"\n    ];\n    const coreBeliefOptions = [\n        \"I am defective \/ inadequate\", \"I am unlovable\", \"I am weak\", \"I must be perfect to be accepted\",\n        \"I must never make mistakes\", \"Others are against me\", \"The world is dangerous\", \"I am responsible for everyone's feelings\",\n        \"I must control everything\", \"I am entitled to special treatment\", \"I am worthless without achievement\"\n    ];\n    \n    \/\/ Load saved audits\n    function loadData() {\n        const stored = localStorage.getItem(STORAGE_KEY);\n        if (stored) {\n            audits = JSON.parse(stored);\n        } else {\n            audits = [];\n        }\n    }\n    \n    function saveAudits() {\n        localStorage.setItem(STORAGE_KEY, JSON.stringify(audits));\n    }\n    \n    \/\/ Helper: render tag buttons\n    function renderPatternTags(containerId, selectedSet) {\n        const container = document.getElementById(containerId);\n        if (!container) return;\n        let html = \"\";\n        availablePatterns.forEach(p => {\n            const cls = selectedSet.has(p) ? \"distortion-option selected\" : \"distortion-option\";\n            html += `<div class=\"${cls}\" data-pattern=\"${p}\">${p}<\/div>`;\n        });\n        container.innerHTML = html;\n        \/\/ attach events\n        container.querySelectorAll(\".distortion-option\").forEach(el => {\n            el.addEventListener(\"click\", () => {\n                const val = el.getAttribute(\"data-pattern\");\n                if (selectedSet.has(val)) selectedSet.delete(val);\n                else selectedSet.add(val);\n                renderPatternTags(containerId, selectedSet);\n            });\n        });\n    }\n    \n    function renderDistortions(containerId, selectedSet) {\n        const container = document.getElementById(containerId);\n        let html = \"\";\n        distortionOptions.forEach(d => {\n            const cls = selectedSet.has(d) ? \"distortion-option selected\" : \"distortion-option\";\n            html += `<div class=\"${cls}\" data-dist=\"${d}\">${d}<\/div>`;\n        });\n        container.innerHTML = html;\n        container.querySelectorAll(\".distortion-option\").forEach(el => {\n            el.addEventListener(\"click\", () => {\n                const val = el.getAttribute(\"data-dist\");\n                if (selectedSet.has(val)) selectedSet.delete(val);\n                else selectedSet.add(val);\n                renderDistortions(containerId, selectedSet);\n            });\n        });\n    }\n    \n    function renderCoreBeliefs(containerId, selectedSet) {\n        const container = document.getElementById(containerId);\n        let html = \"\";\n        coreBeliefOptions.forEach(b => {\n            const cls = selectedSet.has(b) ? \"belief-option selected\" : \"belief-option\";\n            html += `<div class=\"${cls}\" data-belief=\"${b}\">${b}<\/div>`;\n        });\n        container.innerHTML = html;\n        container.querySelectorAll(\".belief-option\").forEach(el => {\n            el.addEventListener(\"click\", () => {\n                const val = el.getAttribute(\"data-belief\");\n                if (selectedSet.has(val)) selectedSet.delete(val);\n                else selectedSet.add(val);\n                renderCoreBeliefs(containerId, selectedSet);\n            });\n        });\n    }\n    \n    \/\/ Generate restructuring worksheet based on currentAudit\n    function generateWorksheet() {\n        const thoughts = currentAudit.autoThoughts;\n        const distortionsList = Array.from(currentAudit.distortions);\n        const coreBeliefsList = Array.from(currentAudit.coreBeliefs);\n        const patternTags = Array.from(currentAudit.patternTags);\n        \n        \/\/ Create challenge questions\n        let challengeHtml = `<strong>\ud83d\udd0d Challenging the distortions:<\/strong><br>`;\n        if (distortionsList.length === 0) {\n            challengeHtml += `<p>No distortions selected. Re\u2011examine your automatic thoughts: are there any thinking traps?<\/p>`;\n        } else {\n            challengeHtml += `<ul>`;\n            distortionsList.forEach(d => {\n                if (d.includes(\"All-or-nothing\")) challengeHtml += `<li>Are there any shades of grey? Is it really 0% or 100%?<\/li>`;\n                else if (d.includes(\"Overgeneralisation\")) challengeHtml += `<li>Is this truly 'always' or 'never'? Can you find one counterexample?<\/li>`;\n                else if (d.includes(\"Mental filter\")) challengeHtml += `<li>Are you ignoring positive aspects? What else happened that you're not focusing on?<\/li>`;\n                else if (d.includes(\"Disqualifying the positive\")) challengeHtml += `<li>Why are you dismissing good parts? What would you say to a friend who did the same?<\/li>`;\n                else if (d.includes(\"Jumping to conclusions\")) challengeHtml += `<li>What evidence do you have? Are there alternative explanations?<\/li>`;\n                else if (d.includes(\"Catastrophising\")) challengeHtml += `<li>What's the worst that could realistically happen? How would you cope?<\/li>`;\n                else if (d.includes(\"Emotional reasoning\")) challengeHtml += `<li>Just because you feel it, doesn't make it true. What are the facts?<\/li>`;\n                else if (d.includes(\"Should statements\")) challengeHtml += `<li>Where does the 'should' come from? Is it flexible?<\/li>`;\n                else if (d.includes(\"Labeling\")) challengeHtml += `<li>Instead of labeling yourself or others, describe the specific behaviour.<\/li>`;\n                else if (d.includes(\"Personalisation\")) challengeHtml += `<li>Is it really all about you? What other factors contributed?<\/li>`;\n                else challengeHtml += `<li>Ask: What would a balanced, compassionate observer say?<\/li>`;\n            });\n            challengeHtml += `<\/ul>`;\n        }\n        \n        let balancedThought = `<strong>\ud83d\udd04 Balanced alternative thought:<\/strong><br>\n        <textarea id=\"balancedThoughtArea\" rows=\"2\" placeholder=\"Write a more realistic, compassionate thought...\"><\/textarea>`;\n        \n        let coreBeliefWork = `<strong>\ud83c\udfdb\ufe0f Working with core beliefs:<\/strong><br>`;\n        if (coreBeliefsList.length) {\n            coreBeliefWork += `<p>Your selected core beliefs: ${coreBeliefsList.join(\", \")}.<\/p>`;\n            coreBeliefWork += `<p>\ud83d\udca1 New evidence challenge: List three experiences that contradict this core belief.<\/p>\n            <textarea id=\"newEvidence\" rows=\"2\" placeholder=\"1. ... 2. ... 3. ...\"><\/textarea>\n            <p>\ud83e\uddea Behavioural experiment: What could you do this week to test the old belief?<\/p>\n            <textarea id=\"behaviourExperiment\" rows=\"2\" placeholder=\"Example: 'I will ask for feedback from one person and notice if they reject me.'\"><\/textarea>`;\n        } else {\n            coreBeliefWork += `<p>No core beliefs selected \u2013 but you can still reflect on deeper assumptions.<\/p>`;\n        }\n        \n        let actionPlan = `<strong>\ud83d\udccc Righteous action plan:<\/strong><br>\n        <textarea id=\"actionPlan\" rows=\"2\" placeholder=\"What will you do differently next time? (e.g., take three deep breaths, use 'I feel' statements)\"><\/textarea>`;\n        \n        return { challengeHtml, balancedThought, coreBeliefWork, actionPlan };\n    }\n    \n    function displayWorksheet() {\n        const { challengeHtml, balancedThought, coreBeliefWork, actionPlan } = generateWorksheet();\n        const container = document.getElementById(\"worksheetContent\");\n        container.innerHTML = `\n            <h4>Incident: ${currentAudit.situation.substring(0, 80)}${currentAudit.situation.length>80 ? '\u2026' : ''}<\/h4>\n            <p><strong>Automatic thoughts:<\/strong> ${currentAudit.autoThoughts}<\/p>\n            <p><strong>Emotions:<\/strong> ${currentAudit.emotions.join(', ') || '\u2014'}<\/p>\n            <p><strong>Behaviour:<\/strong> ${currentAudit.behaviour}<\/p>\n            <hr>\n            ${challengeHtml}\n            ${balancedThought}\n            ${coreBeliefWork}\n            ${actionPlan}\n            <p style=\"margin-top: 16px;\"><em>After filling, click \"Save audit\" to store this work in your dashboard.<\/em><\/p>\n        `;\n    }\n    \n    \/\/ Collect data from step 1 UI\n    function collectIncidentData() {\n        const incidentDate = document.getElementById(\"incidentDate\").value;\n        const situation = document.getElementById(\"situation\").value.trim();\n        const autoThoughts = document.getElementById(\"autoThoughts\").value.trim();\n        const emotion1 = document.getElementById(\"emotion1\").value.trim();\n        const emotion2 = document.getElementById(\"emotion2\").value.trim();\n        const emotion3 = document.getElementById(\"emotion3\").value.trim();\n        const emotions = [emotion1, emotion2, emotion3].filter(e => e !== \"\");\n        const behaviour = document.getElementById(\"behaviour\").value.trim();\n        \n        if (!situation || !autoThoughts || !behaviour) {\n            alert(\"Please fill at least situation, automatic thoughts, and behaviour.\");\n            return false;\n        }\n        \/\/ patternTags are collected via currentAudit.patternTags (from rendered buttons)\n        currentAudit.incidentDate = incidentDate;\n        currentAudit.situation = situation;\n        currentAudit.autoThoughts = autoThoughts;\n        currentAudit.emotions = emotions;\n        currentAudit.behaviour = behaviour;\n        \/\/ patternTags already stored from the tag selection (we maintain a Set)\n        return true;\n    }\n    \n    \/\/ Initialise step 1 with pattern selection\n    const patternSet = new Set();\n    const distortionSet = new Set();\n    const coreSet = new Set();\n    \n    function resetCurrentAudit() {\n        currentAudit = {\n            incidentDate: \"\",\n            situation: \"\",\n            autoThoughts: \"\",\n            emotions: [],\n            behaviour: \"\",\n            patternTags: [],\n            distortions: [],\n            coreBeliefs: []\n        };\n        patternSet.clear();\n        distortionSet.clear();\n        coreSet.clear();\n        \/\/ Clear UI fields\n        document.getElementById(\"incidentDate\").value = \"\";\n        document.getElementById(\"situation\").value = \"\";\n        document.getElementById(\"autoThoughts\").value = \"\";\n        document.getElementById(\"emotion1\").value = \"\";\n        document.getElementById(\"emotion2\").value = \"\";\n        document.getElementById(\"emotion3\").value = \"\";\n        document.getElementById(\"behaviour\").value = \"\";\n        renderPatternTags(\"patternTags\", patternSet);\n        renderDistortions(\"distortionsList\", distortionSet);\n        renderCoreBeliefs(\"coreBeliefsList\", coreSet);\n    }\n    \n    \/\/ Event handlers\n    document.getElementById(\"submitIncidentBtn\").addEventListener(\"click\", () => {\n        if (!collectIncidentData()) return;\n        currentAudit.patternTags = Array.from(patternSet);\n        \/\/ move to step 2\n        document.getElementById(\"incidentForm\").classList.add(\"hidden\");\n        document.getElementById(\"distortionsForm\").classList.remove(\"hidden\");\n        \/\/ render distortions and core beliefs with current selections\n        renderDistortions(\"distortionsList\", distortionSet);\n        renderCoreBeliefs(\"coreBeliefsList\", coreSet);\n    });\n    \n    document.getElementById(\"backToIncidentBtn\").addEventListener(\"click\", () => {\n        document.getElementById(\"distortionsForm\").classList.add(\"hidden\");\n        document.getElementById(\"incidentForm\").classList.remove(\"hidden\");\n    });\n    \n    document.getElementById(\"generateWorksheetBtn\").addEventListener(\"click\", () => {\n        \/\/ collect distortions and core beliefs from UI\n        distortionSet.clear();\n        coreSet.clear();\n        \/\/ read selected from the rendered divs\n        document.querySelectorAll(\"#distortionsList .distortion-option.selected\").forEach(el => {\n            distortionSet.add(el.getAttribute(\"data-dist\"));\n        });\n        document.querySelectorAll(\"#coreBeliefsList .belief-option.selected\").forEach(el => {\n            coreSet.add(el.getAttribute(\"data-belief\"));\n        });\n        const customDist = document.getElementById(\"customDistortion\").value.trim();\n        if (customDist) distortionSet.add(customDist);\n        const customBelief = document.getElementById(\"customBelief\").value.trim();\n        if (customBelief) coreSet.add(customBelief);\n        \n        currentAudit.distortions = Array.from(distortionSet);\n        currentAudit.coreBeliefs = Array.from(coreSet);\n        \n        displayWorksheet();\n        document.getElementById(\"distortionsForm\").classList.add(\"hidden\");\n        document.getElementById(\"worksheetPanel\").classList.remove(\"hidden\");\n    });\n    \n    document.getElementById(\"saveAuditBtn\").addEventListener(\"click\", () => {\n        \/\/ get the worksheet fields values\n        const balancedThought = document.getElementById(\"balancedThoughtArea\")?.value || \"\";\n        const newEvidence = document.getElementById(\"newEvidence\")?.value || \"\";\n        const behaviourExperiment = document.getElementById(\"behaviourExperiment\")?.value || \"\";\n        const actionPlan = document.getElementById(\"actionPlan\")?.value || \"\";\n        const restructuring = {\n            balancedThought,\n            newEvidence,\n            behaviourExperiment,\n            actionPlan\n        };\n        const newAudit = {\n            id: Date.now(),\n            date: currentAudit.incidentDate || new Date().toISOString().slice(0,10),\n            situation: currentAudit.situation,\n            autoThoughts: currentAudit.autoThoughts,\n            emotions: currentAudit.emotions,\n            behaviour: currentAudit.behaviour,\n            patternTags: currentAudit.patternTags,\n            distortions: currentAudit.distortions,\n            coreBeliefs: currentAudit.coreBeliefs,\n            restructuring: restructuring,\n            createdAt: new Date().toISOString()\n        };\n        audits.unshift(newAudit);\n        saveAudits();\n        alert(\"Audit saved! You can view it in the dashboard.\");\n        resetCurrentAudit();\n        document.getElementById(\"worksheetPanel\").classList.add(\"hidden\");\n        document.getElementById(\"incidentForm\").classList.remove(\"hidden\");\n    });\n    \n    document.getElementById(\"newAuditBtn\").addEventListener(\"click\", () => {\n        resetCurrentAudit();\n        document.getElementById(\"worksheetPanel\").classList.add(\"hidden\");\n        document.getElementById(\"incidentForm\").classList.remove(\"hidden\");\n    });\n    \n    \/\/ Dashboard rendering\n    function renderDashboard() {\n        const statsDiv = document.getElementById(\"dashboardStats\");\n        const listDiv = document.getElementById(\"auditList\");\n        if (audits.length === 0) {\n            statsDiv.innerHTML = `<div class=\"stat-card\">No audits yet. Complete a CBT audit first.<\/div>`;\n            listDiv.innerHTML = \"<p>No records.<\/p>\";\n            return;\n        }\n        \/\/ Frequency of distortions\n        const distortionFreq = {};\n        const coreFreq = {};\n        const patternFreq = {};\n        audits.forEach(a => {\n            a.distortions.forEach(d => { distortionFreq[d] = (distortionFreq[d] || 0) + 1; });\n            a.coreBeliefs.forEach(c => { coreFreq[c] = (coreFreq[c] || 0) + 1; });\n            a.patternTags.forEach(p => { patternFreq[p] = (patternFreq[p] || 0) + 1; });\n        });\n        const topDistortions = Object.entries(distortionFreq).sort((a,b)=>b[1]-a[1]).slice(0,3);\n        const topCore = Object.entries(coreFreq).sort((a,b)=>b[1]-a[1]).slice(0,3);\n        const topPatterns = Object.entries(patternFreq).sort((a,b)=>b[1]-a[1]).slice(0,3);\n        \n        statsDiv.innerHTML = `\n            <div class=\"stat-card\"><strong>\ud83d\udd01 Most common patterns<\/strong><br> ${topPatterns.map(p=>`${p[0]} (${p[1]})`).join(', ') || '\u2014'}<\/div>\n            <div class=\"stat-card\"><strong>\ud83e\udde0 Frequent distortions<\/strong><br> ${topDistortions.map(d=>`${d[0]} (${d[1]})`).join(', ') || '\u2014'}<\/div>\n            <div class=\"stat-card\"><strong>\ud83c\udfdb\ufe0f Recurring core beliefs<\/strong><br> ${topCore.map(c=>`${c[0]} (${c[1]})`).join(', ') || '\u2014'}<\/div>\n        `;\n        \n        let listHtml = `<h4>All audits (${audits.length})<\/h4>`;\n        audits.forEach((a, idx) => {\n            listHtml += `\n                <div style=\"background:#f8fafc; border-radius:20px; padding:12px; margin-bottom:12px;\">\n                    <div><strong>\ud83d\udcc5 ${a.date}<\/strong> &nbsp; ${a.situation.substring(0,100)}${a.situation.length>100 ? '\u2026' : ''}<\/div>\n                    <div>\ud83e\udde9 Patterns: ${a.patternTags.join(', ')}<\/div>\n                    <div>\ud83e\udd14 Distortions: ${a.distortions.slice(0,3).join(', ')}${a.distortions.length>3 ? '\u2026' : ''}<\/div>\n                    <details><summary>\ud83d\udcdd View restructuring worksheet<\/summary>\n                        <p><strong>Balanced thought:<\/strong> ${a.restructuring.balancedThought || '\u2014'}<\/p>\n                        <p><strong>Action plan:<\/strong> ${a.restructuring.actionPlan || '\u2014'}<\/p>\n                    <\/details>\n                    <button class=\"delete-audit-btn\" data-id=\"${a.id}\" style=\"background:#e53e3e; padding:4px 12px; font-size:0.75rem;\">Delete<\/button>\n                <\/div>\n            `;\n        });\n        listDiv.innerHTML = listHtml;\n        \/\/ attach delete events\n        document.querySelectorAll(\".delete-audit-btn\").forEach(btn => {\n            btn.addEventListener(\"click\", (e) => {\n                const id = parseInt(btn.getAttribute(\"data-id\"));\n                audits = audits.filter(a => a.id !== id);\n                saveAudits();\n                renderDashboard();\n            });\n        });\n    }\n    \n    document.getElementById(\"viewDashboardBtn\").addEventListener(\"click\", () => {\n        renderDashboard();\n        document.getElementById(\"incidentForm\").classList.add(\"hidden\");\n        document.getElementById(\"distortionsForm\").classList.add(\"hidden\");\n        document.getElementById(\"worksheetPanel\").classList.add(\"hidden\");\n        document.getElementById(\"dashboardPanel\").classList.remove(\"hidden\");\n    });\n    document.getElementById(\"closeDashboardBtn\").addEventListener(\"click\", () => {\n        document.getElementById(\"dashboardPanel\").classList.add(\"hidden\");\n        document.getElementById(\"incidentForm\").classList.remove(\"hidden\");\n        resetCurrentAudit();\n    });\n    document.getElementById(\"resetAllDataBtn\").addEventListener(\"click\", () => {\n        if (confirm(\"Delete ALL audits permanently?\")) {\n            audits = [];\n            saveAudits();\n            renderDashboard();\n            alert(\"All data erased.\");\n        }\n    });\n    \n    \/\/ Initialisation\n    loadData();\n    resetCurrentAudit();\n    renderPatternTags(\"patternTags\", patternSet);\n    renderDistortions(\"distortionsList\", distortionSet);\n    renderCoreBeliefs(\"coreBeliefsList\", coreSet);\n<\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Cognitive\u2011Behavioural Pattern Audit | Righteous Growth \ud83e\udde0 Cognitive\u2011Behavioural Pattern Audit A structured, deep audit of one unrighteous incident. Identify automatic thoughts, emotions, distortions, core beliefs, and create a restructuring plan. \ud83d\udccb Step 1: Describe the incident \ud83d\udcc5 Date (approximate) \ud83d\udd0d What happened? (Be specific \u2013 situation, who, what, where) \ud83d\udcad Automatic thoughts (What ran through [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-142","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/camp.wiserighteous.org\/index.php\/wp-json\/wp\/v2\/pages\/142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/camp.wiserighteous.org\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/camp.wiserighteous.org\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/camp.wiserighteous.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/camp.wiserighteous.org\/index.php\/wp-json\/wp\/v2\/comments?post=142"}],"version-history":[{"count":4,"href":"https:\/\/camp.wiserighteous.org\/index.php\/wp-json\/wp\/v2\/pages\/142\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/camp.wiserighteous.org\/index.php\/wp-json\/wp\/v2\/pages\/142\/revisions\/147"}],"wp:attachment":[{"href":"https:\/\/camp.wiserighteous.org\/index.php\/wp-json\/wp\/v2\/media?parent=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}