← Demos
Web Pages · Demos

Medical Bill Payoff Denver

by Shane Hadden Oct 11, 2026 9 views 28 KB
Sandbox · medical-bill-payoff-denver · no access to your account
View source — the whole page is this one file
<!-- Copyright (c) 2026 Globefin. Released under the MIT License. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Summit Plan — paying off the bills from one Denver ER visit</title>
<style>
  :root { --sky: #e7eef7; --snow: #fbfcfe; --granite: #3b4150; --columbine: #5b4fa0; --aspen: #e0a526; --pine: #2f5d50; --rock: #8a8f9c; --line: #d6dce8; --red: #b4232f; }
  * { box-sizing: border-box; }
  body { margin: 0; background: var(--snow); color: var(--granite); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.5; }
  h1, h2, .hd { font-family: "Gill Sans", "Gill Sans MT", "Trebuchet MS", sans-serif; font-weight: 600; letter-spacing: .01em; }

  .peak { background: var(--sky); position: relative; }
  .peak .top { max-width: 1100px; margin: 0 auto; padding: 1.6rem 1.3rem 0; display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: start; }
  .peak h1 { font-size: 2.4rem; margin: 0; color: var(--columbine); line-height: 1.05; }
  .peak p { margin: .6rem 0 0; max-width: 520px; }
  .peak .who { font-size: .85rem; color: var(--pine); margin-top: .7rem; }
  .pay { background: #fff; border-radius: 14px; padding: 1rem 1.2rem; border: 1px solid var(--line); }
  .pay label { font-size: .9rem; display: block; }
  .pay .amt { font-family: "Gill Sans", "Gill Sans MT", "Trebuchet MS", sans-serif; font-size: 2.4rem; color: var(--granite); font-variant-numeric: tabular-nums; }
  .pay .amt small { font-size: 1rem; color: var(--rock); }
  input[type=range] { width: 100%; accent-color: var(--columbine); }
  .pay .summit { margin-top: .4rem; font-size: 1.05rem; }
  .pay .summit b { color: var(--columbine); }
  .peak svg { display: block; width: 100%; height: auto; }

  .walk { max-width: 1100px; margin: .9rem auto 0; padding: 0 1.3rem; display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; position: relative; }
  .walk span { font-size: .9rem; }
  .walk b { font-variant-numeric: tabular-nums; }

  main { max-width: 1100px; margin: 0 auto; padding: 1.6rem 1.3rem 2rem; display: grid; grid-template-columns: minmax(0,1.15fr) minmax(0,.85fr); gap: 2rem; }
  h2 { font-size: 1.35rem; margin: 0 0 .3rem; color: var(--granite); }
  .sub { font-size: .9rem; color: var(--rock); margin: 0 0 .8rem; }
  .order { display: inline-flex; border: 1.5px solid var(--columbine); border-radius: 999px; overflow: hidden; margin-bottom: .8rem; }
  .order button { font: inherit; font-size: .85rem; border: 0; background: #fff; color: var(--columbine); padding: .4rem .85rem; cursor: pointer; }
  .order button.on { background: var(--columbine); color: #fff; }

  .bill { display: grid; grid-template-columns: 1.6rem 1fr; gap: .6rem; background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--columbine);
          border-radius: 10px; padding: .7rem .8rem; margin-bottom: .55rem; cursor: grab; transition: transform .12s ease, box-shadow .12s ease; }
  .bill.drag { opacity: .5; }
  .bill.over { box-shadow: 0 -3px 0 var(--aspen); }
  .bill .grip { color: var(--rock); font-size: 1.1rem; line-height: 1; padding-top: .3rem; text-align: center; user-select: none; }
  .bill .rank { display: block; font-family: "Gill Sans", "Gill Sans MT", "Trebuchet MS", sans-serif; font-size: .78rem; color: var(--columbine); margin-top: .1rem; }
  .bill .f { display: grid; grid-template-columns: 1.6fr 1fr .8fr 1fr auto; gap: .4rem; align-items: end; }
  .bill label { font-size: .72rem; color: var(--rock); display: block; }
  .bill input { font: inherit; font-size: .92rem; width: 100%; padding: .32rem .45rem; border: 1px solid var(--line); border-radius: 6px; }
  .bill .done { grid-column: 2; font-size: .82rem; color: var(--pine); margin-top: .35rem; }
  .bill .mv { display: flex; gap: .2rem; }
  .bill .mv button, .bill .x { font: inherit; font-size: .8rem; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .2rem .45rem; cursor: pointer; color: var(--granite); }
  .add { font: inherit; font-size: .9rem; border: 1.5px dashed var(--columbine); background: none; color: var(--columbine); border-radius: 10px; padding: .55rem .9rem; cursor: pointer; width: 100%; }

  .side section { margin-bottom: 1.6rem; }
  .card { border-radius: 14px; padding: 1rem 1.1rem; background: #fff7e3; border: 1px solid #f0d899; }
  .card .vs { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: .6rem; }
  .card .vs div { background: #fff; border-radius: 10px; padding: .6rem .7rem; }
  .card .vs b { display: block; font-family: "Gill Sans", "Gill Sans MT", "Trebuchet MS", sans-serif; font-size: 1.5rem; }
  .card .vs span { font-size: .8rem; color: var(--rock); }
  .card .diff { margin-top: .7rem; font-size: .95rem; }
  .card input[type=number] { width: 5rem; font: inherit; padding: .2rem .4rem; border: 1px solid #e6c97a; border-radius: 6px; }
  .checks label { display: grid; grid-template-columns: 1.3rem 1fr; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; cursor: pointer; }
  .checks input { accent-color: var(--pine); width: 1.05rem; height: 1.05rem; margin-top: .2rem; }
  .checks .got { color: var(--pine); font-size: .85rem; margin-top: .5rem; }

  .work { font-size: .88rem; background: var(--sky); border-radius: 10px; padding: .9rem 1rem; }
  .msg { font-size: .9rem; margin: .5rem 0; }
  .msg.warn { color: var(--red); font-weight: 600; }
  .toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
  .toolbar button { font: inherit; font-size: .9rem; border-radius: 999px; padding: .5rem 1rem; cursor: pointer; border: 1.5px solid var(--granite); background: #fff; color: var(--granite); }
  .toolbar button.primary { background: var(--granite); color: #fff; }
  button:focus-visible, input:focus-visible { outline: 3px solid var(--aspen); outline-offset: 2px; }
  footer { max-width: 1100px; margin: 0 auto; padding: 0 1.3rem 2.4rem; font-size: .8rem; color: var(--rock); }

  @media (max-width: 880px) {
    .peak .top, main { grid-template-columns: 1fr; }
    .bill .f { grid-template-columns: 1fr 1fr; }
    .walk { grid-template-columns: 1fr; gap: .2rem; margin-top: .4rem; }
    .trailbox { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .trailbox svg { min-width: 820px; }
  }
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
  @media print { .toolbar, .order, .walk input, .mv, .x, .add { display: none !important; } }
</style>
</head>
<body>

<header class="peak">
  <div class="top">
    <div>
      <h1>Summit Plan</h1>
      <p>One ER visit can send four or five separate bills: the hospital, the ER doctors, imaging, the lab. List them,
         choose what you can pay each month, and watch the trail to debt-free.</p>
      <div class="who">Built for a Denver household working through the bills from one emergency room visit.</div>
    </div>
    <div class="pay">
      <label for="budget">You can put toward these bills each month</label>
      <div class="amt" id="budgetV">$0</div>
      <input id="budget" type="range" min="0" max="2000" step="10">
      <div class="summit" id="summit"></div>
    </div>
  </div>
  <!-- The Front Range, with the trail drawn on it. Waypoint flags and the hiker are added by the script. -->
  <div class="trailbox"><svg id="range" viewBox="0 0 1200 300" role="img" aria-label="The trail from today to debt-free"></svg></div>
</header>
<div class="walk">
  <label for="walkMonth"><span>Walk the trail</span></label>
  <input id="walkMonth" type="range" min="0" max="1" step="1" value="0">
  <span id="walkV"></span>
</div>

<main>
  <section>
    <h2>Your bills</h2>
    <p class="sub">The extra money goes to the top bill first. Drag the cards, or use the arrows, to set your own order.</p>
    <div class="order" role="group" aria-label="Payoff order">
      <button type="button" data-o="avalanche">Highest interest first</button>
      <button type="button" data-o="snowball">Smallest first</button>
      <button type="button" data-o="custom">My order</button>
    </div>
    <div id="bills"></div>
    <button type="button" class="add" id="addBill">+ Add a bill</button>
    <div id="msg"></div>
  </section>

  <div class="side">
    <section class="card" aria-live="polite">
      <h2>What if it all went on a credit card?</h2>
      <div><label for="cardApr">At a card rate of </label><input id="cardApr" type="number" min="0" step="0.1"> %</div>
      <div class="vs">
        <div><span>This plan, interest</span><b id="planInt">$0</b><span id="planEnd"></span></div>
        <div><span>On a card, interest</span><b id="cardInt">$0</b><span id="cardEnd"></span></div>
      </div>
      <div class="diff" id="diff"></div>
    </section>

    <section class="checks">
      <h2>Before you pay anything</h2>
      <label><input type="checkbox" data-c="itemized"><span>Ask every biller for an <b>itemized bill</b> and check it against your insurer's Explanation of Benefits.</span></label>
      <label><input type="checkbox" data-c="discount"><span>Ask the hospital to <b>screen you for discounted care</b>. Colorado hospitals have to offer this screening under the state's Hospital Discounted Care program.</span></label>
      <label><input type="checkbox" data-c="plan"><span>Get a <b>0% payment plan</b> in writing before you put any bill on a card.</span></label>
      <label><input type="checkbox" data-c="surprise"><span>Out-of-network care you didn't choose in an emergency? Ask whether the federal <b>No Surprises Act</b> applies.</span></label>
      <div class="got" id="got"></div>
    </section>

    <section class="work" id="work"></section>
    <div class="toolbar">
      <button type="button" class="primary" id="saveBtn">Save my plan</button>
      <button type="button" id="openBtn">Open a saved plan</button>
      <button type="button" id="printBtn">Print</button>
      <button type="button" id="resetBtn">Start over</button>
      <input type="file" id="fileIn" accept=".json,application/json" hidden>
    </div>
    <div id="fileMsg" class="msg" role="status"></div>
  </div>
</main>

<footer>
  <p><b>For education only.</b> Not financial, legal, or medical-billing advice. Program rules and eligibility change;
     confirm anything you rely on with the biller or a patient advocate. Nothing you type leaves this page: there's no
     account, and nothing is sent anywhere. Made for the Globefin Demos gallery as an example. No outside code was used.</p>
</footer>

<script>
(function () {
  "use strict";
  var APP = "globefin-summit-plan", VERSION = 2, NS = "http://www.w3.org/2000/svg";
  function sample() {
    return { budget: 450, order: "avalanche", cardApr: 24, checks: {},
      bills: [ { name: "Hospital (facility)", balance: 3800, apr: 0, min: 100 }, { name: "ER physicians", balance: 1150, apr: 0, min: 50 },
               { name: "Imaging — CT scan", balance: 640, apr: 0, min: 40 }, { name: "Lab work", balance: 210, apr: 0, min: 25 },
               { name: "Card used for the ambulance", balance: 1300, apr: 26.9, min: 39 } ] };
  }
  var state = sample(), dirty = false, walk = 0;
  var $ = function (id) { return document.getElementById(id); };
  var money = function (n) { return "$" + Math.round(n).toLocaleString("en-US"); };
  var cents = function (n) { return "$" + n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); };
  function num(v) { var n = parseFloat(v); return isFinite(n) ? n : 0; }
  function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return {"&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;"}[c]; }); }
  function el(tag, a, p) { var e = document.createElementNS(NS, tag); for (var k in a) e.setAttribute(k, a[k]); if (p) p.appendChild(e); return e; }
  function monthLabel(k) { var d = new Date(); d.setDate(1); d.setMonth(d.getMonth() + k); return d.toLocaleDateString("en-US", { month: "short", year: "numeric" }); }

  // Month by month: interest (rate ÷ 12) is added, every open bill gets its minimum, and what's left goes down the
  // payoff order. Records each month's total so the trail can show it.
  function simulate(bills, budget, order) {
    var list = bills.map(function (b, i) { return { i: i, pos: i, name: b.name || "Bill " + (i + 1), bal: Math.max(0, b.balance), apr: Math.max(0, b.apr), min: Math.max(0, b.min), off: null }; })
                    .filter(function (b) { return b.bal > 0.005; });
    function open() {
      return list.filter(function (b) { return b.bal > 0.005; }).sort(function (a, b) {
        if (order === "custom") return a.pos - b.pos;
        if (order === "snowball") return (a.bal - b.bal) || (b.apr - a.apr);
        return (b.apr - a.apr) || (a.bal - b.bal);
      });
    }
    var first = open().map(function (b) { return b.i; });
    var interest = 0, m = 0, totals = [list.reduce(function (s, b) { return s + b.bal; }, 0)];
    while (open().length && m < 600) {
      m++;
      list.forEach(function (b) { if (b.bal > 0.005) { var it = b.bal * b.apr / 1200; b.bal += it; interest += it; } });
      var left = budget;
      list.forEach(function (b) { if (b.bal > 0.005) { var p = Math.min(b.min, b.bal, left); b.bal -= p; left -= p; } });
      var o = open();
      for (var k = 0; k < o.length && left > 0.005; k++) { var p2 = Math.min(o[k].bal, left); o[k].bal -= p2; left -= p2; }
      list.forEach(function (b) { if (b.bal <= 0.005 && b.off === null) b.off = m; });
      totals.push(Math.max(0, list.reduce(function (s, b) { return s + Math.max(0, b.bal); }, 0)));
    }
    return { months: m, done: !open().length, interest: interest, list: list, first: first, totals: totals };
  }

  // ---------- the mountain ----------
  var TRAIL = [[60,280],[180,262],[300,248],[260,222],[390,205],[520,190],[470,165],[600,148],[730,130],[680,108],[800,88],[900,70],[960,52]];
  function trailPoint(f) {
    var segs = [], total = 0;
    for (var i = 1; i < TRAIL.length; i++) { var dx = TRAIL[i][0] - TRAIL[i-1][0], dy = TRAIL[i][1] - TRAIL[i-1][1], d = Math.sqrt(dx*dx + dy*dy); segs.push(d); total += d; }
    var want = Math.max(0, Math.min(1, f)) * total;
    for (var j = 0; j < segs.length; j++) { if (want <= segs[j]) { var t = want / segs[j]; return [TRAIL[j][0] + (TRAIL[j+1][0] - TRAIL[j][0]) * t, TRAIL[j][1] + (TRAIL[j+1][1] - TRAIL[j][1]) * t]; } want -= segs[j]; }
    return TRAIL[TRAIL.length - 1];
  }
  function drawRange(r) {
    var svg = $("range"); svg.innerHTML = "";
    el("path", { d: "M0 300 L0 200 L140 150 L230 175 L340 110 L430 150 L560 70 L640 120 L760 60 L840 95 L960 30 L1060 90 L1200 60 L1200 300Z", fill: "#c9d3e3" }, svg);
    el("path", { d: "M940 44 L960 30 L982 47 L970 45 L960 54 L950 46Z M545 82 L560 70 L578 84 L566 82 L560 90 L552 83Z", fill: "#fff" }, svg);
    el("path", { d: "M0 300 L0 240 L160 200 L300 232 L420 190 L560 220 L700 170 L860 200 L1000 160 L1200 210 L1200 300Z", fill: "#7f8fa6" }, svg);
    el("path", { d: "M0 300 L0 268 L200 250 L380 272 L560 248 L760 266 L980 240 L1200 262 L1200 300Z", fill: "#2f5d50" }, svg);
    // aspens
    [[90,262],[120,258],[1080,250],[1110,246],[1140,252]].forEach(function (a) { el("path", { d: "M" + a[0] + " " + a[1] + " l-7 14 h14z", fill: "#e0a526" }, svg); el("rect", { x: a[0]-1, y: a[1]+14, width: 2, height: 8, fill: "#fff" }, svg); });
    el("polyline", { points: TRAIL.map(function (p) { return p.join(","); }).join(" "), fill: "none", stroke: "#fff", "stroke-width": 3, "stroke-dasharray": "2 7", "stroke-linecap": "round" }, svg);
    // summit flag
    var s = TRAIL[TRAIL.length - 1];
    el("path", { d: "M" + s[0] + " " + s[1] + " v-34", stroke: "#3b4150", "stroke-width": 2.5 }, svg);
    el("path", { d: "M" + s[0] + " " + (s[1]-34) + " l30 8 l-30 8z", fill: "#e0a526" }, svg);
    var st = el("text", { x: s[0] + 36, y: s[1] - 20, "font-size": 15, fill: "#3b4150", "font-family": "Gill Sans, Trebuchet MS, sans-serif" }, svg);
    st.textContent = r.done ? "Debt-free, " + monthLabel(r.months - 1) : "Summit out of reach";
    if (!r.done || r.months === 0) { drawHiker(svg, 0, r); return; }
    // a waypoint flag where each bill is paid off
    // Labels sit on a small pill. When two bills clear close together on the trail, the
    // second label drops below the path so they never overlap.
    var placed = [];
    r.list.slice().sort(function (a, b) { return a.off - b.off; }).forEach(function (b) {
      if (!b.off || b.off === r.months) return;
      var p = trailPoint(b.off / r.months);
      el("circle", { cx: p[0], cy: p[1], r: 6, fill: "#5b4fa0", stroke: "#fff", "stroke-width": 2 }, svg);
      var label = b.name + " paid";
      var w = label.length * 6.6 + 14, x = p[0] + 10, y = p[1] - 30;
      for (var tries = 0; tries < 4 && placed.some(function (q) { return Math.abs(q[0] - x) < Math.max(q[2], w) && Math.abs(q[1] - y) < 24; }); tries++) y += 26;
      if (x + w > 1190) x = p[0] - 10 - w;
      placed.push([x, y, w]);
      el("rect", { x: x, y: y, width: w, height: 20, rx: 10, fill: "#fff", opacity: .92 }, svg);
      var t = el("text", { x: x + 7, y: y + 14, "font-size": 12, fill: "#3b4150", "font-family": "system-ui, sans-serif" }, svg);
      t.textContent = label;
    });
    drawHiker(svg, walk / r.months, r);
  }
  function drawHiker(svg, f, r) {
    var p = trailPoint(f);
    var g = el("g", { transform: "translate(" + p[0] + " " + p[1] + ")" }, svg);
    el("circle", { cx: 0, cy: -22, r: 5, fill: "#3b4150" }, g);
    el("path", { d: "M0 -17 L0 -4 M0 -4 L-5 6 M0 -4 L5 6 M0 -13 L-6 -7 M0 -13 L7 -9", stroke: "#3b4150", "stroke-width": 2.5, "stroke-linecap": "round", fill: "none" }, g);
    el("rect", { x: -7, y: -18, width: 6, height: 8, rx: 1, fill: "#5b4fa0" }, g);
    el("path", { d: "M9 -10 L12 6", stroke: "#8a8f9c", "stroke-width": 1.5 }, g);
  }

  // ---------- bill cards ----------
  var dragFrom = null;
  function renderBills(r) {
    var box = $("bills"); box.innerHTML = "";
    var order = state.order === "custom" ? state.bills.map(function (_, i) { return i; }) : r.first.concat(state.bills.map(function (_, i) { return i; }).filter(function (i) { return r.first.indexOf(i) < 0; }));
    var byI = {}; r.list.forEach(function (b) { byI[b.i] = b; });
    order.forEach(function (i, pos) {
      var b = state.bills[i], s = byI[i];
      var card = document.createElement("div"); card.className = "bill"; card.draggable = true; card.dataset.i = i;
      card.innerHTML = '<div class="grip" aria-hidden="true">⋮⋮<span class="rank">' + (pos + 1) + '</span></div>' +
        '<div class="f">' +
          '<div><label>From</label><input type="text" value="' + esc(b.name) + '" aria-label="Who the bill is from"></div>' +
          '<div><label>Balance $</label><input type="number" min="0" step="10" value="' + b.balance + '" aria-label="Balance"></div>' +
          '<div><label>Rate %</label><input type="number" min="0" step="0.1" value="' + b.apr + '" aria-label="Interest rate"></div>' +
          '<div><label>Minimum $</label><input type="number" min="0" step="5" value="' + b.min + '" aria-label="Monthly minimum"></div>' +
          '<div class="mv"><button type="button" aria-label="Move up">▲</button><button type="button" aria-label="Move down">▼</button><button type="button" class="x" aria-label="Remove bill">✕</button></div>' +
        '</div>' +
        '<div class="done">' + (s && s.off ? "Paid off " + monthLabel(s.off - 1) : (b.balance > 0 ? "Not paid off at this rate" : "Nothing owed")) + '</div>';
      var ins = card.querySelectorAll("input");
      ins[0].addEventListener("input", function () { b.name = this.value; soft(); });
      ins[1].addEventListener("change", function () { b.balance = num(this.value); changed(); });
      ins[2].addEventListener("change", function () { b.apr = num(this.value); changed(); });
      ins[3].addEventListener("change", function () { b.min = num(this.value); changed(); });
      var btns = card.querySelectorAll(".mv button");
      btns[0].addEventListener("click", function () { move(order, pos, pos - 1); });
      btns[1].addEventListener("click", function () { move(order, pos, pos + 1); });
      btns[2].addEventListener("click", function () { state.bills.splice(i, 1); changed(); });
      card.addEventListener("dragstart", function (e) { dragFrom = pos; card.classList.add("drag"); e.dataTransfer.effectAllowed = "move"; e.dataTransfer.setData("text/plain", String(pos)); });
      card.addEventListener("dragend", function () { card.classList.remove("drag"); });
      card.addEventListener("dragover", function (e) { e.preventDefault(); card.classList.add("over"); });
      card.addEventListener("dragleave", function () { card.classList.remove("over"); });
      card.addEventListener("drop", function (e) { e.preventDefault(); card.classList.remove("over"); if (dragFrom !== null) move(order, dragFrom, pos); dragFrom = null; });
      box.appendChild(card);
    });
  }
  // Reordering always switches to "My order", with the bills stored in the order shown.
  function move(order, from, to) {
    if (to < 0 || to >= order.length || from === to) return;
    var o = order.slice(); var it = o.splice(from, 1)[0]; o.splice(to, 0, it);
    state.bills = o.map(function (i) { return state.bills[i]; });
    state.order = "custom"; changed();
  }

  // ---------- render ----------
  function render() {
    var budget = Math.max(0, state.budget);
    var r = simulate(state.bills, budget, state.order);
    var total = state.bills.reduce(function (s, b) { return s + Math.max(0, b.balance); }, 0);
    var mins = state.bills.reduce(function (s, b) { return s + (b.balance > 0 ? Math.max(0, b.min) : 0); }, 0);
    $("budgetV").innerHTML = money(budget) + " <small>a month</small>";
    $("summit").innerHTML = !total ? "Add a bill to plan the climb." : r.done ? "Debt-free by <b>" + monthLabel(r.months - 1) + "</b> — " + r.months + " payment" + (r.months === 1 ? "" : "s") + "." : "<b>At this amount you never reach the top.</b> Interest grows faster than you pay.";
    document.querySelectorAll(".order button").forEach(function (b) { b.classList.toggle("on", b.dataset.o === state.order); });

    var wm = r.done ? r.months : 0;
    walk = Math.min(walk, wm);
    $("walkMonth").max = Math.max(1, wm); $("walkMonth").value = walk; $("walkMonth").disabled = !r.done || !wm;
    $("walkV").innerHTML = r.done ? (walk === 0 ? "Today: <b>" + money(r.totals[0]) + "</b> owed" : monthLabel(walk - 1) + ": <b>" + money(r.totals[walk] || 0) + "</b> left") : "";
    drawRange(r); renderBills(r);

    var msgs = [];
    if (budget < mins) msgs.push("Your " + money(budget) + " a month is less than the minimums (" + money(mins) + "). Call the billers before you miss a payment — most will lower a minimum on a payment plan.");
    if (state.bills.some(function (b) { return b.balance < 0 || b.apr < 0 || b.min < 0; })) msgs.push("Negative numbers are treated as zero.");
    $("msg").innerHTML = msgs.map(function (m) { return '<p class="msg warn">' + esc(m) + "</p>"; }).join("");

    var card = simulate([{ name: "card", balance: total, apr: state.cardApr, min: 0 }], budget, "avalanche");
    $("cardApr").value = state.cardApr;
    $("planInt").textContent = r.done ? cents(r.interest) : "—"; $("planEnd").textContent = r.done ? "clear " + monthLabel(r.months - 1) : "";
    $("cardInt").textContent = card.done ? cents(card.interest) : "—"; $("cardEnd").textContent = card.done ? "clear " + monthLabel(card.months - 1) : "";
    var zero = state.bills.reduce(function (s, b) { return s + (b.apr === 0 ? Math.max(0, b.balance) : 0); }, 0);
    $("diff").innerHTML = r.done && card.done ? "Putting it on the card costs <b>" + cents(Math.max(0, card.interest - r.interest)) + " more</b>." + (zero ? " " + money(zero) + " of what you owe is at 0% now — the cheapest money you'll ever borrow." : "") : "At this monthly amount the card never gets paid off.";

    var n = Object.keys(state.checks).filter(function (k) { return state.checks[k]; }).length;
    document.querySelectorAll(".checks input").forEach(function (c) { c.checked = !!state.checks[c.dataset.c]; });
    $("got").textContent = n === 4 ? "All four done. Now you know exactly what you owe." : n + " of 4 done";

    $("work").innerHTML = "<b>How it's worked out.</b> Each month, interest is added to every bill at its rate ÷ 12. Every open bill gets its minimum, " +
      "and the rest of your " + money(budget) + " goes to the bill at the top of the list until it's clear, then rolls to the next. " +
      (state.order === "avalanche" ? "Highest interest first costs the least." : state.order === "snowball" ? "Smallest first clears whole bills sooner." : "You set the order by hand.") +
      " The card comparison moves everything onto one card at the rate shown, paid with the same monthly amount. Interest compounds monthly and is shown to the cent.";
  }
  function changed() { dirty = true; render(); }
  function soft() { dirty = true; }

  // ---------- wiring ----------
  $("budget").addEventListener("input", function () { state.budget = num(this.value); changed(); });
  $("walkMonth").addEventListener("input", function () { walk = +this.value; render(); });
  $("cardApr").addEventListener("change", function () { state.cardApr = Math.max(0, num(this.value)); changed(); });
  document.querySelectorAll(".order button").forEach(function (b) { b.addEventListener("click", function () { state.order = b.dataset.o; changed(); }); });
  document.querySelectorAll(".checks input").forEach(function (c) { c.addEventListener("change", function () { state.checks[c.dataset.c] = c.checked; changed(); }); });
  $("addBill").addEventListener("click", function () { state.bills.push({ name: "", balance: 0, apr: 0, min: 0 }); changed(); });

  $("saveBtn").addEventListener("click", function () {
    var blob = new Blob([JSON.stringify({ app: APP, version: VERSION, saved: new Date().toISOString(), data: state }, null, 2)], { type: "application/json" });
    var a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = "summit-plan.json";
    document.body.appendChild(a); a.click(); a.remove(); setTimeout(function () { URL.revokeObjectURL(a.href); }, 1000);
    dirty = false; $("fileMsg").textContent = "Saved. Open it here each month to update the balances.";
  });
  $("openBtn").addEventListener("click", function () { $("fileIn").click(); });
  $("fileIn").addEventListener("change", function () {
    var f = this.files[0]; this.value = ""; if (!f) return;
    var rd = new FileReader();
    rd.onload = function () {
      var d; try { d = JSON.parse(rd.result); } catch (e) { d = null; }
      function bad(why) { $("fileMsg").innerHTML = '<span class="warn">That file can\'t be opened here — ' + esc(why) + '.</span> Nothing on screen was changed.'; $("fileMsg").className = "msg"; }
      if (!d || d.app !== APP) return bad("it isn't a Summit Plan file");
      var s = d.data; if (!s || !Array.isArray(s.bills)) return bad("the list of bills is missing");
      var c = { budget: num(s.budget), order: ["avalanche","snowball","custom"].indexOf(s.order) >= 0 ? s.order : "avalanche", cardApr: s.cardApr === undefined ? 24 : num(s.cardApr), checks: {},
                bills: s.bills.slice(0, 40).map(function (b) { return { name: String((b && b.name) || "").slice(0, 80), balance: num(b && b.balance), apr: num(b && b.apr), min: num(b && b.min) }; }) };
      ["itemized","discount","plan","surprise"].forEach(function (k) { c.checks[k] = !!(s.checks && s.checks[k]); });
      if (dirty && !confirm("Replace what's on screen with the saved plan? Unsaved changes will be lost.")) return;
      state = c; dirty = false; walk = 0; $("budget").value = state.budget; render(); $("fileMsg").textContent = "Opened your saved plan.";
    };
    rd.onerror = function () { $("fileMsg").innerHTML = '<span class="warn">That file couldn\'t be read.</span> Nothing on screen was changed.'; };
    rd.readAsText(f);
  });
  $("printBtn").addEventListener("click", function () { window.print(); });
  $("resetBtn").addEventListener("click", function () {
    if (dirty && !confirm("Start over with the example bills? Unsaved changes will be lost.")) return;
    state = sample(); dirty = false; walk = 0; $("budget").value = state.budget; render(); $("fileMsg").textContent = "";
  });
  window.addEventListener("beforeunload", function (e) { if (dirty) { e.preventDefault(); e.returnValue = ""; } });

  $("budget").value = state.budget; render();
})();
</script>
</body>
</html>

Reaches out to

Websites this page contacts when it runs — fonts, chart libraries, data. Found by reading its source.

  • www.w3.org

Licence

Published on Globefin under the MIT License. You may copy, change, and reuse this page, including commercially — just keep the notice below with it.

Copyright © 2026 Shane Hadden. Licensed under the MIT License. Published on Globefin.

Provided as is, without warranty. Any external libraries it loads keep their own licences. Terms →

Sandbox

Scripts run, but the demo has its own throwaway origin. It can't read your session or cookies, can't reach the page around it, and can't navigate your tab. Don't enter real passwords or personal data into any demo.