diff --git a/before/script.js b/after/script.js index c58a571..ddc3b46 100644 --- a/before/script.js +++ b/after/script.js @@ -1,10 +1,9 @@ /* - BEFORE — Broken lead-capture workflow (DEMO) - ============================================ - This script intentionally reproduces realistic automation failures so the - "after" repair can be compared against it. Every intentional bug is marked - with a "BUG:" comment explaining the problem and what it maps to in a real - Zapier / Make / n8n / webhook setup. + AFTER — Repaired lead-capture workflow (DEMO) + ============================================= + This is the "before" workflow after the Repair Package. Each fix is marked + with a "FIX:" comment showing what was repaired and what it maps to in a + real Zapier / Make / n8n / webhook setup. This is a demo. Nothing is sent to a real CRM, Slack workspace, or inbox. */ @@ -14,12 +13,31 @@ const crm = []; const form = document.getElementById("lead-form"); const statusPanel = document.getElementById("status-panel"); -const vagueError = document.getElementById("vague-error"); const crmBody = document.getElementById("crm-body"); const slackPanel = document.getElementById("slack-panel"); const emailPanel = document.getElementById("email-panel"); +const logEl = document.getElementById("error-log"); const devEvidence = document.getElementById("dev-evidence"); +let logStarted = false; + +function ts() { + return new Date().toLocaleTimeString("en-GB", { hour12: false }); +} + +function log(kind, message) { + if (!logStarted) { + logEl.innerHTML = ""; + logStarted = true; + } + const line = document.createElement("div"); + line.className = `log-line log-${kind}`; + const label = { ok: "OK ", err: "ERR ", warn: "WARN", info: "INFO" }[kind] || "INFO"; + line.innerHTML = `${ts()} ${label} ${message}`; + logEl.appendChild(line); + logEl.scrollTop = logEl.scrollHeight; +} + function setStatus(rows) { statusPanel.innerHTML = rows .map((r) => `