indmoney-networth-log 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dashboard.js CHANGED
@@ -1,12 +1,12 @@
1
- /*! INDmoney Net Worth Log dashboard v1.3.0 | MIT | https://nagarajanseshadri.com/networth-log/ */
1
+ /*! INDmoney Net Worth Log dashboard v1.4.0 | MIT | https://nagarajanseshadri.com/networth-log/ */
2
2
  (function () {
3
3
  var root = document.getElementById('nwlog-root');
4
4
  if (!root || root.getAttribute('data-loaded')) return;
5
5
  root.setAttribute('data-loaded', '1');
6
- window.NWLOG_VERSION = "1.3.0";
7
- var css = "/* VOICE: a calm personal ledger, newspaper graphics-desk clarity, no props.\n IDEA: a daily bank passbook: one line per morning, the balance carried forward.\n PICTURE: the net worth line across the days, latest point marked, crosshair tooltip.\n COLOUR and TYPE: white, ink #101418, one warm yellow slab behind the key figure; Manrope.\n LAYOUT: key figure + chart in first screen, then what moved, then the daily ledger. */\n:root{color-scheme:light dark;--bg:light-dark(#ffffff,#101418);--ink:light-dark(#101418,#eef1f4);--mute:light-dark(#5b6670,#9aa6b1);--line:light-dark(#e3e7eb,#283039);--slab:#ffd84a;--slabInk:#101418;--up:light-dark(#127a52,#4cc38a);--down:light-dark(#b4410f,#f08a5d);--plot:light-dark(#101418,#eef1f4);--card:light-dark(#f6f7f9,#171c22)}\n:root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark}\n*{box-sizing:border-box;min-width:0}\n[hidden]{display:none!important}\nbody{margin:0;background:var(--bg);color:var(--ink);font:16px/1.55 Manrope,system-ui,sans-serif;overflow-x:clip}\n.band{padding:clamp(24px,4vw,56px) max(5vw,16px)}\n.wrap{max-width:1240px;margin:0 auto}\nh1{font-size:clamp(28px,4.2vw,46px);line-height:1.05;font-weight:800;margin:0 0 10px;text-wrap:balance;letter-spacing:-.01em}\nh2{font-size:22px;line-height:1.2;margin:0 0 6px;font-weight:700}\n.sub{color:var(--mute);margin:0 0 22px;max-width:70ch}\n.top{display:grid;grid-template-columns:minmax(0,320px) minmax(0,1fr);gap:clamp(16px,3vw,40px);align-items:stretch}\n.slab{background:var(--slab);color:var(--slabInk);border-radius:6px;padding:22px 22px 20px;display:flex;flex-direction:column;gap:14px}\n.slab .lab{font-size:14px;font-weight:600}\n.slab .big{font-size:clamp(34px,5vw,48px);font-weight:800;line-height:1;white-space:nowrap}\n.kv{display:grid;grid-template-columns:auto 1fr;gap:6px 14px;font-size:15px}\n.kv dt{font-weight:500}.kv dd{margin:0;text-align:right;font-weight:700;white-space:nowrap}\n.fig{position:relative;min-height:340px}.fig>svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}\n.tip{position:absolute;pointer-events:none;background:var(--ink);color:var(--bg);font-size:13px;padding:7px 10px;border-radius:5px;white-space:nowrap;opacity:0;transform:translate(-50%,-115%);transition:opacity .12s}\n.tip b{display:block;font-size:15px}\n.note{font-size:13px;color:var(--mute);margin:10px 0 0}\n.empty{border:1px dashed var(--line);border-radius:6px;padding:28px;color:var(--mute)}\n.moves{display:grid;gap:10px;margin-top:18px;max-width:900px}\n.mv{display:grid;grid-template-columns:9.5em minmax(0,1fr) 7.5em;gap:12px;align-items:center;font-size:15px}\n.mv .track{position:relative;height:14px}\n.mv .axis{position:absolute;left:50%;top:-3px;bottom:-3px;width:1px;background:var(--line)}\n.mv .bar{position:absolute;top:0;height:14px;border-radius:4px}\n.mv .val{text-align:right;font-weight:700;white-space:nowrap}\n.up{color:var(--up)}.down{color:var(--down)}\n.scroll{overflow-x:auto}\ntable{border-collapse:collapse;width:100%;font-size:15px;margin-top:16px}\nth,td{padding:9px 12px;border-bottom:1px solid var(--line);text-align:right;white-space:nowrap}\nth{font-weight:600;color:var(--mute);font-size:13px}\nth:first-child,td:first-child{text-align:left}\ntbody tr:hover{background:var(--card)}\n.status{font-size:14px;color:var(--mute);margin:0 0 14px}\n.exp{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;margin:-6px 6px -6px 0;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--ink);font:700 16px/1 Manrope,system-ui,sans-serif;cursor:pointer;vertical-align:middle}\n.exp:hover{background:var(--card)}.exp:focus-visible{outline:2px solid var(--slab);outline-offset:1px}\n.upd{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-areas:\"badge t1 btn\" \"badge t2 btn\" \"badge t3 btn\" \"badge t4 btn\";gap:6px 16px;align-items:start;margin:0 0 20px;padding:16px 18px;border-radius:8px;background:var(--slab);color:var(--slabInk);font-size:15px;line-height:1.45}\n.upd .badge{grid-area:badge;background:var(--slabInk);color:var(--slab);font-weight:800;font-size:12px;letter-spacing:.02em;padding:5px 9px;border-radius:5px;white-space:nowrap}\n.upd .t1{grid-area:t1;font-size:17px;font-weight:800}.upd .t2{grid-area:t2}.upd .t3{grid-area:t3}.upd .t4{grid-area:t4}\n.upd b{font-weight:800}\n.upd .x{grid-area:btn;min-height:36px;padding:0 12px;border:1px solid rgba(16,20,24,.35);border-radius:999px;background:none;color:inherit;font:600 13px Manrope,system-ui,sans-serif;cursor:pointer;white-space:nowrap}\n.upd .copy{min-height:44px;padding:0 18px;margin:4px 8px 4px 0;border:0;border-radius:999px;background:var(--slabInk);color:var(--slab);font:800 15px Manrope,system-ui,sans-serif;cursor:pointer}\n.upd .copy:focus-visible,.upd .x:focus-visible{outline:2px solid var(--slabInk);outline-offset:2px}\n.upd textarea{width:100%;min-height:140px;margin-top:6px;padding:10px;border:1px solid rgba(16,20,24,.35);border-radius:6px;background:#fffbe6;color:#101418;font:13px/1.4 ui-monospace,Menlo,monospace}\n.upd .msg{margin:2px 0 0;font-weight:700}\n@media(max-width:600px){.upd{grid-template-columns:minmax(0,1fr);grid-template-areas:\"badge\" \"t1\" \"btn\" \"t2\" \"t3\" \"t4\"}.upd .badge,.upd .x{justify-self:start}}\n.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:3px;margin:0 0 10px;gap:2px;flex-wrap:wrap}\n.seg button{min-height:38px;padding:0 14px;border:0;border-radius:999px;background:none;color:var(--ink);font:600 14px Manrope,system-ui,sans-serif;cursor:pointer}\n.seg button[aria-pressed=true]{background:var(--ink);color:var(--bg)}\n.seg button:focus-visible{outline:2px solid var(--slab);outline-offset:1px}\n.info{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin-left:4px;padding:0;border:1px solid var(--line);border-radius:50%;background:none;color:var(--mute);font:700 12px/1 Manrope,system-ui,sans-serif;cursor:pointer;vertical-align:middle;position:relative}\n.info::after{content:\"\";position:absolute;inset:-11px}\n.info[aria-expanded=true]{background:var(--ink);color:var(--bg);border-color:var(--ink)}\n.info:focus-visible{outline:2px solid var(--slab);outline-offset:1px}\n.colnote{margin:14px 0 0;padding:12px 14px;border-left:3px solid var(--slab);background:var(--card);border-radius:4px;font-size:14px;max-width:70ch}\n.colnote b{font-weight:700}\ntr.det td{padding:4px 12px 14px;background:var(--card);text-align:left;white-space:normal}\ntr.det:hover{background:none}\n.dl{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,max-content);gap:4px 28px;margin:0;padding:8px 0 0 calc(32px + 6px);border-left:2px solid var(--line);margin-left:15px;font-size:14px}\n.dl dt{padding-left:12px}.dl dd{margin:0;text-align:right;font-weight:600;white-space:nowrap}\n.dl .sub2{padding-left:32px;color:var(--mute);font-weight:400}.dl dd.sub2{color:var(--mute);font-weight:400}\n.tabs{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 18px}\n.tabs a{display:inline-flex;align-items:center;min-height:44px;padding:0 16px;border:1px solid var(--line);border-radius:999px;color:var(--ink);text-decoration:none;font-weight:600;font-size:15px}\n.tabs a[aria-current=page]{background:var(--ink);color:var(--bg);border-color:var(--ink)}\n.tabs a:focus-visible{outline:2px solid var(--slab);outline-offset:2px}\n@media(max-width:760px){.top{grid-template-columns:minmax(0,1fr)}}\n@media(max-width:600px){table{font-size:13px}.mv{grid-template-columns:7em minmax(0,1fr) 6.2em;font-size:14px}}\n@media(prefers-reduced-motion:reduce){.tip{transition:none}}\n";
6
+ window.NWLOG_VERSION = "1.4.0";
7
+ var css = "/* VOICE: a calm personal ledger, newspaper graphics-desk clarity, no props.\n IDEA: a daily bank passbook: one line per morning, the balance carried forward.\n PICTURE: the net worth line across the days, latest point marked, crosshair tooltip.\n COLOUR and TYPE: white, ink #101418, one warm yellow slab behind the key figure; Manrope.\n LAYOUT: key figure + chart in first screen, then what moved, then the daily ledger. */\n:root{color-scheme:light dark;--bg:light-dark(#ffffff,#101418);--ink:light-dark(#101418,#eef1f4);--mute:light-dark(#5b6670,#9aa6b1);--line:light-dark(#e3e7eb,#283039);--slab:#ffd84a;--slabInk:#101418;--up:light-dark(#127a52,#4cc38a);--down:light-dark(#b4410f,#f08a5d);--plot:light-dark(#101418,#eef1f4);--card:light-dark(#f6f7f9,#171c22)}\n:root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark}\n*{box-sizing:border-box;min-width:0}\n[hidden]{display:none!important}\nbody{margin:0;background:var(--bg);color:var(--ink);font:16px/1.55 Manrope,system-ui,sans-serif;overflow-x:clip}\n.band{padding:clamp(24px,4vw,56px) max(5vw,16px)}\n.wrap{max-width:1240px;margin:0 auto}\nh1{font-size:clamp(28px,4.2vw,46px);line-height:1.05;font-weight:800;margin:0 0 10px;text-wrap:balance;letter-spacing:-.01em}\nh2{font-size:22px;line-height:1.2;margin:0 0 6px;font-weight:700}\n.sub{color:var(--mute);margin:0 0 22px;max-width:70ch}\n.top{display:grid;grid-template-columns:minmax(0,320px) minmax(0,1fr);gap:clamp(16px,3vw,40px);align-items:stretch}\n.slab{background:var(--slab);color:var(--slabInk);border-radius:6px;padding:22px 22px 20px;display:flex;flex-direction:column;gap:14px}\n.slab .lab{font-size:14px;font-weight:600}\n.slab .big{font-size:clamp(34px,5vw,48px);font-weight:800;line-height:1;white-space:nowrap}\n.kv{display:grid;grid-template-columns:auto 1fr;gap:6px 14px;font-size:15px}\n.kv dt{font-weight:500}.kv dd{margin:0;text-align:right;font-weight:700;white-space:nowrap}\n.fig{position:relative;min-height:340px}.fig>svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}\n.tip{position:absolute;pointer-events:none;background:var(--ink);color:var(--bg);font-size:13px;padding:7px 10px;border-radius:5px;white-space:nowrap;opacity:0;transform:translate(-50%,-115%);transition:opacity .12s}\n.tip b{display:block;font-size:15px}\n.note{font-size:13px;color:var(--mute);margin:10px 0 0}\n.empty{border:1px dashed var(--line);border-radius:6px;padding:28px;color:var(--mute)}\n.moves{display:grid;gap:10px;margin-top:18px;max-width:900px}\n.mv{display:grid;grid-template-columns:9.5em minmax(0,1fr) 7.5em;gap:12px;align-items:center;font-size:15px}\n.mv .track{position:relative;height:14px}\n.mv .axis{position:absolute;left:50%;top:-3px;bottom:-3px;width:1px;background:var(--line)}\n.mv .bar{position:absolute;top:0;height:14px;border-radius:4px}\n.mv .val{text-align:right;font-weight:700;white-space:nowrap}\n.up{color:var(--up)}.down{color:var(--down)}\n.scroll{overflow-x:auto}\ntable{border-collapse:collapse;width:100%;font-size:15px;margin-top:16px}\nth,td{padding:9px 12px;border-bottom:1px solid var(--line);text-align:right;white-space:nowrap}\nth{font-weight:600;color:var(--mute);font-size:13px}\nth:first-child,td:first-child{text-align:left}\ntbody tr:hover{background:var(--card)}\n.status{font-size:14px;color:var(--mute);margin:0 0 14px}\n.exp{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;margin:-6px 6px -6px 0;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--ink);font:700 16px/1 Manrope,system-ui,sans-serif;cursor:pointer;vertical-align:middle}\n.exp:hover{background:var(--card)}.exp:focus-visible{outline:2px solid var(--slab);outline-offset:1px}\n.upd{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-areas:\"badge t1 btn\" \"badge t2 btn\" \"badge t3 btn\" \"badge t4 btn\";gap:6px 16px;align-items:start;margin:0 0 20px;padding:16px 18px;border-radius:8px;background:var(--slab);color:var(--slabInk);font-size:15px;line-height:1.45}\n.upd .badge{grid-area:badge;background:var(--slabInk);color:var(--slab);font-weight:800;font-size:12px;letter-spacing:.02em;padding:5px 9px;border-radius:5px;white-space:nowrap}\n.upd .t1{grid-area:t1;font-size:17px;font-weight:800}.upd .t2{grid-area:t2}.upd .t3{grid-area:t3}.upd .t4{grid-area:t4}\n.upd b{font-weight:800}\n.upd .x{grid-area:btn;min-height:36px;padding:0 12px;border:1px solid rgba(16,20,24,.35);border-radius:999px;background:none;color:inherit;font:600 13px Manrope,system-ui,sans-serif;cursor:pointer;white-space:nowrap}\n.upd .copy{min-height:44px;padding:0 18px;margin:4px 8px 4px 0;border:0;border-radius:999px;background:var(--slabInk);color:var(--slab);font:800 15px Manrope,system-ui,sans-serif;cursor:pointer}\n.upd .copy:focus-visible,.upd .x:focus-visible{outline:2px solid var(--slabInk);outline-offset:2px}\n.upd textarea{width:100%;min-height:140px;margin-top:6px;padding:10px;border:1px solid rgba(16,20,24,.35);border-radius:6px;background:#fffbe6;color:#101418;font:13px/1.4 ui-monospace,Menlo,monospace}\n.upd .msg{margin:2px 0 0;font-weight:700}\n@media(max-width:600px){.upd{grid-template-columns:minmax(0,1fr);grid-template-areas:\"badge\" \"t1\" \"btn\" \"t2\" \"t3\" \"t4\"}.upd .badge,.upd .x{justify-self:start}}\n.rng{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;margin:0 0 18px}\n.rng .lab{font-size:13px;font-weight:600;color:var(--mute);margin-right:4px}\n.rng button{min-height:36px;padding:0 13px;border:1px solid var(--line);border-radius:999px;background:none;color:var(--ink);font:600 14px Manrope,system-ui,sans-serif;cursor:pointer}\n.rng button[aria-pressed=true]{background:var(--ink);color:var(--bg);border-color:var(--ink)}\n.rng button:focus-visible,.more button:focus-visible{outline:2px solid var(--slab);outline-offset:2px}\n.cust{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:-8px 0 18px;font-size:14px}\n.cust input{min-height:36px;padding:0 8px;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--ink);font:15px Manrope,system-ui,sans-serif}\n.cust .go{min-height:36px;padding:0 14px;border:0;border-radius:999px;background:var(--ink);color:var(--bg);font:700 14px Manrope,system-ui,sans-serif;cursor:pointer}\n.cust .err{color:var(--down);font-weight:600}\n.more{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:12px;font-size:14px;color:var(--mute)}\n.more button{min-height:36px;padding:0 14px;border:1px solid var(--line);border-radius:999px;background:none;color:var(--ink);font:600 14px Manrope,system-ui,sans-serif;cursor:pointer}\n.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:3px;margin:0 0 10px;gap:2px;flex-wrap:wrap}\n.seg button{min-height:38px;padding:0 14px;border:0;border-radius:999px;background:none;color:var(--ink);font:600 14px Manrope,system-ui,sans-serif;cursor:pointer}\n.seg button[aria-pressed=true]{background:var(--ink);color:var(--bg)}\n.seg button:focus-visible{outline:2px solid var(--slab);outline-offset:1px}\n.info{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin-left:4px;padding:0;border:1px solid var(--line);border-radius:50%;background:none;color:var(--mute);font:700 12px/1 Manrope,system-ui,sans-serif;cursor:pointer;vertical-align:middle;position:relative}\n.info::after{content:\"\";position:absolute;inset:-11px}\n.info[aria-expanded=true]{background:var(--ink);color:var(--bg);border-color:var(--ink)}\n.info:focus-visible{outline:2px solid var(--slab);outline-offset:1px}\n.colnote{margin:14px 0 0;padding:12px 14px;border-left:3px solid var(--slab);background:var(--card);border-radius:4px;font-size:14px;max-width:70ch}\n.colnote b{font-weight:700}\ntr.det td{padding:4px 12px 14px;background:var(--card);text-align:left;white-space:normal}\ntr.det:hover{background:none}\n.dl{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,max-content);gap:4px 28px;margin:0;padding:8px 0 0 calc(32px + 6px);border-left:2px solid var(--line);margin-left:15px;font-size:14px}\n.dl dt{padding-left:12px}.dl dd{margin:0;text-align:right;font-weight:600;white-space:nowrap}\n.dl .sub2{padding-left:32px;color:var(--mute);font-weight:400}.dl dd.sub2{color:var(--mute);font-weight:400}\n.tabs{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 18px}\n.tabs a{display:inline-flex;align-items:center;min-height:44px;padding:0 16px;border:1px solid var(--line);border-radius:999px;color:var(--ink);text-decoration:none;font-weight:600;font-size:15px}\n.tabs a[aria-current=page]{background:var(--ink);color:var(--bg);border-color:var(--ink)}\n.tabs a:focus-visible{outline:2px solid var(--slab);outline-offset:2px}\n@media(max-width:760px){.top{grid-template-columns:minmax(0,1fr)}}\n@media(max-width:600px){table{font-size:13px}.mv{grid-template-columns:7em minmax(0,1fr) 6.2em;font-size:14px}}\n@media(prefers-reduced-motion:reduce){.tip{transition:none}}\n";
8
8
  var st = document.createElement('style'); st.textContent = css; document.head.appendChild(st);
9
- root.innerHTML = "<section class=\"band\"><div class=\"wrap\">\n <div class=\"upd\" id=\"upd\" role=\"region\" aria-label=\"Update\" hidden>\n <span class=\"badge\">ONE STEP</span>\n <div class=\"t1\" id=\"updV\"></div>\n <button type=\"button\" class=\"x\" id=\"updX\">Hide for now</button>\n <div class=\"t2\" id=\"updH\"></div>\n <div class=\"t3\"><button type=\"button\" class=\"copy\" id=\"updCopy\">Copy update message</button>then open a new chat in Claude, paste it and press Enter. It takes a minute, and your history is kept.</div>\n <div class=\"t4\"><p class=\"msg\" id=\"updMsg\" role=\"status\" hidden></p><textarea id=\"updText\" readonly hidden aria-label=\"Update message\"></textarea></div>\n </div>\n <nav class=\"tabs\" id=\"tabs\" aria-label=\"Whose net worth\" hidden></nav>\n <p class=\"status\" id=\"status\">Loading your log\u2026</p>\n <h1 id=\"headline\">Your net worth, logged every morning</h1>\n <p class=\"sub\" id=\"lede\">One snapshot from INDmoney each day at about 8:40 am IST: everything owned minus loans, for each person and the family together.</p>\n <div class=\"top\">\n <div class=\"slab\" id=\"slab\">\n <div><div class=\"lab\" id=\"slabLab\">Net worth</div><div class=\"big\" id=\"nwBig\">\u2014</div></div>\n <dl class=\"kv\">\n <dt>Since previous day</dt><dd id=\"dDay\">\u2014</dd>\n <dt id=\"dStartLab\">Since first log</dt><dd id=\"dStart\">\u2014</dd>\n <dt id=\"kAssetsLab\">Assets</dt><dd id=\"kAssets\">\u2014</dd>\n <dt id=\"kAltLab\">Liabilities</dt><dd id=\"kLoan\">\u2014</dd>\n </dl>\n </div>\n <div>\n <div class=\"seg\" role=\"group\" aria-label=\"What to show\"><button type=\"button\" data-b=\"net\" aria-pressed=\"true\">Net worth</button><button type=\"button\" data-b=\"gross\" aria-pressed=\"false\">Before liabilities</button></div>\n <div class=\"fig\" id=\"fig\"><svg id=\"chart\" role=\"img\" aria-label=\"Net worth by day\"></svg><div class=\"tip\" id=\"tip\"></div></div>\n <p class=\"note\" id=\"chartNote\"></p>\n </div>\n </div>\n</div></section>\n\n<section class=\"band\" style=\"padding-top:0\"><div class=\"wrap\">\n <h2 id=\"movesH\">What moved</h2>\n <p class=\"sub\" id=\"movesSub\" style=\"margin-bottom:0\">Change in each part of your net worth between the first and latest log.</p>\n <div class=\"moves\" id=\"moves\"></div>\n</div></section>\n\n<section class=\"band\" style=\"padding-top:0\" id=\"banksBand\" hidden><div class=\"wrap\">\n <h2>Bank accounts</h2>\n <p class=\"sub\" style=\"margin-bottom:0\" id=\"banksSub\">Savings balance in each account, so you can see which one moved.</p>\n <div class=\"scroll\"><table><thead id=\"bankHead\"></thead><tbody id=\"bankBody\"></tbody></table></div>\n</div></section>\n\n<section class=\"band\" style=\"padding-top:0\" id=\"liabBand\" hidden><div class=\"wrap\">\n <h2>Loans and credit cards</h2>\n <p class=\"sub\" style=\"margin-bottom:0\" id=\"liabSub\">What you owe, item by item.</p>\n <div class=\"scroll\"><table><thead id=\"liabHead\"></thead><tbody id=\"liabBody\"></tbody></table></div>\n</div></section>\n\n<section class=\"band\" style=\"padding-top:0\"><div class=\"wrap\">\n <h2>Day by day</h2>\n <p class=\"sub\" style=\"margin-bottom:0\">Values as INDmoney reported them that morning.</p>\n <p class=\"colnote\" id=\"colNote\" role=\"status\" hidden></p>\n <div class=\"scroll\"><table id=\"tbl\"><thead><tr><th>Date</th><th>Net worth<button type=\"button\" class=\"info\" data-k=\"nw\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What net worth means\">i</button></th><th>Day change<button type=\"button\" class=\"info\" data-k=\"dc\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What day change means\">i</button></th><th>Mutual funds</th><th>Bonds</th><th>Indian stocks</th><th>US stocks<button type=\"button\" class=\"info\" data-k=\"us\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What US stocks means\">i</button></th><th>Other assets<button type=\"button\" class=\"info\" data-k=\"oa\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What other assets means\">i</button></th><th>Liabilities<button type=\"button\" class=\"info\" data-k=\"ln\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What liabilities means\">i</button></th></tr></thead><tbody id=\"tbody\"></tbody></table></div>\n</div></section>\n\n<footer class=\"band\" style=\"padding-top:0\"><div class=\"wrap\"><p class=\"note\">Net worth log v1.3.0 \u00b7 figures from INDmoney \u00b7 a tracking tool, not financial advice</p></div></footer>\n\n";
9
+ root.innerHTML = "<section class=\"band\"><div class=\"wrap\">\n <div class=\"upd\" id=\"upd\" role=\"region\" aria-label=\"Update\" hidden>\n <span class=\"badge\">ONE STEP</span>\n <div class=\"t1\" id=\"updV\"></div>\n <button type=\"button\" class=\"x\" id=\"updX\">Hide for now</button>\n <div class=\"t2\" id=\"updH\"></div>\n <div class=\"t3\"><button type=\"button\" class=\"copy\" id=\"updCopy\">Copy update message</button>then open a new chat in Claude, paste it and press Enter. It takes a minute, and your history is kept.</div>\n <div class=\"t4\"><p class=\"msg\" id=\"updMsg\" role=\"status\" hidden></p><textarea id=\"updText\" readonly hidden aria-label=\"Update message\"></textarea></div>\n </div>\n <nav class=\"tabs\" id=\"tabs\" aria-label=\"Whose net worth\" hidden></nav>\n <p class=\"status\" id=\"status\">Loading your log\u2026</p>\n <h1 id=\"headline\">Your net worth, logged every morning</h1>\n <p class=\"sub\" id=\"lede\">One snapshot from INDmoney each day at about 8:40 am IST: everything owned minus loans, for each person and the family together.</p>\n <div class=\"rng\" id=\"rng\" role=\"group\" aria-label=\"Date range\"><span class=\"lab\">Range</span><button type=\"button\" data-r=\"3m\" aria-pressed=\"true\">3 months</button><button type=\"button\" data-r=\"6m\" aria-pressed=\"false\">6 months</button><button type=\"button\" data-r=\"1y\" aria-pressed=\"false\">1 year</button><button type=\"button\" data-r=\"2y\" aria-pressed=\"false\">2 years</button><button type=\"button\" data-r=\"3y\" aria-pressed=\"false\">3 years</button><button type=\"button\" data-r=\"5y\" aria-pressed=\"false\">5 years</button><button type=\"button\" data-r=\"custom\" aria-pressed=\"false\" aria-expanded=\"false\" aria-controls=\"cust\">Custom\u2026</button></div>\n <form class=\"cust\" id=\"cust\" hidden><label>From <input type=\"date\" id=\"cFrom\" required></label><label>To <input type=\"date\" id=\"cTo\" required></label><button type=\"submit\" class=\"go\">Show</button><span class=\"err\" id=\"cErr\" role=\"status\"></span></form>\n <div class=\"top\">\n <div class=\"slab\" id=\"slab\">\n <div><div class=\"lab\" id=\"slabLab\">Net worth</div><div class=\"big\" id=\"nwBig\">\u2014</div></div>\n <dl class=\"kv\">\n <dt>Since previous day</dt><dd id=\"dDay\">\u2014</dd>\n <dt id=\"dStartLab\">Since first log</dt><dd id=\"dStart\">\u2014</dd>\n <dt id=\"kAssetsLab\">Assets</dt><dd id=\"kAssets\">\u2014</dd>\n <dt id=\"kAltLab\">Liabilities</dt><dd id=\"kLoan\">\u2014</dd>\n </dl>\n </div>\n <div>\n <div class=\"seg\" role=\"group\" aria-label=\"What to show\"><button type=\"button\" data-b=\"net\" aria-pressed=\"true\">Net worth</button><button type=\"button\" data-b=\"gross\" aria-pressed=\"false\">Before liabilities</button></div>\n <div class=\"fig\" id=\"fig\"><svg id=\"chart\" role=\"img\" aria-label=\"Net worth by day\"></svg><div class=\"tip\" id=\"tip\"></div></div>\n <p class=\"note\" id=\"chartNote\"></p>\n </div>\n </div>\n</div></section>\n\n<section class=\"band\" style=\"padding-top:0\"><div class=\"wrap\">\n <h2 id=\"movesH\">What moved</h2>\n <p class=\"sub\" id=\"movesSub\" style=\"margin-bottom:0\">Change in each part of your net worth between the first and latest log.</p>\n <div class=\"moves\" id=\"moves\"></div>\n</div></section>\n\n<section class=\"band\" style=\"padding-top:0\" id=\"banksBand\" hidden><div class=\"wrap\">\n <h2>Bank accounts</h2>\n <p class=\"sub\" style=\"margin-bottom:0\" id=\"banksSub\">Savings balance in each account, so you can see which one moved.</p>\n <div class=\"scroll\"><table><thead id=\"bankHead\"></thead><tbody id=\"bankBody\"></tbody></table></div>\n</div></section>\n\n<section class=\"band\" style=\"padding-top:0\" id=\"liabBand\" hidden><div class=\"wrap\">\n <h2>Loans and credit cards</h2>\n <p class=\"sub\" style=\"margin-bottom:0\" id=\"liabSub\">What you owe, item by item.</p>\n <div class=\"scroll\"><table><thead id=\"liabHead\"></thead><tbody id=\"liabBody\"></tbody></table></div>\n</div></section>\n\n<section class=\"band\" style=\"padding-top:0\"><div class=\"wrap\">\n <h2>Day by day</h2>\n <p class=\"sub\" style=\"margin-bottom:0\" id=\"tblSub\">Values as INDmoney reported them that morning.</p>\n <p class=\"colnote\" id=\"colNote\" role=\"status\" hidden></p>\n <div class=\"scroll\"><table id=\"tbl\"><thead><tr><th>Date</th><th>Net worth<button type=\"button\" class=\"info\" data-k=\"nw\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What net worth means\">i</button></th><th>Day change<button type=\"button\" class=\"info\" data-k=\"dc\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What day change means\">i</button></th><th>Mutual funds</th><th>Bonds</th><th>Indian stocks</th><th>US stocks<button type=\"button\" class=\"info\" data-k=\"us\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What US stocks means\">i</button></th><th>Other assets<button type=\"button\" class=\"info\" data-k=\"oa\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What other assets means\">i</button></th><th>Liabilities<button type=\"button\" class=\"info\" data-k=\"ln\" aria-expanded=\"false\" aria-controls=\"colNote\" aria-label=\"What liabilities means\">i</button></th></tr></thead><tbody id=\"tbody\"></tbody></table></div>\n <div class=\"more\" id=\"more\" hidden><span id=\"moreTxt\"></span><button type=\"button\" id=\"moreBtn\">Show 60 more</button><button type=\"button\" id=\"allBtn\">Show all</button></div>\n</div></section>\n\n<footer class=\"band\" style=\"padding-top:0\"><div class=\"wrap\"><p class=\"note\">Net worth log v1.4.0 \u00b7 figures from INDmoney \u00b7 a tracking tool, not financial advice</p></div></footer>\n\n";
10
10
  {
11
11
  const $ = (id) => document.getElementById(id);
12
12
  const PARTS = [
@@ -27,7 +27,7 @@ const pct = (v, base) => base ? Math.abs((v/base)*100).toFixed(2) + '%' : '';
27
27
  const fmtDate = (d, opt) => new Date(d + 'T00:00:00').toLocaleDateString('en-IN', opt || {day:'numeric', month:'short'});
28
28
  function setDelta(el, v){ el.textContent = signed(v); }
29
29
 
30
- let rows = [], basis = 'net';
30
+ let rows = [], fullRows = [], basis = 'net', tableLimit = 31;
31
31
  const val = (r) => basis === 'gross' ? r.assets : r.net_worth;
32
32
 
33
33
  function draw(){
@@ -52,8 +52,10 @@ function draw(){
52
52
  if (!narrow) g += `<text x="${m.l - 10}" y="${yy}" dy="4" text-anchor="end" font-size="12" fill="var(--mute)">${short(v)}</text>`;
53
53
  }
54
54
  const step = Math.max(1, Math.ceil(n / (narrow ? 4 : 8)));
55
+ const longSpan = n > 1 && (Date.parse(rows[n - 1].date) - Date.parse(rows[0].date)) > 300 * 864e5;
56
+ const xl = (d) => longSpan ? fmtDate(d, {month:'short', year:'2-digit'}) : fmtDate(d);
55
57
  rows.forEach((r, i) => {
56
- if (i % step === 0 || i === n - 1) g += `<text x="${x(i).toFixed(1)}" y="${H - 8}" text-anchor="middle" font-size="12" fill="var(--mute)">${fmtDate(r.date)}</text>`;
58
+ if (i % step === 0 || i === n - 1) g += `<text x="${x(i).toFixed(1)}" y="${H - 8}" text-anchor="middle" font-size="12" fill="var(--mute)">${xl(r.date)}</text>`;
57
59
  });
58
60
  const path = rows.map((r, i) => (i ? 'L' : 'M') + x(i).toFixed(1) + ',' + y(val(r)).toFixed(1)).join('');
59
61
  if (n > 1) g += `<path d="${path}" fill="none" stroke="var(--plot)" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`;
@@ -86,20 +88,23 @@ const ro = new ResizeObserver(draw); ro.observe($('chart'));
86
88
  function render(){
87
89
  const n = rows.length;
88
90
  if (!n){
89
- $('status').textContent = 'No days logged yet. The first snapshot arrives with the next morning run.';
91
+ $('status').textContent = fullRows.length ? 'No days logged in this range. Pick a longer range.' : 'No days logged yet. The first snapshot arrives with the next morning run.';
90
92
  $('moves').innerHTML = '<div class="empty">Changes appear once two days are logged.</div>';
91
- $('tbody').innerHTML = '';
93
+ $('tbody').innerHTML = ''; $('more').hidden = true;
92
94
  draw(); return;
93
95
  }
94
- const L = rows[n - 1], F = rows[0], P = n > 1 ? rows[n - 2] : null;
96
+ const L = rows[n - 1], F = rows[0];
97
+ const li = fullRows.findIndex(r => r.date === L.date), P = li > 0 ? fullRows[li - 1] : null;
95
98
  const have = new Set(rows.map(r => r.date)), gaps = [];
96
99
  for (let t = new Date(F.date + 'T00:00:00Z'); t <= new Date(L.date + 'T00:00:00Z'); t.setUTCDate(t.getUTCDate() + 1)){
97
100
  const d = t.toISOString().slice(0, 10); if (!have.has(d)) gaps.push(d);
98
101
  }
99
102
  const todayIST = new Date(Date.now() + 5.5 * 3600e3).toISOString().slice(0, 10);
100
103
  const nowH = new Date(Date.now() + 5.5 * 3600e3).getUTCHours() + new Date(Date.now() + 5.5 * 3600e3).getUTCMinutes() / 60;
101
- const lateToday = L.date < todayIST && nowH >= 9.25;
102
- let st = `${n} ${n === 1 ? 'day' : 'days'} logged · latest ${fmtDate(L.date, {weekday:'short', day:'numeric', month:'short', year:'numeric'})}`;
104
+ const newest = fullRows[fullRows.length - 1];
105
+ const lateToday = newest.date < todayIST && nowH >= 9.25;
106
+ const plus = members.some(m => moreOlder[m.id]) ? '+' : '';
107
+ let st = `${fullRows.length}${plus} ${fullRows.length === 1 && !plus ? 'day' : 'days'} logged${n < fullRows.length ? ` · ${n} in this range` : ''} · latest ${fmtDate(newest.date, {weekday:'short', day:'numeric', month:'short', year:'numeric'})}`;
103
108
  if (lateToday) st += ' · ⚠ today not logged yet: check INDmoney sign-in';
104
109
  if (gaps.length) st += ` · ⚠ missing ${gaps.length} ${gaps.length === 1 ? 'day' : 'days'}: ${gaps.slice(-5).map(d => fmtDate(d)).join(', ')}`;
105
110
  $('status').textContent = st;
@@ -112,13 +117,14 @@ function render(){
112
117
  $('kAltLab').textContent = g ? 'Net worth' : 'Liabilities';
113
118
  $('kLoan').textContent = short(g ? L.net_worth : L.liabilities);
114
119
  $('chart').setAttribute('aria-label', g ? 'Assets before liabilities by day' : 'Net worth by day');
115
- $('dStartLab').textContent = 'Since ' + fmtDate(F.date);
120
+ const fy = F.date.slice(0, 4) !== L.date.slice(0, 4) ? {day:'numeric', month:'short', year:'numeric'} : undefined;
121
+ $('dStartLab').textContent = 'Since ' + fmtDate(F.date, fy);
116
122
  if (P){ setDelta($('dDay'), val(L) - val(P)); } else $('dDay').textContent = 'first day';
117
123
  if (n > 1){
118
124
  const ch = L.net_worth - F.net_worth;
119
125
  setDelta($('dStart'), val(L) - val(F));
120
- $('headline').textContent = `${VIEWS[view]} ${ch >= 0 ? 'up' : 'down'} ${short(Math.abs(ch)).replace('−','')} since ${fmtDate(F.date)}`;
121
- $('lede').textContent = `${short(L.net_worth)} now, ${pct(ch, F.net_worth)} ${ch >= 0 ? 'higher' : 'lower'} than ${n - 1} ${n === 2 ? 'day' : 'days'} ago. Logged each morning from INDmoney: everything owned minus loans.`;
126
+ $('headline').textContent = `${VIEWS[view]} ${ch >= 0 ? 'up' : 'down'} ${short(Math.abs(ch)).replace('−','')} since ${fmtDate(F.date, fy)}`;
127
+ $('lede').textContent = `${short(L.net_worth)} on ${fmtDate(L.date)}, ${pct(ch, F.net_worth)} ${ch >= 0 ? 'higher' : 'lower'} than on ${fmtDate(F.date, {day:'numeric', month:'short', year:'numeric'})}. Logged each morning from INDmoney: everything owned minus loans.`;
122
128
  $('chartNote').textContent = 'Point at the line to see any day.';
123
129
  } else {
124
130
  $('dStart').textContent = '—';
@@ -129,7 +135,7 @@ function render(){
129
135
  if (n > 1){
130
136
  const mv = PARTS.map(([k, name, sign]) => ({name, d: sign * (num(L[k]) - num(F[k]))})).filter(o => Math.abs(o.d) >= 1).sort((a, b) => Math.abs(b.d) - Math.abs(a.d));
131
137
  const max = Math.max(1, ...mv.map(o => Math.abs(o.d)));
132
- $('movesSub').textContent = `Effect of each part on your net worth, ${fmtDate(F.date)} to ${fmtDate(L.date)}. Smaller loans or card dues count as a gain.`;
138
+ $('movesSub').textContent = `Effect of each part on your net worth, ${fmtDate(F.date, fy)} to ${fmtDate(L.date, fy)}. Smaller loans or card dues count as a gain.`;
133
139
  $('moves').innerHTML = mv.length ? mv.map(o => {
134
140
  const w = (Math.abs(o.d) / max * 50).toFixed(2), left = o.d >= 0 ? 50 : 50 - w;
135
141
  return `<div class="mv"><span>${o.name}</span><span class="track"><span class="axis"></span><span class="bar" style="left:${left}%;width:${w}%;background:var(${o.d >= 0 ? '--up' : '--down'})"></span></span><span class="val ${o.d >= 0 ? 'up' : 'down'}">${signed(o.d)}</span></div>`;
@@ -138,13 +144,18 @@ function render(){
138
144
  $('moves').innerHTML = '<div class="empty">Changes appear once two days are logged.</div>';
139
145
  }
140
146
  // Ledger, newest first, with expandable "Other assets"
141
- $('tbody').innerHTML = rows.slice().reverse().map((r, j) => {
142
- const i = n - 1 - j, prev = i > 0 ? rows[i - 1] : null, dc = prev ? r.net_worth - prev.net_worth : null;
147
+ const prevOf = new Map(fullRows.map((r, i) => [r.date, i > 0 ? fullRows[i - 1] : null]));
148
+ const shown = rows.slice().reverse().slice(0, tableLimit);
149
+ $('tbody').innerHTML = shown.map((r) => {
150
+ const prev = prevOf.get(r.date), dc = prev ? r.net_worth - prev.net_worth : null;
143
151
  const other = num(r.nps) + num(r.sa) + num(r.vehicle) + num(r.other);
144
152
  const open = openDays.has(r.date);
145
153
  const main = `<tr><td>${fmtDate(r.date, {weekday:'short', day:'numeric', month:'short'})}</td><td><b>${full(r.net_worth)}</b></td><td class="${dc == null ? '' : dc >= 0 ? 'up' : 'down'}">${dc == null ? '—' : signed(dc)}</td><td>${short(num(r.mf))}</td><td>${short(num(r.bond))}</td><td>${short(num(r.stock))}</td><td>${short(num(r.us_stock))}</td><td><button type="button" class="exp" data-d="${r.date}" aria-expanded="${open}" aria-label="${open ? 'Hide' : 'Show'} what other assets include on ${fmtDate(r.date)}">${open ? '−' : '+'}</button>${short(other)}</td><td>${short(num(r.liabilities))}</td></tr>`;
146
154
  return open ? main + `<tr class="det"><td colspan="9">${detail(r)}</td></tr>` : main;
147
155
  }).join('');
156
+ $('more').hidden = n <= shown.length;
157
+ $('moreTxt').textContent = `Showing ${shown.length} of ${n} days`;
158
+ $('tblSub').textContent = `Values as INDmoney reported them that morning, ${fmtDate(F.date, {day:'numeric', month:'short', year:'numeric'})} to ${fmtDate(L.date, {day:'numeric', month:'short', year:'numeric'})}.`;
148
159
  renderBanks();
149
160
  renderLiab();
150
161
  draw();
@@ -253,7 +264,7 @@ function renderBanks(){
253
264
  $('banksSub').textContent = withA.length > 1 ? 'Savings balance in each account and how it changed, so you can see which one moved.' : 'Savings balance in each account. Changes appear from the next morning\'s log.';
254
265
  }
255
266
 
256
- const APP_VERSION = '1.3.0', TASK_VERSION = '1.3.0';
267
+ const APP_VERSION = '1.4.0', TASK_VERSION = '1.3.0';
257
268
  const WHATS_NEW = 'Your dashboard now updates itself, and the morning task saves everything INDmoney reports, so future features need no steps from you.';
258
269
  const TASK_TEMPLATE = "Log today's net worth snapshots from INDmoney into the user's \"Net worth log\" dashboard. This is an unattended daily run; do not ask questions. (Task version 1.3.0)\n\nMEMBERS (family_member argument -> document path):\n{{MEMBERS}}\n\n1. Load the tools with ToolSearch: the INDmoney tools networth_snapshot and networth_holdings, the artifact database tools db_get and db_write, and WebFetch. If the INDmoney tools are missing, or a call fails because INDmoney needs signing in again, write nothing and finish with exactly: \"ACTION NEEDED: INDmoney needs you to sign in again (claude.ai connector settings). Today's net worth wasn't logged.\" Then stop.\n\n2. For each member: call networth_snapshot, then networth_holdings with asset_type = \"SA\" (same family_member argument; none for the user). RETRIES: if a call fails for any reason other than sign-in (timeout, server error, empty or malformed result, total_networth missing), wait 60 seconds (run `sleep 60` in Bash) and try again, up to 3 attempts in all. If only networth_holdings keeps failing, still log that member without sa_accounts and raw.sa. If a family member's snapshot still fails, or they no longer share their portfolio, still log the others and say so in the summary. If the user's own snapshot fails after 3 attempts, say so in the summary starting with \"ACTION NEEDED:\".\n\n3. From each successful snapshot, build one document (INR as returned; never estimate or invent a value):\n - date: today's date in Asia/Kolkata time, \"YYYY-MM-DD\"\n - captured_at: now, ISO 8601 with +05:30\n - source: \"INDmoney networth_snapshot\"\n - net_worth: total_networth\n - assets: total_current_value\n - invested: total_invested\n - liabilities: liabilities.total\n - home_loan: liabilities.total_loan_balance\n - credit_card_due: liabilities.total_credit_card_due\n - loans: liabilities.loans as [{\"lender\", \"type\": loan_type, \"balance\": current_balance}], [] if none\n - cards: liabilities.credit_cards as [{\"name\": name exactly as returned (masked), \"due\": total_due}], [] if none\n - mf, bond, stock, us_stock, nps, sa, vehicle: current_value of the investments rows with asset_type MF, BOND, STOCK, US_STOCK, NPS, SA, VEHICLE (0 if missing)\n - other: sum of current_value of every other asset_type, 0 if none\n - sa_accounts: from networth_holdings SA, [{\"name\": investment, \"balance\": market_value}]; if a bank name repeats, name the later ones \"<bank> (2)\", \"<bank> (3)\"\n - raw: {\"snapshot\": the investments, assets, market_cap and liabilities parts of the networth_snapshot result exactly as returned, \"sa\": the holdings list from networth_holdings exactly as returned}. This keeps everything INDmoney reported so future dashboard features can use it. Never add card numbers, account numbers or anything not in those results.\n\n4. Dashboard slug: {{SLUG}}. For each path, db_get first. If it does not exist, db_write one op {op:\"set\", path, data}. If it exists, db_write {op:\"set\", path, data, ifVersion: <its version>} so that day's row is replaced, never duplicated. One db_write at a time. If a db_write fails with a transient error, wait 10 seconds and retry once (re-read the version first). Then db_get each path to confirm it saved with today's date. If a document would be over 200 KB, drop raw from it and say so in the summary. Write nothing else in the database.\n\n5. Usage count (anonymous, never let it affect logging): WebFetch https://nagarajanseshadri.com/networth-log/version.json?v=1.3.0 once and ignore the result. If it fails, skip it silently. Send nothing else.\n\n6. Finish with a one-line summary starting \"Logged:\", with the family total (sum of all members) in lakhs and each person's figure, e.g. \"Logged: Family ₹68.22 L (Asha ₹60.66 L, Ravi ₹7.55 L)\". If any bank account changed by more than ₹10,000 since the previous logged day (compare with that day's sa_accounts, if you read it), add a short note naming it and the change. If any credit card due is above ₹0, add a short note with the card and amount. Link: {{URL}}\n";
259
270
  const newer = (a, b) => { const p = (v) => String(v).split('.').map(n => parseInt(n, 10) || 0); const x = p(a), y = p(b); for (let i = 0; i < 3; i++){ if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) > (y[i] || 0); } return false; };
@@ -330,15 +341,91 @@ function buildTabs(){
330
341
  });
331
342
  nav.hidden = list.length < 2;
332
343
  }
344
+ // ---- Date range (3 months by default; remembered in this browser)
345
+ const RANGE_MONTHS = {'3m': 3, '6m': 6, '1y': 12, '2y': 24, '3y': 36, '5y': 60};
346
+ let rangeSel = {id: '3m'};
347
+ try { const saved = JSON.parse(localStorage.getItem('nwlog-range') || 'null'); if (saved && (RANGE_MONTHS[saved.id] || (saved.id === 'custom' && DATE_RE.test(saved.from) && DATE_RE.test(saved.to)))) rangeSel = saved; } catch (e) {}
348
+ const isoAddMonths = (iso, n) => { const d = new Date(iso + 'T00:00:00Z'); d.setUTCMonth(d.getUTCMonth() + n); return d.toISOString().slice(0, 10); };
349
+ const isoAddDays = (iso, n) => { const d = new Date(iso + 'T00:00:00Z'); d.setUTCDate(d.getUTCDate() + n); return d.toISOString().slice(0, 10); };
350
+ function rangeBounds(){
351
+ const last = fullRows.length ? fullRows[fullRows.length - 1].date : new Date(Date.now() + 5.5 * 3600e3).toISOString().slice(0, 10);
352
+ if (rangeSel.id === 'custom') return {from: rangeSel.from, to: rangeSel.to};
353
+ return {from: isoAddDays(isoAddMonths(last, -(RANGE_MONTHS[rangeSel.id] || 3)), 1), to: last};
354
+ }
355
+ function syncRangeUI(){
356
+ document.querySelectorAll('#rng button').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.r === rangeSel.id)));
357
+ const c = $('cust'), cb = document.querySelector('#rng button[data-r="custom"]');
358
+ if (rangeSel.id === 'custom'){ $('cFrom').value = rangeSel.from; $('cTo').value = rangeSel.to; }
359
+ if (fullRows.length){ ['cFrom', 'cTo'].forEach(id => { $(id).min = fullRows[0].date; $(id).max = fullRows[fullRows.length - 1].date; }); }
360
+ cb.setAttribute('aria-expanded', String(!c.hidden));
361
+ }
362
+ function setRange(sel){
363
+ rangeSel = sel; tableLimit = 31;
364
+ try { localStorage.setItem('nwlog-range', JSON.stringify(sel)); } catch (e) {}
365
+ syncRangeUI(); ensureHistory(); pick();
366
+ }
367
+ document.getElementById('rng').addEventListener('click', (e) => {
368
+ const b = e.target.closest('button[data-r]'); if (!b) return;
369
+ if (b.dataset.r === 'custom'){
370
+ const c = $('cust'); c.hidden = !c.hidden;
371
+ if (!c.hidden){ const bnd = rangeBounds(); if (!$('cFrom').value) $('cFrom').value = bnd.from; if (!$('cTo').value) $('cTo').value = bnd.to; $('cFrom').focus(); }
372
+ syncRangeUI(); return;
373
+ }
374
+ $('cust').hidden = true; setRange({id: b.dataset.r});
375
+ });
376
+ document.getElementById('cust').addEventListener('submit', (e) => {
377
+ e.preventDefault();
378
+ let f = $('cFrom').value, t = $('cTo').value;
379
+ if (!DATE_RE.test(f) || !DATE_RE.test(t)){ $('cErr').textContent = 'Pick both dates.'; return; }
380
+ if (f > t){ const x = f; f = t; t = x; }
381
+ $('cErr').textContent = '';
382
+ setRange({id: 'custom', from: f, to: t});
383
+ });
384
+ document.getElementById('moreBtn').addEventListener('click', () => { tableLimit += 60; render(); });
385
+ document.getElementById('allBtn').addEventListener('click', () => { tableLimit = Infinity; render(); });
386
+
333
387
  function pick(){
334
388
  if (!members.length) return;
335
389
  const h = location.hash.slice(1), first = members.length > 1 ? 'family' : members[0].id;
336
390
  view = VIEWS[h] ? h : first;
337
391
  document.querySelectorAll('#tabs a').forEach(a => a.setAttribute('aria-current', a.dataset.v === view ? 'page' : 'false'));
338
392
  if (!members.every(m => loaded[m.id])) return;
339
- rows = view === 'family' ? familyRows() : store[view];
393
+ fullRows = view === 'family' ? familyRows() : store[view];
394
+ const {from, to} = rangeBounds();
395
+ rows = fullRows.filter(r => r.date >= from && r.date <= to);
396
+ syncRangeUI();
340
397
  render();
341
398
  }
399
+
400
+ // ---- Loading: the newest 1,000 days live, older days fetched only when a long range needs them
401
+ const PAGE = 1000;
402
+ let dbRef = null; const live = {}, older = {}, moreOlder = {}, fetching = {};
403
+ function mergeStore(id){
404
+ const map = new Map();
405
+ (older[id] || []).forEach(r => map.set(r.date, r));
406
+ (live[id] || []).forEach(r => map.set(r.date, r));
407
+ store[id] = [...map.values()].sort((a, b) => a.date < b.date ? -1 : a.date > b.date ? 1 : 0);
408
+ }
409
+ async function ensureHistory(){
410
+ if (!dbRef) return;
411
+ const want = rangeBounds().from;
412
+ for (const m of members){
413
+ if (!moreOlder[m.id] || fetching[m.id]) continue;
414
+ const oldest = () => (store[m.id][0] || {}).date || '9999-12-31';
415
+ if (oldest() <= want) continue;
416
+ fetching[m.id] = true;
417
+ try {
418
+ while (moreOlder[m.id] && oldest() > want){
419
+ const snap = await dbRef.collection(m.collection).where('date', '<', oldest()).orderBy('date', 'desc').limit(PAGE).get();
420
+ older[m.id] = clean(snap.docs.map(d => d.data() || {})).concat(older[m.id] || []);
421
+ moreOlder[m.id] = snap.size === PAGE;
422
+ mergeStore(m.id);
423
+ }
424
+ } catch (e) { moreOlder[m.id] = false; }
425
+ fetching[m.id] = false;
426
+ pick();
427
+ }
428
+ }
342
429
  window.addEventListener('hashchange', pick);
343
430
  (async () => {
344
431
  const db = await claude.use('db');
@@ -355,11 +442,14 @@ window.addEventListener('hashchange', pick);
355
442
  if (!next.length){ $('status').textContent = 'Setup not finished yet: ask Claude to run the INDmoney net worth log skill.'; return; }
356
443
  if (JSON.stringify(next) === JSON.stringify(members)) return;
357
444
  subs.forEach(u => u()); subs = [];
358
- members = next; store = {}; loaded = {};
445
+ members = next; store = {}; loaded = {}; Object.keys(live).forEach(k => { delete live[k]; delete older[k]; delete moreOlder[k]; });
359
446
  members.forEach(m => { store[m.id] = []; loaded[m.id] = false; });
360
447
  buildTabs();
361
- members.forEach(m => subs.push(db.collection(m.collection).orderBy('date').onSnapshot((s) => {
362
- store[m.id] = clean(s.docs.map(d => d.data() || {})); loaded[m.id] = true; pick();
448
+ dbRef = db;
449
+ members.forEach(m => subs.push(db.collection(m.collection).orderBy('date', 'desc').limit(PAGE).onSnapshot((s) => {
450
+ live[m.id] = clean(s.docs.map(d => d.data() || {}));
451
+ if (moreOlder[m.id] === undefined) moreOlder[m.id] = s.size === PAGE;
452
+ mergeStore(m.id); loaded[m.id] = true; pick(); ensureHistory();
363
453
  }, fail)));
364
454
  pick();
365
455
  }, fail);
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>Net worth log</title>
7
- <meta name="nwlog-version" content="1.3.0">
7
+ <meta name="nwlog-version" content="1.4.0">
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
9
  <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;700;800&display=swap" rel="stylesheet">
10
10
  <style>
@@ -60,6 +60,17 @@ tbody tr:hover{background:var(--card)}
60
60
  .upd textarea{width:100%;min-height:140px;margin-top:6px;padding:10px;border:1px solid rgba(16,20,24,.35);border-radius:6px;background:#fffbe6;color:#101418;font:13px/1.4 ui-monospace,Menlo,monospace}
61
61
  .upd .msg{margin:2px 0 0;font-weight:700}
62
62
  @media(max-width:600px){.upd{grid-template-columns:minmax(0,1fr);grid-template-areas:"badge" "t1" "btn" "t2" "t3" "t4"}.upd .badge,.upd .x{justify-self:start}}
63
+ .rng{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;margin:0 0 18px}
64
+ .rng .lab{font-size:13px;font-weight:600;color:var(--mute);margin-right:4px}
65
+ .rng button{min-height:36px;padding:0 13px;border:1px solid var(--line);border-radius:999px;background:none;color:var(--ink);font:600 14px Manrope,system-ui,sans-serif;cursor:pointer}
66
+ .rng button[aria-pressed=true]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
67
+ .rng button:focus-visible,.more button:focus-visible{outline:2px solid var(--slab);outline-offset:2px}
68
+ .cust{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:-8px 0 18px;font-size:14px}
69
+ .cust input{min-height:36px;padding:0 8px;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--ink);font:15px Manrope,system-ui,sans-serif}
70
+ .cust .go{min-height:36px;padding:0 14px;border:0;border-radius:999px;background:var(--ink);color:var(--bg);font:700 14px Manrope,system-ui,sans-serif;cursor:pointer}
71
+ .cust .err{color:var(--down);font-weight:600}
72
+ .more{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:12px;font-size:14px;color:var(--mute)}
73
+ .more button{min-height:36px;padding:0 14px;border:1px solid var(--line);border-radius:999px;background:none;color:var(--ink);font:600 14px Manrope,system-ui,sans-serif;cursor:pointer}
63
74
  .seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:3px;margin:0 0 10px;gap:2px;flex-wrap:wrap}
64
75
  .seg button{min-height:38px;padding:0 14px;border:0;border-radius:999px;background:none;color:var(--ink);font:600 14px Manrope,system-ui,sans-serif;cursor:pointer}
65
76
  .seg button[aria-pressed=true]{background:var(--ink);color:var(--bg)}
@@ -98,6 +109,8 @@ tr.det:hover{background:none}
98
109
  <p class="status" id="status">Loading your log…</p>
99
110
  <h1 id="headline">Your net worth, logged every morning</h1>
100
111
  <p class="sub" id="lede">One snapshot from INDmoney each day at about 8:40 am IST: everything owned minus loans, for each person and the family together.</p>
112
+ <div class="rng" id="rng" role="group" aria-label="Date range"><span class="lab">Range</span><button type="button" data-r="3m" aria-pressed="true">3 months</button><button type="button" data-r="6m" aria-pressed="false">6 months</button><button type="button" data-r="1y" aria-pressed="false">1 year</button><button type="button" data-r="2y" aria-pressed="false">2 years</button><button type="button" data-r="3y" aria-pressed="false">3 years</button><button type="button" data-r="5y" aria-pressed="false">5 years</button><button type="button" data-r="custom" aria-pressed="false" aria-expanded="false" aria-controls="cust">Custom…</button></div>
113
+ <form class="cust" id="cust" hidden><label>From <input type="date" id="cFrom" required></label><label>To <input type="date" id="cTo" required></label><button type="submit" class="go">Show</button><span class="err" id="cErr" role="status"></span></form>
101
114
  <div class="top">
102
115
  <div class="slab" id="slab">
103
116
  <div><div class="lab" id="slabLab">Net worth</div><div class="big" id="nwBig">—</div></div>
@@ -136,12 +149,13 @@ tr.det:hover{background:none}
136
149
 
137
150
  <section class="band" style="padding-top:0"><div class="wrap">
138
151
  <h2>Day by day</h2>
139
- <p class="sub" style="margin-bottom:0">Values as INDmoney reported them that morning.</p>
152
+ <p class="sub" style="margin-bottom:0" id="tblSub">Values as INDmoney reported them that morning.</p>
140
153
  <p class="colnote" id="colNote" role="status" hidden></p>
141
154
  <div class="scroll"><table id="tbl"><thead><tr><th>Date</th><th>Net worth<button type="button" class="info" data-k="nw" aria-expanded="false" aria-controls="colNote" aria-label="What net worth means">i</button></th><th>Day change<button type="button" class="info" data-k="dc" aria-expanded="false" aria-controls="colNote" aria-label="What day change means">i</button></th><th>Mutual funds</th><th>Bonds</th><th>Indian stocks</th><th>US stocks<button type="button" class="info" data-k="us" aria-expanded="false" aria-controls="colNote" aria-label="What US stocks means">i</button></th><th>Other assets<button type="button" class="info" data-k="oa" aria-expanded="false" aria-controls="colNote" aria-label="What other assets means">i</button></th><th>Liabilities<button type="button" class="info" data-k="ln" aria-expanded="false" aria-controls="colNote" aria-label="What liabilities means">i</button></th></tr></thead><tbody id="tbody"></tbody></table></div>
155
+ <div class="more" id="more" hidden><span id="moreTxt"></span><button type="button" id="moreBtn">Show 60 more</button><button type="button" id="allBtn">Show all</button></div>
142
156
  </div></section>
143
157
 
144
- <footer class="band" style="padding-top:0"><div class="wrap"><p class="note">Net worth log v1.3.0 · figures from INDmoney · a tracking tool, not financial advice</p></div></footer>
158
+ <footer class="band" style="padding-top:0"><div class="wrap"><p class="note">Net worth log v1.4.0 · figures from INDmoney · a tracking tool, not financial advice</p></div></footer>
145
159
 
146
160
  <script>
147
161
  {
@@ -164,7 +178,7 @@ const pct = (v, base) => base ? Math.abs((v/base)*100).toFixed(2) + '%' : '';
164
178
  const fmtDate = (d, opt) => new Date(d + 'T00:00:00').toLocaleDateString('en-IN', opt || {day:'numeric', month:'short'});
165
179
  function setDelta(el, v){ el.textContent = signed(v); }
166
180
 
167
- let rows = [], basis = 'net';
181
+ let rows = [], fullRows = [], basis = 'net', tableLimit = 31;
168
182
  const val = (r) => basis === 'gross' ? r.assets : r.net_worth;
169
183
 
170
184
  function draw(){
@@ -189,8 +203,10 @@ function draw(){
189
203
  if (!narrow) g += `<text x="${m.l - 10}" y="${yy}" dy="4" text-anchor="end" font-size="12" fill="var(--mute)">${short(v)}</text>`;
190
204
  }
191
205
  const step = Math.max(1, Math.ceil(n / (narrow ? 4 : 8)));
206
+ const longSpan = n > 1 && (Date.parse(rows[n - 1].date) - Date.parse(rows[0].date)) > 300 * 864e5;
207
+ const xl = (d) => longSpan ? fmtDate(d, {month:'short', year:'2-digit'}) : fmtDate(d);
192
208
  rows.forEach((r, i) => {
193
- if (i % step === 0 || i === n - 1) g += `<text x="${x(i).toFixed(1)}" y="${H - 8}" text-anchor="middle" font-size="12" fill="var(--mute)">${fmtDate(r.date)}</text>`;
209
+ if (i % step === 0 || i === n - 1) g += `<text x="${x(i).toFixed(1)}" y="${H - 8}" text-anchor="middle" font-size="12" fill="var(--mute)">${xl(r.date)}</text>`;
194
210
  });
195
211
  const path = rows.map((r, i) => (i ? 'L' : 'M') + x(i).toFixed(1) + ',' + y(val(r)).toFixed(1)).join('');
196
212
  if (n > 1) g += `<path d="${path}" fill="none" stroke="var(--plot)" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`;
@@ -223,20 +239,23 @@ const ro = new ResizeObserver(draw); ro.observe($('chart'));
223
239
  function render(){
224
240
  const n = rows.length;
225
241
  if (!n){
226
- $('status').textContent = 'No days logged yet. The first snapshot arrives with the next morning run.';
242
+ $('status').textContent = fullRows.length ? 'No days logged in this range. Pick a longer range.' : 'No days logged yet. The first snapshot arrives with the next morning run.';
227
243
  $('moves').innerHTML = '<div class="empty">Changes appear once two days are logged.</div>';
228
- $('tbody').innerHTML = '';
244
+ $('tbody').innerHTML = ''; $('more').hidden = true;
229
245
  draw(); return;
230
246
  }
231
- const L = rows[n - 1], F = rows[0], P = n > 1 ? rows[n - 2] : null;
247
+ const L = rows[n - 1], F = rows[0];
248
+ const li = fullRows.findIndex(r => r.date === L.date), P = li > 0 ? fullRows[li - 1] : null;
232
249
  const have = new Set(rows.map(r => r.date)), gaps = [];
233
250
  for (let t = new Date(F.date + 'T00:00:00Z'); t <= new Date(L.date + 'T00:00:00Z'); t.setUTCDate(t.getUTCDate() + 1)){
234
251
  const d = t.toISOString().slice(0, 10); if (!have.has(d)) gaps.push(d);
235
252
  }
236
253
  const todayIST = new Date(Date.now() + 5.5 * 3600e3).toISOString().slice(0, 10);
237
254
  const nowH = new Date(Date.now() + 5.5 * 3600e3).getUTCHours() + new Date(Date.now() + 5.5 * 3600e3).getUTCMinutes() / 60;
238
- const lateToday = L.date < todayIST && nowH >= 9.25;
239
- let st = `${n} ${n === 1 ? 'day' : 'days'} logged · latest ${fmtDate(L.date, {weekday:'short', day:'numeric', month:'short', year:'numeric'})}`;
255
+ const newest = fullRows[fullRows.length - 1];
256
+ const lateToday = newest.date < todayIST && nowH >= 9.25;
257
+ const plus = members.some(m => moreOlder[m.id]) ? '+' : '';
258
+ let st = `${fullRows.length}${plus} ${fullRows.length === 1 && !plus ? 'day' : 'days'} logged${n < fullRows.length ? ` · ${n} in this range` : ''} · latest ${fmtDate(newest.date, {weekday:'short', day:'numeric', month:'short', year:'numeric'})}`;
240
259
  if (lateToday) st += ' · ⚠ today not logged yet: check INDmoney sign-in';
241
260
  if (gaps.length) st += ` · ⚠ missing ${gaps.length} ${gaps.length === 1 ? 'day' : 'days'}: ${gaps.slice(-5).map(d => fmtDate(d)).join(', ')}`;
242
261
  $('status').textContent = st;
@@ -249,13 +268,14 @@ function render(){
249
268
  $('kAltLab').textContent = g ? 'Net worth' : 'Liabilities';
250
269
  $('kLoan').textContent = short(g ? L.net_worth : L.liabilities);
251
270
  $('chart').setAttribute('aria-label', g ? 'Assets before liabilities by day' : 'Net worth by day');
252
- $('dStartLab').textContent = 'Since ' + fmtDate(F.date);
271
+ const fy = F.date.slice(0, 4) !== L.date.slice(0, 4) ? {day:'numeric', month:'short', year:'numeric'} : undefined;
272
+ $('dStartLab').textContent = 'Since ' + fmtDate(F.date, fy);
253
273
  if (P){ setDelta($('dDay'), val(L) - val(P)); } else $('dDay').textContent = 'first day';
254
274
  if (n > 1){
255
275
  const ch = L.net_worth - F.net_worth;
256
276
  setDelta($('dStart'), val(L) - val(F));
257
- $('headline').textContent = `${VIEWS[view]} ${ch >= 0 ? 'up' : 'down'} ${short(Math.abs(ch)).replace('−','')} since ${fmtDate(F.date)}`;
258
- $('lede').textContent = `${short(L.net_worth)} now, ${pct(ch, F.net_worth)} ${ch >= 0 ? 'higher' : 'lower'} than ${n - 1} ${n === 2 ? 'day' : 'days'} ago. Logged each morning from INDmoney: everything owned minus loans.`;
277
+ $('headline').textContent = `${VIEWS[view]} ${ch >= 0 ? 'up' : 'down'} ${short(Math.abs(ch)).replace('−','')} since ${fmtDate(F.date, fy)}`;
278
+ $('lede').textContent = `${short(L.net_worth)} on ${fmtDate(L.date)}, ${pct(ch, F.net_worth)} ${ch >= 0 ? 'higher' : 'lower'} than on ${fmtDate(F.date, {day:'numeric', month:'short', year:'numeric'})}. Logged each morning from INDmoney: everything owned minus loans.`;
259
279
  $('chartNote').textContent = 'Point at the line to see any day.';
260
280
  } else {
261
281
  $('dStart').textContent = '—';
@@ -266,7 +286,7 @@ function render(){
266
286
  if (n > 1){
267
287
  const mv = PARTS.map(([k, name, sign]) => ({name, d: sign * (num(L[k]) - num(F[k]))})).filter(o => Math.abs(o.d) >= 1).sort((a, b) => Math.abs(b.d) - Math.abs(a.d));
268
288
  const max = Math.max(1, ...mv.map(o => Math.abs(o.d)));
269
- $('movesSub').textContent = `Effect of each part on your net worth, ${fmtDate(F.date)} to ${fmtDate(L.date)}. Smaller loans or card dues count as a gain.`;
289
+ $('movesSub').textContent = `Effect of each part on your net worth, ${fmtDate(F.date, fy)} to ${fmtDate(L.date, fy)}. Smaller loans or card dues count as a gain.`;
270
290
  $('moves').innerHTML = mv.length ? mv.map(o => {
271
291
  const w = (Math.abs(o.d) / max * 50).toFixed(2), left = o.d >= 0 ? 50 : 50 - w;
272
292
  return `<div class="mv"><span>${o.name}</span><span class="track"><span class="axis"></span><span class="bar" style="left:${left}%;width:${w}%;background:var(${o.d >= 0 ? '--up' : '--down'})"></span></span><span class="val ${o.d >= 0 ? 'up' : 'down'}">${signed(o.d)}</span></div>`;
@@ -275,13 +295,18 @@ function render(){
275
295
  $('moves').innerHTML = '<div class="empty">Changes appear once two days are logged.</div>';
276
296
  }
277
297
  // Ledger, newest first, with expandable "Other assets"
278
- $('tbody').innerHTML = rows.slice().reverse().map((r, j) => {
279
- const i = n - 1 - j, prev = i > 0 ? rows[i - 1] : null, dc = prev ? r.net_worth - prev.net_worth : null;
298
+ const prevOf = new Map(fullRows.map((r, i) => [r.date, i > 0 ? fullRows[i - 1] : null]));
299
+ const shown = rows.slice().reverse().slice(0, tableLimit);
300
+ $('tbody').innerHTML = shown.map((r) => {
301
+ const prev = prevOf.get(r.date), dc = prev ? r.net_worth - prev.net_worth : null;
280
302
  const other = num(r.nps) + num(r.sa) + num(r.vehicle) + num(r.other);
281
303
  const open = openDays.has(r.date);
282
304
  const main = `<tr><td>${fmtDate(r.date, {weekday:'short', day:'numeric', month:'short'})}</td><td><b>${full(r.net_worth)}</b></td><td class="${dc == null ? '' : dc >= 0 ? 'up' : 'down'}">${dc == null ? '—' : signed(dc)}</td><td>${short(num(r.mf))}</td><td>${short(num(r.bond))}</td><td>${short(num(r.stock))}</td><td>${short(num(r.us_stock))}</td><td><button type="button" class="exp" data-d="${r.date}" aria-expanded="${open}" aria-label="${open ? 'Hide' : 'Show'} what other assets include on ${fmtDate(r.date)}">${open ? '−' : '+'}</button>${short(other)}</td><td>${short(num(r.liabilities))}</td></tr>`;
283
305
  return open ? main + `<tr class="det"><td colspan="9">${detail(r)}</td></tr>` : main;
284
306
  }).join('');
307
+ $('more').hidden = n <= shown.length;
308
+ $('moreTxt').textContent = `Showing ${shown.length} of ${n} days`;
309
+ $('tblSub').textContent = `Values as INDmoney reported them that morning, ${fmtDate(F.date, {day:'numeric', month:'short', year:'numeric'})} to ${fmtDate(L.date, {day:'numeric', month:'short', year:'numeric'})}.`;
285
310
  renderBanks();
286
311
  renderLiab();
287
312
  draw();
@@ -390,7 +415,7 @@ function renderBanks(){
390
415
  $('banksSub').textContent = withA.length > 1 ? 'Savings balance in each account and how it changed, so you can see which one moved.' : 'Savings balance in each account. Changes appear from the next morning\'s log.';
391
416
  }
392
417
 
393
- const APP_VERSION = '1.3.0', TASK_VERSION = '1.3.0';
418
+ const APP_VERSION = '1.4.0', TASK_VERSION = '1.3.0';
394
419
  const WHATS_NEW = 'Your dashboard now updates itself, and the morning task saves everything INDmoney reports, so future features need no steps from you.';
395
420
  const TASK_TEMPLATE = "Log today's net worth snapshots from INDmoney into the user's \"Net worth log\" dashboard. This is an unattended daily run; do not ask questions. (Task version 1.3.0)\n\nMEMBERS (family_member argument -> document path):\n{{MEMBERS}}\n\n1. Load the tools with ToolSearch: the INDmoney tools networth_snapshot and networth_holdings, the artifact database tools db_get and db_write, and WebFetch. If the INDmoney tools are missing, or a call fails because INDmoney needs signing in again, write nothing and finish with exactly: \"ACTION NEEDED: INDmoney needs you to sign in again (claude.ai connector settings). Today's net worth wasn't logged.\" Then stop.\n\n2. For each member: call networth_snapshot, then networth_holdings with asset_type = \"SA\" (same family_member argument; none for the user). RETRIES: if a call fails for any reason other than sign-in (timeout, server error, empty or malformed result, total_networth missing), wait 60 seconds (run `sleep 60` in Bash) and try again, up to 3 attempts in all. If only networth_holdings keeps failing, still log that member without sa_accounts and raw.sa. If a family member's snapshot still fails, or they no longer share their portfolio, still log the others and say so in the summary. If the user's own snapshot fails after 3 attempts, say so in the summary starting with \"ACTION NEEDED:\".\n\n3. From each successful snapshot, build one document (INR as returned; never estimate or invent a value):\n - date: today's date in Asia/Kolkata time, \"YYYY-MM-DD\"\n - captured_at: now, ISO 8601 with +05:30\n - source: \"INDmoney networth_snapshot\"\n - net_worth: total_networth\n - assets: total_current_value\n - invested: total_invested\n - liabilities: liabilities.total\n - home_loan: liabilities.total_loan_balance\n - credit_card_due: liabilities.total_credit_card_due\n - loans: liabilities.loans as [{\"lender\", \"type\": loan_type, \"balance\": current_balance}], [] if none\n - cards: liabilities.credit_cards as [{\"name\": name exactly as returned (masked), \"due\": total_due}], [] if none\n - mf, bond, stock, us_stock, nps, sa, vehicle: current_value of the investments rows with asset_type MF, BOND, STOCK, US_STOCK, NPS, SA, VEHICLE (0 if missing)\n - other: sum of current_value of every other asset_type, 0 if none\n - sa_accounts: from networth_holdings SA, [{\"name\": investment, \"balance\": market_value}]; if a bank name repeats, name the later ones \"<bank> (2)\", \"<bank> (3)\"\n - raw: {\"snapshot\": the investments, assets, market_cap and liabilities parts of the networth_snapshot result exactly as returned, \"sa\": the holdings list from networth_holdings exactly as returned}. This keeps everything INDmoney reported so future dashboard features can use it. Never add card numbers, account numbers or anything not in those results.\n\n4. Dashboard slug: {{SLUG}}. For each path, db_get first. If it does not exist, db_write one op {op:\"set\", path, data}. If it exists, db_write {op:\"set\", path, data, ifVersion: <its version>} so that day's row is replaced, never duplicated. One db_write at a time. If a db_write fails with a transient error, wait 10 seconds and retry once (re-read the version first). Then db_get each path to confirm it saved with today's date. If a document would be over 200 KB, drop raw from it and say so in the summary. Write nothing else in the database.\n\n5. Usage count (anonymous, never let it affect logging): WebFetch https://nagarajanseshadri.com/networth-log/version.json?v=1.3.0 once and ignore the result. If it fails, skip it silently. Send nothing else.\n\n6. Finish with a one-line summary starting \"Logged:\", with the family total (sum of all members) in lakhs and each person's figure, e.g. \"Logged: Family ₹68.22 L (Asha ₹60.66 L, Ravi ₹7.55 L)\". If any bank account changed by more than ₹10,000 since the previous logged day (compare with that day's sa_accounts, if you read it), add a short note naming it and the change. If any credit card due is above ₹0, add a short note with the card and amount. Link: {{URL}}\n";
396
421
  const newer = (a, b) => { const p = (v) => String(v).split('.').map(n => parseInt(n, 10) || 0); const x = p(a), y = p(b); for (let i = 0; i < 3; i++){ if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) > (y[i] || 0); } return false; };
@@ -467,15 +492,91 @@ function buildTabs(){
467
492
  });
468
493
  nav.hidden = list.length < 2;
469
494
  }
495
+ // ---- Date range (3 months by default; remembered in this browser)
496
+ const RANGE_MONTHS = {'3m': 3, '6m': 6, '1y': 12, '2y': 24, '3y': 36, '5y': 60};
497
+ let rangeSel = {id: '3m'};
498
+ try { const saved = JSON.parse(localStorage.getItem('nwlog-range') || 'null'); if (saved && (RANGE_MONTHS[saved.id] || (saved.id === 'custom' && DATE_RE.test(saved.from) && DATE_RE.test(saved.to)))) rangeSel = saved; } catch (e) {}
499
+ const isoAddMonths = (iso, n) => { const d = new Date(iso + 'T00:00:00Z'); d.setUTCMonth(d.getUTCMonth() + n); return d.toISOString().slice(0, 10); };
500
+ const isoAddDays = (iso, n) => { const d = new Date(iso + 'T00:00:00Z'); d.setUTCDate(d.getUTCDate() + n); return d.toISOString().slice(0, 10); };
501
+ function rangeBounds(){
502
+ const last = fullRows.length ? fullRows[fullRows.length - 1].date : new Date(Date.now() + 5.5 * 3600e3).toISOString().slice(0, 10);
503
+ if (rangeSel.id === 'custom') return {from: rangeSel.from, to: rangeSel.to};
504
+ return {from: isoAddDays(isoAddMonths(last, -(RANGE_MONTHS[rangeSel.id] || 3)), 1), to: last};
505
+ }
506
+ function syncRangeUI(){
507
+ document.querySelectorAll('#rng button').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.r === rangeSel.id)));
508
+ const c = $('cust'), cb = document.querySelector('#rng button[data-r="custom"]');
509
+ if (rangeSel.id === 'custom'){ $('cFrom').value = rangeSel.from; $('cTo').value = rangeSel.to; }
510
+ if (fullRows.length){ ['cFrom', 'cTo'].forEach(id => { $(id).min = fullRows[0].date; $(id).max = fullRows[fullRows.length - 1].date; }); }
511
+ cb.setAttribute('aria-expanded', String(!c.hidden));
512
+ }
513
+ function setRange(sel){
514
+ rangeSel = sel; tableLimit = 31;
515
+ try { localStorage.setItem('nwlog-range', JSON.stringify(sel)); } catch (e) {}
516
+ syncRangeUI(); ensureHistory(); pick();
517
+ }
518
+ document.getElementById('rng').addEventListener('click', (e) => {
519
+ const b = e.target.closest('button[data-r]'); if (!b) return;
520
+ if (b.dataset.r === 'custom'){
521
+ const c = $('cust'); c.hidden = !c.hidden;
522
+ if (!c.hidden){ const bnd = rangeBounds(); if (!$('cFrom').value) $('cFrom').value = bnd.from; if (!$('cTo').value) $('cTo').value = bnd.to; $('cFrom').focus(); }
523
+ syncRangeUI(); return;
524
+ }
525
+ $('cust').hidden = true; setRange({id: b.dataset.r});
526
+ });
527
+ document.getElementById('cust').addEventListener('submit', (e) => {
528
+ e.preventDefault();
529
+ let f = $('cFrom').value, t = $('cTo').value;
530
+ if (!DATE_RE.test(f) || !DATE_RE.test(t)){ $('cErr').textContent = 'Pick both dates.'; return; }
531
+ if (f > t){ const x = f; f = t; t = x; }
532
+ $('cErr').textContent = '';
533
+ setRange({id: 'custom', from: f, to: t});
534
+ });
535
+ document.getElementById('moreBtn').addEventListener('click', () => { tableLimit += 60; render(); });
536
+ document.getElementById('allBtn').addEventListener('click', () => { tableLimit = Infinity; render(); });
537
+
470
538
  function pick(){
471
539
  if (!members.length) return;
472
540
  const h = location.hash.slice(1), first = members.length > 1 ? 'family' : members[0].id;
473
541
  view = VIEWS[h] ? h : first;
474
542
  document.querySelectorAll('#tabs a').forEach(a => a.setAttribute('aria-current', a.dataset.v === view ? 'page' : 'false'));
475
543
  if (!members.every(m => loaded[m.id])) return;
476
- rows = view === 'family' ? familyRows() : store[view];
544
+ fullRows = view === 'family' ? familyRows() : store[view];
545
+ const {from, to} = rangeBounds();
546
+ rows = fullRows.filter(r => r.date >= from && r.date <= to);
547
+ syncRangeUI();
477
548
  render();
478
549
  }
550
+
551
+ // ---- Loading: the newest 1,000 days live, older days fetched only when a long range needs them
552
+ const PAGE = 1000;
553
+ let dbRef = null; const live = {}, older = {}, moreOlder = {}, fetching = {};
554
+ function mergeStore(id){
555
+ const map = new Map();
556
+ (older[id] || []).forEach(r => map.set(r.date, r));
557
+ (live[id] || []).forEach(r => map.set(r.date, r));
558
+ store[id] = [...map.values()].sort((a, b) => a.date < b.date ? -1 : a.date > b.date ? 1 : 0);
559
+ }
560
+ async function ensureHistory(){
561
+ if (!dbRef) return;
562
+ const want = rangeBounds().from;
563
+ for (const m of members){
564
+ if (!moreOlder[m.id] || fetching[m.id]) continue;
565
+ const oldest = () => (store[m.id][0] || {}).date || '9999-12-31';
566
+ if (oldest() <= want) continue;
567
+ fetching[m.id] = true;
568
+ try {
569
+ while (moreOlder[m.id] && oldest() > want){
570
+ const snap = await dbRef.collection(m.collection).where('date', '<', oldest()).orderBy('date', 'desc').limit(PAGE).get();
571
+ older[m.id] = clean(snap.docs.map(d => d.data() || {})).concat(older[m.id] || []);
572
+ moreOlder[m.id] = snap.size === PAGE;
573
+ mergeStore(m.id);
574
+ }
575
+ } catch (e) { moreOlder[m.id] = false; }
576
+ fetching[m.id] = false;
577
+ pick();
578
+ }
579
+ }
479
580
  window.addEventListener('hashchange', pick);
480
581
  (async () => {
481
582
  const db = await claude.use('db');
@@ -492,11 +593,14 @@ window.addEventListener('hashchange', pick);
492
593
  if (!next.length){ $('status').textContent = 'Setup not finished yet: ask Claude to run the INDmoney net worth log skill.'; return; }
493
594
  if (JSON.stringify(next) === JSON.stringify(members)) return;
494
595
  subs.forEach(u => u()); subs = [];
495
- members = next; store = {}; loaded = {};
596
+ members = next; store = {}; loaded = {}; Object.keys(live).forEach(k => { delete live[k]; delete older[k]; delete moreOlder[k]; });
496
597
  members.forEach(m => { store[m.id] = []; loaded[m.id] = false; });
497
598
  buildTabs();
498
- members.forEach(m => subs.push(db.collection(m.collection).orderBy('date').onSnapshot((s) => {
499
- store[m.id] = clean(s.docs.map(d => d.data() || {})); loaded[m.id] = true; pick();
599
+ dbRef = db;
600
+ members.forEach(m => subs.push(db.collection(m.collection).orderBy('date', 'desc').limit(PAGE).onSnapshot((s) => {
601
+ live[m.id] = clean(s.docs.map(d => d.data() || {}));
602
+ if (moreOlder[m.id] === undefined) moreOlder[m.id] = s.size === PAGE;
603
+ mergeStore(m.id); loaded[m.id] = true; pick(); ensureHistory();
500
604
  }, fail)));
501
605
  pick();
502
606
  }, fail);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indmoney-networth-log",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Dashboard code for the INDmoney Net Worth Log Claude skill. Loaded by each user's private dashboard via jsDelivr.",
5
5
  "files": ["dist/dashboard.js", "dist/standalone.html"],
6
6
  "license": "MIT",