Copy share link: encoding a whole week of shifts into a URL hash
A few weeks after the time card calculator went live, I kept getting the same request in different words: "can I send my filled-in week to my manager?" or "my partner does the payroll, can I just send her the link?" The
A few weeks after the time card calculator went live, I kept getting the same request in different words: "can I send my filled-in week to my manager?" or "my partner does the payroll, can I just send her the link?"
The problem is that the calculator has no server. Everything runs in the visitor's browser, there are no accounts, and nothing is ever uploaded anywhere. That is the whole point of the tool — your timesheet never leaves your device. But it also means there is nowhere to store a shared copy. So the share link had to carry the week inside itself.
The answer is the URL hash — the part after the #. Browsers never send the hash to a server, which matters here: a timesheet is personal data, and keeping it out of server logs entirely is the right default. The link looks like the site address, then #w= followed by the encoded week. Paste it into a message, and whoever opens it sees the same filled-in card.
Encoding a week turned out to be a small design exercise of its own. Each day has a clock-in, a clock-out, a break, and an hourly rate, plus a name field and a few toggles. Writing all of that out as JSON would work, but it would be long and ugly — and long links get mangled by chat apps. So I flattened each day into a short token: start and end times as minutes since midnight, break in minutes, rate as a plain number. A day like 9:00 to 17:30 with a 30-minute lunch at $16.50 becomes something like 540-1050-30-16.5. Seven days joined with a separator, days with no shifts left empty so the order stays obvious.
The reader side is the part that took the most care. A link pasted into a chat can be truncated, a user can edit it by hand, or an old link can arrive after the format changed. So the decoder is suspicious by design: it splits the hash, checks every number is in range — minutes between 0 and 1439, rate a positive number — and quietly drops anything that fails instead of crashing the page. A bad day becomes an empty day, never a wrong total. The one thing I refuse to do is guess: if a value is outside the range, it is ignored, and the card loads with the rest of the week intact.
There is a small detail people miss about the hash: it never reaches the server, so the shared week never touches my analytics or my logs. That is not an accident, it is the reason I chose the hash over a query string. A ?w= parameter would be sent on every request and would show up in logs. The hash stays in the browser.
The copy itself uses the Clipboard API, navigator.clipboard.writeText, with a fallback for older browsers: select a hidden input, document.execCommand('copy'), and show a short "Link copied" message either way. A small thing, but a share button that silently fails is worse than no button at all.
One more decision: the link encodes the week, not the result. The totals are recalculated when the link opens, using the same code as the normal page. That keeps one source of truth — if I ever fix a rounding bug, every shared link benefits from the fix instead of carrying a stale total around. It also keeps the link shorter.
The feature is live on mytimecardcal.com now, on the time card page — fill in a week, hit "Copy share link", and send it to whoever needs to see it.
It is a tiny feature, but it is the one I am proudest of on the site, because it does something useful without giving up the rule the whole site is built on: your timesheet stays yours.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.