← Demos
Web Pages · Demos

Offseason Budget Alaska Fisher

by Shane Hadden Oct 11, 2026 9 views 29.4 KB
Sandbox · offseason-budget-alaska-fisher · 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>The Off-Season Ledger — a steady paycheck for a Kodiak salmon fisher</title>
<style>
  :root {
    --spruce: #123b3a; --deep: #0b2a2c; --glacier: #d9ece8; --foam: #f2f7f5;
    --sockeye: #c8323c; --kelp: #4b7a5a; --brass: #b8892e; --ink: #17302f; --mist: #6b8582;
  }
  * { box-sizing: border-box; }
  body { margin: 0; background: var(--foam); color: var(--ink);
         font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; line-height: 1.55; }
  .sans { font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif; }

  /* ---------- harbor ---------- */
  .harbor { position: relative; color: #fff; background: var(--deep); overflow: hidden; }
  .harbor svg.scene { display: block; width: 100%; height: 300px; }
  .harbor .title { position: absolute; left: 0; right: 0; top: 0; padding: 2rem 1.4rem 0; max-width: 1080px; margin: 0 auto; }
  .harbor h1 { font-size: 2.6rem; font-weight: 400; margin: 0; letter-spacing: -.01em; line-height: 1.05; }
  .harbor p { max-width: 520px; margin: .7rem 0 0; color: #cfe3df; font-size: 1.02rem; }
  .harbor .who { margin-top: .9rem; font-size: .85rem; color: #f3d9a4; font-style: italic; }

  main { max-width: 1080px; margin: 0 auto; padding: 1.6rem 1.4rem 2rem; }
  .result { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: end;
            border-bottom: 2px solid var(--spruce); padding-bottom: 1rem; margin-bottom: 1.6rem; }
  .result .pay { font-size: 3.2rem; line-height: 1; color: var(--spruce); }
  .result .pay small { font-size: 1.1rem; color: var(--mist); }
  .result .say { font-size: 1rem; color: var(--ink); max-width: 560px; margin-top: .4rem; }
  .runs { display: flex; gap: .35rem; flex-wrap: wrap; }
  .runs button { font: inherit; font-size: .9rem; border: 1.5px solid var(--spruce); background: #fff; color: var(--spruce);
                 border-radius: 999px; padding: .45rem .9rem; cursor: pointer; }
  .runs button.on { background: var(--spruce); color: #fff; }
  .runs .lab { width: 100%; font-size: .82rem; color: var(--mist); text-align: right; }

  .grid { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 2rem; align-items: start; }
  h2 { font-weight: 400; font-size: 1.35rem; margin: 0 0 .5rem; color: var(--spruce); }
  .note { font-size: .86rem; color: var(--mist); margin: .3rem 0 0; }

  /* ---------- year wheel ---------- */
  .wheel svg { width: 100%; height: auto; display: block; }
  .wheel .wedge { cursor: pointer; transition: fill .2s ease; }
  .wheel .wedge:focus { outline: none; stroke: var(--brass); stroke-width: 3; }
  .legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .82rem; color: var(--mist); margin-top: .4rem; }
  .legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; vertical-align: -1px; margin-right: .3rem; }

  /* ---------- controls ---------- */
  .field { margin: .9rem 0 0; }
  .field label { display: flex; justify-content: space-between; font-size: .92rem; }
  .field label b { font-weight: 600; color: var(--spruce); font-variant-numeric: tabular-nums; }
  input[type=range] { width: 100%; accent-color: var(--sockeye); }
  input[type=number], input[type=text], select {
    font: inherit; font-size: .95rem; width: 100%; padding: .4rem .5rem; border: 1px solid #b9d0cb; border-radius: 6px; background: #fff; color: var(--ink); }
  input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

  /* ---------- tide chart ---------- */
  .tide { background: #fff; border: 1px solid #c9dcd8; border-radius: 4px; padding: 1rem 1rem .6rem; }
  .tide svg { width: 100%; height: auto; display: block; }
  .scrub { display: grid; grid-template-columns: auto 1fr; gap: .8rem; align-items: center; margin-top: .4rem; }
  .monthcard { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .5rem; margin-top: .8rem; }
  .monthcard div { border-left: 3px solid var(--glacier); padding: .1rem .6rem; }
  .monthcard span { display: block; font-size: .78rem; color: var(--mist); }
  .monthcard b { font-size: 1.15rem; font-weight: 400; font-variant-numeric: tabular-nums; }

  .bills { margin-top: 1.6rem; }
  .bill { display: grid; grid-template-columns: 1.6fr .9fr .9fr auto; gap: .4rem; margin-bottom: .4rem; }
  button.ghost { font: inherit; font-size: .88rem; background: none; border: 1px dashed var(--kelp); color: var(--kelp); border-radius: 6px; padding: .4rem .8rem; cursor: pointer; }
  button.x { font: inherit; background: none; border: 1px solid #c9dcd8; color: var(--mist); border-radius: 6px; padding: 0 .55rem; cursor: pointer; }

  .work { margin-top: 1.6rem; font-size: .92rem; background: var(--glacier); padding: 1rem 1.2rem; border-radius: 4px; }
  .warn { color: var(--sockeye); font-weight: 600; }
  .toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.2rem; }
  .toolbar button { font: inherit; font-size: .9rem; border-radius: 6px; padding: .5rem .95rem; cursor: pointer; border: 1px solid var(--spruce); background: #fff; color: var(--spruce); }
  .toolbar button.primary { background: var(--spruce); color: #fff; }
  #fileMsg { margin-top: .6rem; font-size: .9rem; }
  footer { max-width: 1080px; margin: 0 auto; padding: 0 1.4rem 2.4rem; font-size: .82rem; color: var(--mist); }

  @media (max-width: 860px) {
    .grid { grid-template-columns: 1fr; }
    .result { grid-template-columns: 1fr; }
    .runs .lab { text-align: left; }
    .harbor h1 { font-size: 2rem; }
    .harbor svg.scene { height: 340px; }
    .monthcard { grid-template-columns: 1fr 1fr; }
  }
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
  @media print { .toolbar, .runs, .scrub input { display: none; } .harbor svg.scene { height: 160px; } }
</style>
</head>
<body>

<header class="harbor">
  <!-- Kodiak harbor at dusk: mountains, the breakwater, one seiner tied up for the winter. -->
  <svg class="scene" viewBox="0 0 1200 300" preserveAspectRatio="xMidYMax slice" aria-hidden="true">
    <defs>
      <linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0b2a2c"/><stop offset=".7" stop-color="#1f4f4c"/><stop offset="1" stop-color="#3c6e66"/></linearGradient>
      <linearGradient id="veil" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#0b2a2c" stop-opacity=".92"/><stop offset=".45" stop-color="#0b2a2c" stop-opacity=".55"/><stop offset=".7" stop-color="#0b2a2c" stop-opacity="0"/></linearGradient>
      <linearGradient id="sea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#20504c"/><stop offset="1" stop-color="#0b2a2c"/></linearGradient>
    </defs>
    <rect width="1200" height="300" fill="url(#sky)"/>
    <circle cx="980" cy="70" r="26" fill="#f3d9a4" opacity=".85"/>
    <path d="M0 210 L120 150 L190 175 L300 110 L380 160 L470 125 L560 175 L700 120 L790 150 L880 95 L960 140 L1060 115 L1200 165 L1200 230 L0 230Z" fill="#2c5a54"/>
    <path d="M880 95 L908 113 L892 111 L880 124 L868 112 L852 114Z" fill="#e6efec" opacity=".85"/>
    <path d="M0 230 L160 190 L260 212 L420 180 L560 214 L720 186 L860 210 L1000 182 L1200 214 L1200 240 L0 240Z" fill="#1d4440"/>
    <rect y="236" width="1200" height="64" fill="url(#sea)"/>
    <path d="M0 250 Q30 246 60 250 T120 250 T180 250 T240 250 T300 250 T360 250 T420 250 T480 250 T540 250 T600 250 T660 250 T720 250 T780 250 T840 250 T900 250 T960 250 T1020 250 T1080 250 T1140 250 T1200 250" stroke="#4f8a80" stroke-width="1.5" fill="none" opacity=".6"/>
    <rect width="1200" height="300" fill="url(#veil)"/>
    <!-- breakwater + seiner -->
    <rect x="640" y="236" width="560" height="6" fill="#16393a"/>
    <g transform="translate(820 196)">
      <path d="M0 40 L170 40 L155 60 L14 60Z" fill="#c8323c"/>
      <rect x="20" y="20" width="56" height="20" fill="#e9efed"/>
      <rect x="28" y="26" width="10" height="8" fill="#123b3a"/><rect x="44" y="26" width="10" height="8" fill="#123b3a"/>
      <path d="M100 40 L100 -8 M100 -4 L150 30" stroke="#e9efed" stroke-width="3" fill="none"/>
      <path d="M118 40 Q128 20 142 40Z" fill="#d6c79e"/>
      <path d="M-4 66 Q85 74 176 66" stroke="#4f8a80" stroke-width="2" fill="none" opacity=".7"/>
    </g>
  </svg>
  <div class="title">
    <h1>The Off-Season Ledger</h1>
    <p>Salmon pays in three summer months. Rent, fuel and the boat don't wait for summer. Set up your year and this
       works out one steady paycheck you can pay yourself every month, all year.</p>
    <div class="who">Built for a salmon fisher in Kodiak, Alaska, whose income arrives June through August.</div>
  </div>
</header>

<main>
  <section class="result" aria-live="polite">
    <div>
      <div class="pay" id="pay">$0 <small>a month</small></div>
      <div class="say sans" id="say"></div>
    </div>
    <div class="runs sans" role="group" aria-label="How the season goes">
      <span class="lab">What if the run is…</span>
      <button type="button" data-run="0.75">Weak (−25%)</button>
      <button type="button" data-run="1" class="on">As planned</button>
      <button type="button" data-run="1.2">Strong (+20%)</button>
    </div>
  </section>

  <div class="grid">
    <section class="wheel" aria-labelledby="w-h">
      <h2 id="w-h">Your year</h2>
      <svg id="wheel" viewBox="0 0 320 320" role="group" aria-label="Months of the year. Select a month to mark it as a season month."></svg>
      <div class="legend sans">
        <span><i style="background:#c8323c"></i>Season pays</span>
        <span><i style="background:#b8892e"></i>Dividend</span>
        <span><i style="background:#123b3a"></i>Yearly bill due</span>
      </div>
      <p class="note sans">Tap a month to switch it in or out of the season.</p>

      <div class="field sans">
        <label for="season">Season gross <b id="seasonV"></b></label>
        <input id="season" type="range" min="0" max="250000" step="1000">
      </div>
      <div class="field sans">
        <label for="costs">Boat, crew shares &amp; fuel <b id="costsV"></b></label>
        <input id="costs" type="range" min="0" max="80" step="1">
      </div>
      <div class="field sans">
        <label for="tax">Set aside for taxes <b id="taxV"></b></label>
        <input id="tax" type="range" min="0" max="50" step="1">
      </div>
      <div class="two sans">
        <div class="field"><label for="pfd">Dividend (PFD)</label><input id="pfd" type="number" min="0" step="10"></div>
        <div class="field"><label for="pfdMonth">Paid in</label><select id="pfdMonth"></select></div>
      </div>
      <p class="note sans">The PFD changes every year. Enter 0 if you don't expect one.</p>
      <div class="two sans">
        <div class="field"><label for="start">In the bank Jan 1</label><input id="start" type="number" step="100"></div>
        <div class="field"><label for="cushion">Never drop below</label><input id="cushion" type="number" min="0" step="100"></div>
      </div>
    </section>

    <section>
      <h2>The tide chart</h2>
      <div class="tide">
        <svg id="chart" viewBox="0 0 600 240" role="img" aria-label="Month-end balance across the year"></svg>
        <div class="scrub sans">
          <label for="month" style="font-size:.9rem;">Scrub the year</label>
          <input id="month" type="range" min="0" max="11" step="1" value="4">
        </div>
        <div class="monthcard sans" id="monthcard"></div>
      </div>

      <div class="bills sans">
        <h2>Bills that land in one month</h2>
        <div id="bills"></div>
        <button type="button" class="ghost" id="addBill">+ Add a yearly bill</button>
        <p class="note">Insurance, permit and license renewals, haul-out, gear, moorage.</p>
      </div>

      <div class="work sans" id="work"></div>
      <div class="toolbar sans">
        <button type="button" class="primary" id="saveBtn">Save my year</button>
        <button type="button" id="openBtn">Open a saved year</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="sans" role="status"></div>
    </section>
  </div>
</main>

<footer class="sans">
  <p><b>For education only.</b> A planning sketch, not financial or tax advice. Your tax set-aside depends on your own
     return, and no season is guaranteed. 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 MONTHS = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
  var FULL = ["January","February","March","April","May","June","July","August","September","October","November","December"];
  var APP = "globefin-offseason-ledger", VERSION = 2;
  var NS = "http://www.w3.org/2000/svg";

  function sample() {
    return { season: 85000, costs: 35, tax: 25, start: 26000, pfd: 1000, pfdMonth: 9, cushion: 1500, run: 1,
             seasonMonths: [5, 6, 7],
             annual: [ { name: "Boat insurance", amount: 4200, month: 3 }, { name: "Permit & license renewal", amount: 900, month: 0 },
                       { name: "Haul-out & repairs", amount: 3500, month: 3 }, { name: "Net & gear", amount: 2200, month: 4 } ] };
  }
  var state = sample(), dirty = false, focusMonth = 4;
  var $ = function (id) { return document.getElementById(id); };
  var money = function (n) { return (n < 0 ? "−$" : "$") + Math.round(Math.abs(n)).toLocaleString("en-US"); };
  function num(v) { var n = parseFloat(v); return isFinite(n) ? n : 0; }
  function pct(n, hi) { return Math.min(hi, Math.max(0, n)); }
  function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return {"&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;"}[c]; }); }
  function el(tag, attrs, parent) { var e = document.createElementNS(NS, tag); for (var k in attrs) e.setAttribute(k, attrs[k]); if (parent) parent.appendChild(e); return e; }

  // ---------- the arithmetic ----------
  function plan(runFactor) {
    var gross = Math.max(0, state.season) * runFactor;
    var afterCosts = gross * (1 - pct(state.costs, 100) / 100);
    var net = afterCosts * (1 - pct(state.tax, 100) / 100);
    var n = state.seasonMonths.length;
    var inc = MONTHS.map(function (_, i) { return (n && state.seasonMonths.indexOf(i) >= 0 ? net / n : 0) + (i === state.pfdMonth ? Math.max(0, state.pfd) : 0); });
    var bills = MONTHS.map(function (_, i) { return state.annual.reduce(function (s, a) { return s + (a.month === i ? Math.max(0, a.amount) : 0); }, 0); });
    var floor = Math.max(0, state.cushion);
    var inflow = inc.reduce(function (a, b) { return a + b; }, 0), billTotal = bills.reduce(function (a, b) { return a + b; }, 0);
    function run(p) { var b = state.start, low = Infinity, lowM = 0, rows = []; for (var i = 0; i < 12; i++) { b += inc[i] - p - bills[i]; if (b < low) { low = b; lowM = i; } rows.push(b); } return { rows: rows, low: low, lowM: lowM }; }
    // What the year supports: everything in, minus yearly bills, in 12 equal pieces (Dec 31 ends where Jan 1 began).
    var sustainable = Math.max(0, (inflow - billTotal) / 12);
    // The Jan 1 balance that paycheck needs: the floor plus the deepest the running total dips before the season pays.
    var cum = 0, deepest = 0;
    for (var m = 0; m < 12; m++) { cum += inc[m] - sustainable - bills[m]; deepest = Math.min(deepest, cum); }
    var needStart = floor - deepest, pay, limited = false, feasible = true;
    if (state.start >= needStart - 0.005) pay = Math.floor(sustainable);
    else {
      limited = true;
      if (run(0).low < floor - 0.005) { pay = 0; feasible = false; }
      else { var lo = 0, hi = sustainable; for (var k = 0; k < 60; k++) { var mid = (lo + hi) / 2; if (run(mid).low >= floor - 0.005) lo = mid; else hi = mid; } pay = Math.floor(lo); }
    }
    if (inflow - billTotal <= 0) feasible = false;
    return { gross: gross, afterCosts: afterCosts, net: net, inc: inc, bills: bills, floor: floor, inflow: inflow, billTotal: billTotal,
             sustainable: Math.floor(sustainable), needStart: needStart, pay: pay, limited: limited, feasible: feasible, result: run(pay) };
  }

  // ---------- year wheel ----------
  function arc(cx, cy, r1, r2, a0, a1) {
    function pt(r, a) { var t = (a - 90) * Math.PI / 180; return [cx + r * Math.cos(t), cy + r * Math.sin(t)]; }
    var p1 = pt(r2, a0), p2 = pt(r2, a1), p3 = pt(r1, a1), p4 = pt(r1, a0);
    return "M" + p1 + " A" + r2 + " " + r2 + " 0 0 1 " + p2 + " L" + p3 + " A" + r1 + " " + r1 + " 0 0 0 " + p4 + "Z";
  }
  function drawWheel(p) {
    var svg = $("wheel"); svg.innerHTML = "";
    var cx = 160, cy = 160;
    MONTHS.forEach(function (m, i) {
      var on = state.seasonMonths.indexOf(i) >= 0;
      var w = el("path", { d: arc(cx, cy, 70, 140, i * 30 + 1, i * 30 + 29), "class": "wedge", tabindex: "0", role: "button",
                           "aria-pressed": on ? "true" : "false", "aria-label": FULL[i] + (on ? ", season month" : ", off season"),
                           fill: on ? "#c8323c" : (i === focusMonth ? "#bcd8d2" : "#d9ece8") }, svg);
      function toggle() {
        var s = state.seasonMonths.filter(function (x) { return x !== i; });
        if (!on) s.push(i);
        state.seasonMonths = s.sort(function (a, b) { return a - b; }); focusMonth = i; $("month").value = i; changed(true);
        var again = $("wheel").querySelectorAll(".wedge")[i]; if (again) again.focus();
      }
      w.addEventListener("click", toggle);
      w.addEventListener("keydown", function (e) { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); toggle(); } });
      var t = (i * 30 + 15 - 90) * Math.PI / 180;
      var lab = el("text", { x: cx + 108 * Math.cos(t), y: cy + 108 * Math.sin(t) + 5, "text-anchor": "middle", "font-size": "13",
                             fill: on ? "#fff" : "#123b3a", "pointer-events": "none", "font-family": "Avenir Next, Segoe UI, sans-serif" }, svg);
      lab.textContent = m;
      if (i === state.pfdMonth && state.pfd > 0) el("circle", { cx: cx + 150 * Math.cos(t), cy: cy + 150 * Math.sin(t), r: 6, fill: "#b8892e" }, svg);
      if (p.bills[i] > 0) el("circle", { cx: cx + 60 * Math.cos(t), cy: cy + 60 * Math.sin(t), r: 4, fill: "#123b3a" }, svg);
    });
    var c = el("text", { x: cx, y: cy - 4, "text-anchor": "middle", "font-size": "13", fill: "#6b8582", "font-family": "Avenir Next, Segoe UI, sans-serif" }, svg);
    c.textContent = state.seasonMonths.length + " season month" + (state.seasonMonths.length === 1 ? "" : "s");
    var c2 = el("text", { x: cx, y: cy + 16, "text-anchor": "middle", "font-size": "17", fill: "#123b3a" }, svg);
    c2.textContent = money(p.net) + " net";
  }

  // ---------- tide chart ----------
  function drawChart(p) {
    var svg = $("chart"); svg.innerHTML = "";
    var W = 600, H = 240, L = 54, R = 16, T = 18, B = 30;
    var rows = p.result.rows, start = state.start;
    var vals = rows.concat([start, p.floor, 0]);
    var max = Math.max.apply(null, vals), min = Math.min.apply(null, vals);
    if (max === min) max = min + 1;
    var pad = (max - min) * .1; max += pad; min -= pad;
    function x(i) { return L + (i + 0.5) * (W - L - R) / 12; }
    function y(v) { return T + (max - v) / (max - min) * (H - T - B); }
    // gridlines
    for (var g = 0; g <= 3; g++) { var v = min + (max - min) * g / 3;
      el("line", { x1: L, x2: W - R, y1: y(v), y2: y(v), stroke: "#e4efec" }, svg);
      var tl = el("text", { x: L - 8, y: y(v) + 4, "text-anchor": "end", "font-size": "11", fill: "#6b8582", "font-family": "Avenir Next, Segoe UI, sans-serif" }, svg); tl.textContent = money(v); }
    // season bands
    state.seasonMonths.forEach(function (i) { el("rect", { x: x(i) - (W - L - R) / 24, y: T, width: (W - L - R) / 12, height: H - T - B, fill: "#c8323c", opacity: .07 }, svg); });
    // floor
    el("line", { x1: L, x2: W - R, y1: y(p.floor), y2: y(p.floor), stroke: "#c8323c", "stroke-dasharray": "5 5", "stroke-width": 1.5 }, svg);
    var fl = el("text", { x: W - R, y: y(p.floor) - 6, "text-anchor": "end", "font-size": "11", fill: "#c8323c", "font-family": "Avenir Next, Segoe UI, sans-serif" }, svg); fl.textContent = "your floor";
    // water
    var pts = rows.map(function (v, i) { return x(i) + "," + y(v); });
    el("path", { d: "M" + x(0) + "," + (H - B) + " L" + pts.join(" L") + " L" + x(11) + "," + (H - B) + "Z", fill: "#4b7a5a", opacity: .18 }, svg);
    el("polyline", { points: pts.join(" "), fill: "none", stroke: "#123b3a", "stroke-width": 2.5, "stroke-linejoin": "round" }, svg);
    rows.forEach(function (v, i) { el("circle", { cx: x(i), cy: y(v), r: i === p.result.lowM ? 5 : 3, fill: v < p.floor ? "#c8323c" : "#123b3a" }, svg); });
    // month labels
    MONTHS.forEach(function (m, i) { var t = el("text", { x: x(i), y: H - 10, "text-anchor": "middle", "font-size": "11", fill: i === focusMonth ? "#123b3a" : "#6b8582", "font-weight": i === focusMonth ? "700" : "400", "font-family": "Avenir Next, Segoe UI, sans-serif" }, svg); t.textContent = m; });
    // the boat rides the line at the scrubbed month
    var bx = x(focusMonth), by = y(rows[focusMonth]);
    var boat = el("g", { transform: "translate(" + (bx - 16) + " " + (by - 20) + ")" }, svg);
    el("path", { d: "M0 14 L32 14 L28 20 L4 20Z", fill: "#c8323c" }, boat);
    el("rect", { x: 6, y: 6, width: 11, height: 8, fill: "#123b3a" }, boat);
    el("path", { d: "M22 14 L22 0", stroke: "#123b3a", "stroke-width": 2 }, boat);
  }

  function drawMonth(p) {
    var i = focusMonth;
    $("monthcard").innerHTML =
      '<div><span>' + FULL[i] + ' money in</span><b>' + money(p.inc[i]) + '</b></div>' +
      '<div><span>Your paycheck</span><b>' + money(p.pay) + '</b></div>' +
      '<div><span>Yearly bills</span><b>' + (p.bills[i] ? money(p.bills[i]) : "—") + '</b></div>' +
      '<div><span>Balance at month end</span><b' + (p.result.rows[i] < p.floor ? ' class="warn"' : '') + '>' + money(p.result.rows[i]) + '</b></div>';
  }

  function renderBills() {
    var box = $("bills"); box.innerHTML = "";
    state.annual.forEach(function (a, i) {
      var row = document.createElement("div"); row.className = "bill";
      row.innerHTML = '<input type="text" aria-label="Bill" placeholder="What is it?" value="' + esc(a.name) + '">' +
        '<input type="number" aria-label="Amount" min="0" step="10" value="' + a.amount + '">' +
        '<select aria-label="Month due">' + MONTHS.map(function (m, k) { return '<option value="' + k + '"' + (k === a.month ? " selected" : "") + ">" + m + "</option>"; }).join("") + "</select>" +
        '<button type="button" class="x" aria-label="Remove ' + esc(a.name || "bill") + '">✕</button>';
      var ins = row.querySelectorAll("input");
      ins[0].addEventListener("input", function () { a.name = this.value; changed(false); });
      ins[1].addEventListener("input", function () { a.amount = num(this.value); changed(false); });
      row.querySelector("select").addEventListener("change", function () { a.month = +this.value; changed(false); });
      row.querySelector("button").addEventListener("click", function () { state.annual.splice(i, 1); renderBills(); changed(false); });
      box.appendChild(row);
    });
  }

  function fillInputs() {
    ["season","costs","tax","pfd","start","cushion"].forEach(function (k) { $(k).value = state[k]; });
    $("pfdMonth").value = state.pfdMonth;
    document.querySelectorAll(".runs button").forEach(function (b) { b.classList.toggle("on", +b.dataset.run === state.run); });
    renderBills();
  }

  function render() {
    var p = plan(state.run);
    $("seasonV").textContent = money(state.season * state.run) + (state.run !== 1 ? " this run" : "");
    $("costsV").textContent = pct(state.costs, 100) + "%";
    $("taxV").textContent = pct(state.tax, 100) + "%";
    if (!p.feasible) {
      $("pay").innerHTML = "Not yet <small>— the bills come first</small>";
      $("say").innerHTML = p.inflow - p.billTotal <= 0
        ? '<span class="warn">This year\'s income doesn\'t cover the yearly bills.</span> Trim the bills or plan for a bigger season.'
        : '<span class="warn">The bills due before the season pays sink the account below your floor.</span> Start January with ' + money(p.needStart) + ' and you could pay yourself ' + money(p.sustainable) + ' a month.';
    } else {
      $("pay").innerHTML = money(p.pay) + " <small>a month, every month</small>";
      $("say").innerHTML = p.limited
        ? 'That\'s the most your January balance allows before the season pays. The year itself supports <b>' + money(p.sustainable) + '</b> — carry ' + money(p.needStart) + ' into January to get there.'
        : 'Your thinnest month is <b>' + FULL[p.result.lowM] + '</b>, just before the boats go out. Keep at least ' + money(p.needStart) + ' in the bank each January 1 and this paycheck holds year after year.';
    }
    drawWheel(p); drawChart(p); drawMonth(p);
    var gross = Math.max(0, state.season) * state.run;
    $("work").innerHTML = "<b>How it's worked out.</b> Season gross " + money(gross) + " minus " + pct(state.costs, 100) + "% for the boat, crew shares and fuel = " +
      money(p.afterCosts) + ", minus " + pct(state.tax, 100) + "% set aside for taxes = <b>" + money(p.net) + "</b>, spread over " + state.seasonMonths.length +
      " season month(s). Add the " + money(state.pfd) + " dividend in " + FULL[state.pfdMonth] + ". The year supports (" + money(p.inflow) + " in − " +
      money(p.billTotal) + " in yearly bills) ÷ 12 = <b>" + money(p.sustainable) + "</b> a month, ending December where January began. Paying that without any month-end dropping below " +
      money(p.floor) + " needs " + money(p.needStart) + " on January 1: the floor, plus the deepest the running total goes before the season pays.";
  }

  function changed(redrawInputs) { dirty = true; if (redrawInputs) fillInputs(); render(); }

  // ---------- wiring ----------
  MONTHS.forEach(function (m, i) { var o = document.createElement("option"); o.value = i; o.textContent = FULL[i]; $("pfdMonth").appendChild(o); });
  ["season","costs","tax","pfd","start","cushion"].forEach(function (k) { $(k).addEventListener("input", function () { state[k] = num(this.value); changed(false); }); });
  $("pfdMonth").addEventListener("change", function () { state.pfdMonth = +this.value; changed(false); });
  $("month").addEventListener("input", function () { focusMonth = +this.value; render(); });
  $("addBill").addEventListener("click", function () { state.annual.push({ name: "", amount: 0, month: 0 }); renderBills(); changed(false); });
  document.querySelectorAll(".runs button").forEach(function (b) { b.addEventListener("click", function () { state.run = +b.dataset.run; changed(true); }); });

  $("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 = "my-fishing-year.json";
    document.body.appendChild(a); a.click(); a.remove(); setTimeout(function () { URL.revokeObjectURL(a.href); }, 1000);
    dirty = false; $("fileMsg").textContent = "Saved. Open that file here next winter to pick up where you left off.";
  });
  $("openBtn").addEventListener("click", function () { $("fileIn").click(); });
  $("fileIn").addEventListener("change", function () {
    var f = this.files[0]; this.value = ""; if (!f) return;
    var r = new FileReader();
    r.onload = function () {
      var d; try { d = JSON.parse(r.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.'; }
      if (!d || d.app !== APP) return bad("it isn't an Off-Season Ledger file");
      var s = d.data; if (!s || !Array.isArray(s.annual) || !Array.isArray(s.seasonMonths)) return bad("parts of the year are missing");
      var c = sample();
      ["season","costs","tax","start","pfd","cushion"].forEach(function (k) { c[k] = num(s[k]); });
      c.run = [0.75, 1, 1.2].indexOf(+s.run) >= 0 ? +s.run : 1;
      c.pfdMonth = Math.min(11, Math.max(0, parseInt(s.pfdMonth, 10) || 0));
      c.seasonMonths = s.seasonMonths.map(Number).filter(function (x) { return x >= 0 && x < 12; });
      c.annual = s.annual.slice(0, 50).map(function (a) { return { name: String((a && a.name) || "").slice(0, 80), amount: num(a && a.amount), month: Math.min(11, Math.max(0, parseInt(a && a.month, 10) || 0)) }; });
      if (dirty && !confirm("Replace what's on screen with the saved year? Unsaved changes will be lost.")) return;
      state = c; dirty = false; fillInputs(); render(); $("fileMsg").textContent = "Opened your saved year.";
    };
    r.onerror = function () { $("fileMsg").innerHTML = '<span class="warn">That file couldn\'t be read.</span> Nothing on screen was changed.'; };
    r.readAsText(f);
  });
  $("printBtn").addEventListener("click", function () { window.print(); });
  $("resetBtn").addEventListener("click", function () {
    if (dirty && !confirm("Start over with the example year? Unsaved changes will be lost.")) return;
    state = sample(); dirty = false; focusMonth = 4; $("month").value = 4; fillInputs(); render(); $("fileMsg").textContent = "";
  });
  window.addEventListener("beforeunload", function (e) { if (dirty) { e.preventDefault(); e.returnValue = ""; } });

  fillInputs(); 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.