Zero-Upload Browser Apps: Floating-Time .ics Reminders, Deterministic Grid Shuffles & 9:16 Story PNGs in Vanilla JS
Most holiday or countdown web apps follow the same heavy blueprint: require an account up front, upload user photos to object storage, run cron jobs for daily reminder emails, and generate share cards on a headless brows
Most holiday or countdown web apps follow the same heavy blueprint: require an account up front, upload user photos to object storage, run cron jobs for daily reminder emails, and generate share cards on a headless browser server.
While building Digitaler Adventskalender β a free, German-language browser tool where users create 7-, 12-, 24-, or 25-door digital advent calendars (or run a shared Mit Freunden group board without sign-ups) β we intentionally removed logins, email collection, and image uploads completely.
That constraint forced us to solve five surprisingly interesting client-side JavaScript problems cleanly in the browser:
-
Timezone-safe daily unlocks using the
TemporalAPI with a cleanDatefallback -
Serverless daily reminders via client-generated RFC 5545 floating-time
.icsfiles - Consistent randomized door grids across all recipients using FNV-1a + xorshift32
-
One-tap 9:16 Instagram/WhatsApp Story cards (
1080x1920) rendered on<canvas> -
Account-less moderation & privacy-first embeds (
youtube-nocookie.comclick-to-load +#owner=fragment keys)
I also extracted all five standalone utilities (MIT-licensed, zero dependencies) into a small companion repo: vanilla-js-calendar-story-snippets.
1. Timezone-Safe Midnight Unlocks Without Server Clock Drift
In a gift calendar, "Door 4 unlocks on December 4" should unlock at midnight in the recipient's local timezone, not UTC midnight in Frankfurt or Virginia. Comparing ISO timestamps triggers classic DST and UTC-offset off-by-one bugs.
Keeping calendar dates strictly as plain { y, m, d } integer triples eliminates timezone conversion surprises. When Temporal.PlainDate is available in modern browsers, we use it first and fall back cleanly to local new Date(y, m - 1, d + days):
export function parseYmd(str) {
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(str || "").trim());
if (!m) return { y: 2026, m: 12, d: 1 };
const y = Number(m[1]), mo = Number(m[2]), d = Number(m[3]);
if (mo < 1 || mo > 12 || d < 1 || d > 31) return { y: 2026, m: 12, d: 1 };
return { y, m: mo, d };
}
export function todayYmd() {
if (typeof Temporal !== "undefined" && Temporal.Now?.plainDateISO) {
const p = Temporal.Now.plainDateISO();
return { y: p.year, m: p.month, d: p.day };
}
const now = new Date();
return { y: now.getFullYear(), m: now.getMonth() + 1, d: now.getDate() };
}
export function addDaysYmd(ymd, days) {
if (typeof Temporal !== "undefined" && Temporal.PlainDate) {
const p = Temporal.PlainDate.from({ year: ymd.y, month: ymd.m, day: ymd.d }).add({ days });
return { y: p.year, m: p.month, d: p.day };
}
const dt = new Date(ymd.y, ymd.m - 1, ymd.d + days);
return { y: dt.getFullYear(), m: dt.getMonth() + 1, d: dt.getDate() };
}
export function cmpYmd(a, b) {
return (a.y * 10000 + a.m * 100 + a.d) - (b.y * 10000 + b.m * 100 + b.d);
}
Because addDaysYmd uses local calendar arithmetic rather than 86_400_000 ms millisecond addition, crossing daylight saving boundaries never duplicates or skips a day, and fmtDeLong formats labels using Date.UTC(y, m - 1, d) with timeZone: "UTC" so displayed door labels never shift backward in negative UTC offsets.
2. Multi-Day .ics Reminders Instead of Collecting Emails
Email reminders are one of the top reasons simple consumer tools add an auth wall. An RFC 5545 .ics Blob solves the same retention problem locally across Apple Calendar, Google Calendar, and Outlook without storing a single email address.
The important RFC 5545 detail here is floating time: omitting the trailing Z on DTSTART:YYYYMMDDT090000 tells calendar clients to fire the alert at 09:00 AM in whichever timezone the recipient happens to be in on that day:
function pad2(n) {
return n < 10 ? "0" + n : String(n);
}
function icsEscape(str) {
return String(str || "")
.replace(/\\/g, "\\\\")
.replace(/;/g, "\\;")
.replace(/,/g, "\\,")
.replace(/\r?\n/g, "\\n");
}
export function buildFloatingIcs({ title, startStr, count, shareUrl }) {
const base = parseYmd(startStr);
const nowStamp = new Date().toISOString().replace(/[-:]/g, "").slice(0, 15) + "Z";
const lines = [
"BEGIN:VCALENDAR",
"VERSION:2.0",
"PRODID:-//Digitaler Adventskalender//DE",
"CALSCALE:GREGORIAN"
];
for (let i = 0; i < count; i++) {
const d = addDaysYmd(base, i);
const ymd = `${d.y}${pad2(d.m)}${pad2(d.d)}`;
lines.push(
"BEGIN:VEVENT",
`UID:tuerchen-${i + 1}-${ymd}@digitaleradventskalender.com`,
`DTSTAMP:${nowStamp}`,
`DTSTART:${ymd}T090000`,
"DURATION:PT15M",
`SUMMARY:${icsEscape(`TΓΌrchen ${i + 1} β ${title}`)}`,
`DESCRIPTION:${icsEscape(`Γffne dein heutiges TΓΌrchen unter: ${shareUrl}`)}`,
"BEGIN:VALARM",
"ACTION:DISPLAY",
`DESCRIPTION:${icsEscape("Neues Adventskalender-TΓΌrchen bereit!")}`,
"TRIGGER:PT0M",
"END:VALARM",
"END:VEVENT"
);
}
lines.push("END:VCALENDAR");
return new Blob([lines.join("\r\n")], { type: "text/calendar;charset=utf-8" });
}
Wait on two details: CRLF (\r\n) line endings are required by strict .ics parsers (especially older Outlook desktop builds), and semicolons/commas inside SUMMARY and DESCRIPTION must be escaped with icsEscape so URLs or calendar titles don't corrupt event properties.
3. Deterministic Door Shuffling With FNV-1a + xorshift32
Classic paper advent calendars hide doors in a jumbled layout instead of neat rows from 1 to 24. If you use Math.random() on every page load, the grid jumps around on every refresh; if you store the permutation server-side, it bloats the calendar payload.
Instead, we hash the calendar's immutable public ID into an unsigned 32-bit seed using FNV-1a, then run xorshift32 inside a Fisher-Yates shuffle:
export function doorOrder(count, shuffle, seedStr) {
const arr = [];
for (let i = 1; i <= count; i++) arr.push(i);
if (!shuffle) return arr;
let h = 2166136261;
const s = String(seedStr || "advent");
for (let j = 0; j < s.length; j++) {
h ^= s.charCodeAt(j);
h = Math.imul(h, 16777619);
}
for (let k = arr.length - 1; k > 0; k--) {
h ^= h << 13;
h ^= h >>> 17;
h ^= h << 5;
const idx = (h >>> 0) % (k + 1);
const tmp = arr[k];
arr[k] = arr[idx];
arr[idx] = tmp;
}
return arr;
}
Notice Math.imul and h >>> 0: JavaScript's bitwise operators return signed 32-bit integers, so keeping multiplication in Math.imul avoids floating-point precision loss while >>> 0 guarantees a non-negative modulo index. Every friend opening the same shared calendar on mobile Safari, Android Chrome, or desktop Firefox sees the exact same randomized door layoutβzero extra storage required. That is especially useful on shared office and group boards like the one documented on our guide for teams and clubs.
4. Generating 1080x1920 9:16 Story PNGs Client-Side
In collaborative group mode, links dropped in WhatsApp group chats work great, while Instagram and TikTok invite stories prefer a vertical 9:16 graphic paired with a readable short code visitors can enter on /code.
Rendering a 1080x1920 canvas right inside the browser keeps the workflow zero-upload and zero-latency:
function wrapCanvasText(ctx, text, x, y, maxW, lineH, maxLines) {
const words = String(text || "").split(/\s+/);
let line = "";
let drawn = 0;
for (let i = 0; i < words.length; i++) {
const test = line ? `${line} ${words[i]}` : words[i];
if (ctx.measureText(test).width > maxW && line) {
ctx.fillText(line, x, y);
y += lineH;
drawn++;
line = words[i];
if (maxLines && drawn >= maxLines - 1) break;
} else {
line = test;
}
}
if (line) {
ctx.fillText(line, x, y);
y += lineH;
}
return y;
}
Wrapping text via ctx.measureText(test).width lets user-chosen German titles (maxlength="80") flow across up to 3 centered lines without clipping on narrow 9:16 Story safe zones, and exporting canvas.toDataURL("image/png") gives both an instant <img> preview and a one-click PNG download.
5. Privacy-First Media Parsing & Accountless Moderation (#owner=)
To ensure opening an advent calendar never leaks visitor IPs to third-party trackers before consent, the link parser enforces strict https: validation and converts standard YouTube watch/short/Shorts URLs to youtube-nocookie.com/embed/... β and never mounts the <iframe> until the recipient explicitly clicks "Vorschau laden":
export function safeHttpsUrl(raw) {
let s = String(raw || "").trim();
if (!s) return "";
if (!/^https?:\/\//i.test(s)) s = "https://" + s;
try {
const u = new URL(s);
return u.protocol === "https:" ? u.toString() : "";
} catch {
return "";
}
}
export function parseMedia(urlStr) {
const clean = safeHttpsUrl(urlStr);
if (!clean) return null;
try {
const u = new URL(clean);
const h = u.hostname.replace(/^www\./, "");
if (h === "youtu.be" || h === "youtube.com" || h === "m.youtube.com") {
let vid = "";
if (h === "youtu.be") vid = u.pathname.slice(1).split("/")[0];
else if (u.searchParams.get("v")) vid = u.searchParams.get("v");
else if (u.pathname.startsWith("/shorts/")) vid = u.pathname.slice(8).split("/")[0];
if (/^[A-Za-z0-9_-]{11}$/.test(vid)) {
return {
url: clean,
label: "YouTube-Video",
embedUrl: `https://www.youtube-nocookie.com/embed/${vid}`,
kind: "youtube"
};
}
}
if (h === "open.spotify.com") {
const m = /^\/(?:intl-[a-z-]+\/)?(track|album|playlist|episode)\/([A-Za-z0-9]+)/.exec(u.pathname);
if (m) {
return {
url: clean,
label: "Spotify-Titel",
embedUrl: `https://open.spotify.com/embed/${m[1]}/${m[2]}`,
kind: "spotify"
};
}
}
return { url: clean, label: h, embedUrl: "", kind: "link" };
} catch {
return null;
}
}
For moderation without accounts (essential when friends submit doors on shared boards), creators receive a revocable key carried in the URL fragment (#owner=...) and stripped via history.replaceState(...) as soon as the key is claimed into local storage β keeping private moderator tokens out of HTTP referer headers and server access logs.
Wrapping Up
Removing logins and uploads forced cleaner client-side architecture everywhere: .ics replaced email cron jobs, #owner= replaced session tables, Temporal + integer triples solved local midnight unlocks, and Canvas PNG export replaced server-side image rendering.
You can test the live tool on Digitaler Adventskalender (including the browser mini-games or our transparent breakdown of free advent calendar alternatives), or browse the extracted standalone utilities in sunrain113/vanilla-js-calendar-story-snippets.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.