Spaces:
Running
Running
Deploy rotasprig to the hub
Browse files- .gitattributes +1 -0
- rotasprig/app.js +700 -0
- rotasprig/icon-192.png +0 -0
- rotasprig/icon-512.png +0 -0
- rotasprig/icon.svg +9 -0
- rotasprig/index.html +300 -0
- rotasprig/lib/rota.js +375 -0
- rotasprig/manifest.webmanifest +17 -0
- rotasprig/og.png +3 -0
- rotasprig/pro.js +139 -0
- rotasprig/robots.txt +3 -0
- rotasprig/sitemap.xml +2 -0
- rotasprig/style.css +322 -0
- rotasprig/sw.js +34 -0
.gitattributes
CHANGED
|
@@ -654,3 +654,4 @@ brand/rotasprig/image-1-shot.png filter=lfs diff=lfs merge=lfs -text
|
|
| 654 |
brand/rotasprig/image-2-shot.png filter=lfs diff=lfs merge=lfs -text
|
| 655 |
brand/rotasprig/image-3-output.png filter=lfs diff=lfs merge=lfs -text
|
| 656 |
brand/rotasprig/image-4-inside.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 654 |
brand/rotasprig/image-2-shot.png filter=lfs diff=lfs merge=lfs -text
|
| 655 |
brand/rotasprig/image-3-output.png filter=lfs diff=lfs merge=lfs -text
|
| 656 |
brand/rotasprig/image-4-inside.png filter=lfs diff=lfs merge=lfs -text
|
| 657 |
+
rotasprig/og.png filter=lfs diff=lfs merge=lfs -text
|
rotasprig/app.js
ADDED
|
@@ -0,0 +1,700 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Rotasprig app: staff, weekly shift grid, templates, drag/copy, totals, labour cost, warnings, coverage,
|
| 2 |
+
* print, PNG, per-person text, Pro (locations, week history, labour report, CSV, backup).
|
| 3 |
+
* Everything stays in this browser. © 2026 CyberMax. All rights reserved. */
|
| 4 |
+
(function () {
|
| 5 |
+
"use strict";
|
| 6 |
+
var R = window.Rota, X = window.CMXPro;
|
| 7 |
+
var KEY = "rotasprig:v1";
|
| 8 |
+
var FREE_STAFF = 8;
|
| 9 |
+
var HUB = "cybermax-tools-cybermax.static.hf.space/rotasprig/";
|
| 10 |
+
var CREDIT = "Schedule made with Rotasprig by CyberMax";
|
| 11 |
+
var $ = function (id) { return document.getElementById(id); };
|
| 12 |
+
function esc(s) { return String(s == null ? "" : s).replace(/[&<>"']/g, function (c) { return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]; }); }
|
| 13 |
+
function pro() { return X.isPro(); }
|
| 14 |
+
function toast(m) { X.toast(m); }
|
| 15 |
+
function upsell(msg, from) { X.upsell(msg || "That is a Rotasprig Pro feature.", from); }
|
| 16 |
+
function uid(p) { return p + Date.now().toString(36) + Math.random().toString(36).slice(2, 6); }
|
| 17 |
+
function slugify(s) { return String(s || "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "schedule"; }
|
| 18 |
+
function qsa(sel, root) { return Array.prototype.slice.call((root || document).querySelectorAll(sel)); }
|
| 19 |
+
|
| 20 |
+
/* ---------- state ---------- */
|
| 21 |
+
function freshSettings() { return { currency: "USD", time: "24", wstart: 1, minRest: 10, paper: "letter", printCost: false, otAfter: 40, otMult: 1.5 }; }
|
| 22 |
+
function emptySchedule(name) { return { id: uid("l"), name: name || "My business", staff: [], templates: R.defaultTemplates(), shifts: [] }; }
|
| 23 |
+
function nextWeek(ws) { return R.addDays(R.weekStartOf(R.todayISO(), ws), 7); }
|
| 24 |
+
function load() {
|
| 25 |
+
var s = null;
|
| 26 |
+
try { s = JSON.parse(localStorage.getItem(KEY) || "null"); } catch (e) { s = null; }
|
| 27 |
+
if (!s || typeof s !== "object" || !Array.isArray(s.schedules) || !s.schedules.length) return null;
|
| 28 |
+
var f = freshSettings(); s.settings = s.settings || {};
|
| 29 |
+
Object.keys(f).forEach(function (k) { if (s.settings[k] == null) s.settings[k] = f[k]; });
|
| 30 |
+
if (!R.isISO(s.week)) s.week = nextWeek(s.settings.wstart);
|
| 31 |
+
return s;
|
| 32 |
+
}
|
| 33 |
+
var S = load(), saveT = null, clip = null, brush = null, pendingWeek = null, editing = null;
|
| 34 |
+
function save() {
|
| 35 |
+
clearTimeout(saveT);
|
| 36 |
+
saveT = setTimeout(function () { try { localStorage.setItem(KEY, JSON.stringify(S)); } catch (e) { toast("Could not save in this browser (storage full or private mode)."); } }, 120);
|
| 37 |
+
}
|
| 38 |
+
function touch() { S.dirty = true; save(); }
|
| 39 |
+
function sch() { var c = S.schedules.filter(function (x) { return x.id === S.cur; })[0]; if (!c) { c = S.schedules[0]; S.cur = c.id; } return c; }
|
| 40 |
+
function settings() { return S.settings; }
|
| 41 |
+
function fmt() { return settings().time === "12" ? "12" : "24"; }
|
| 42 |
+
function ws() { return Number(settings().wstart) === 0 ? 0 : 1; }
|
| 43 |
+
function money(n) { return R.money(n, settings().currency); }
|
| 44 |
+
function person(id) { return sch().staff.filter(function (p) { return p.id === id; })[0]; }
|
| 45 |
+
function shiftById(id) { return sch().shifts.filter(function (s) { return s.id === id; })[0]; }
|
| 46 |
+
function dates() { return R.weekDates(S.week); }
|
| 47 |
+
|
| 48 |
+
function exampleSchedule(kind) {
|
| 49 |
+
var monday = R.addDays(R.weekStartOf(R.todayISO(), 1), 7);
|
| 50 |
+
var ex = R.example(kind, monday);
|
| 51 |
+
var start = R.weekStartOf(monday, ws());
|
| 52 |
+
if (start !== monday) ex.shifts.forEach(function (s) { if (!R.inWeek(s.date, start)) s.date = R.addDays(s.date, -7); });
|
| 53 |
+
return { sched: { id: uid("l"), name: ex.name, staff: ex.staff, templates: ex.templates, shifts: ex.shifts }, week: start };
|
| 54 |
+
}
|
| 55 |
+
function loadExample(kind) {
|
| 56 |
+
if (!S) S = { v: 1, settings: freshSettings(), schedules: [], cur: null, week: null };
|
| 57 |
+
var e = exampleSchedule(kind);
|
| 58 |
+
if (pro() && S.schedules.length > 1) { var i = S.schedules.indexOf(sch()); e.sched.id = sch().id; S.schedules[i] = e.sched; }
|
| 59 |
+
else S.schedules = [e.sched];
|
| 60 |
+
S.cur = e.sched.id; S.week = e.week; S.example = kind; S.dirty = false;
|
| 61 |
+
brush = null; save();
|
| 62 |
+
}
|
| 63 |
+
if (!S) loadExample("cafe");
|
| 64 |
+
|
| 65 |
+
/* ---------- tabs ---------- */
|
| 66 |
+
var TABS = ["week", "team", "cover", "share", "labour"];
|
| 67 |
+
function showTab(name, focus) {
|
| 68 |
+
TABS.forEach(function (t) {
|
| 69 |
+
var on = t === name;
|
| 70 |
+
$("tab-" + t).setAttribute("aria-selected", on ? "true" : "false");
|
| 71 |
+
$("tab-" + t).tabIndex = on ? 0 : -1;
|
| 72 |
+
$("p-" + t).hidden = !on;
|
| 73 |
+
});
|
| 74 |
+
if (focus) $("tab-" + name).focus();
|
| 75 |
+
if (name === "team") renderTeam();
|
| 76 |
+
}
|
| 77 |
+
TABS.forEach(function (t, i) {
|
| 78 |
+
$("tab-" + t).addEventListener("click", function () { showTab(t); });
|
| 79 |
+
$("tab-" + t).addEventListener("keydown", function (e) {
|
| 80 |
+
if (e.key === "ArrowRight" || e.key === "ArrowLeft") { e.preventDefault(); showTab(TABS[(i + (e.key === "ArrowRight" ? 1 : TABS.length - 1)) % TABS.length], true); }
|
| 81 |
+
});
|
| 82 |
+
});
|
| 83 |
+
qsa("[data-upsell]").forEach(function (b) { b.addEventListener("click", function () { upsell(null, b.getAttribute("data-upsell")); }); });
|
| 84 |
+
|
| 85 |
+
/* ---------- week bar ---------- */
|
| 86 |
+
function renderBar() {
|
| 87 |
+
var s = sch(), d = dates();
|
| 88 |
+
if (document.activeElement !== $("loc-name")) $("loc-name").value = s.name;
|
| 89 |
+
$("wk-label").textContent = "Week of " + R.fmtDate(S.week);
|
| 90 |
+
$("wk-sub").textContent = R.fmtWeek(S.week);
|
| 91 |
+
$("wk-date").value = S.week;
|
| 92 |
+
var multi = S.schedules.length > 1;
|
| 93 |
+
$("loc-select").hidden = !multi;
|
| 94 |
+
$("loc-select").innerHTML = S.schedules.map(function (x) { return '<option value="' + esc(x.id) + '"' + (x.id === s.id ? " selected" : "") + ">" + esc(x.name || "Untitled") + "</option>"; }).join("");
|
| 95 |
+
var weeks = R.savedWeeks(s.shifts, ws());
|
| 96 |
+
if (!weeks.some(function (w) { return w.start === S.week; })) weeks.push({ start: S.week, shifts: 0 });
|
| 97 |
+
weeks.sort(function (a, b) { return a.start < b.start ? 1 : -1; });
|
| 98 |
+
$("hist").hidden = !pro();
|
| 99 |
+
$("btn-hist-lock").hidden = pro();
|
| 100 |
+
$("hist").innerHTML = weeks.map(function (w) { return '<option value="' + w.start + '"' + (w.start === S.week ? " selected" : "") + ">" + R.fmtLong(w.start) + " · " + w.shifts + " shifts</option>"; }).join("");
|
| 101 |
+
var here = R.weekShifts(s.shifts, S.week).length, prev = R.weekShifts(s.shifts, R.addDays(S.week, -7)).length;
|
| 102 |
+
$("btn-copy-last").hidden = !(pro() && !here && prev);
|
| 103 |
+
var n = s.staff.length;
|
| 104 |
+
var staffLine = pro() ? n + " staff · unlimited with Pro" : n + " of " + FREE_STAFF + " free staff";
|
| 105 |
+
$("staff-limit").textContent = staffLine; $("staff-limit2").textContent = staffLine;
|
| 106 |
+
$("staff-limit").className = $("staff-limit2").className = "limit" + (!pro() && n >= FREE_STAFF ? " out" : "");
|
| 107 |
+
$("week-limit").textContent = pro() ? "· " + R.savedWeeks(s.shifts, ws()).length + " saved weeks · " + S.schedules.length + " location" + (S.schedules.length > 1 ? "s" : "") : "· 1 saved week at a time on the free plan";
|
| 108 |
+
void d;
|
| 109 |
+
}
|
| 110 |
+
$("loc-name").addEventListener("input", function () { sch().name = this.value; touch(); renderPrintable(); renderShare(); if (S.schedules.length > 1) renderBar(); });
|
| 111 |
+
$("loc-select").addEventListener("change", function () { S.cur = this.value; brush = null; touch(); renderAll(); });
|
| 112 |
+
$("btn-add-loc").addEventListener("click", function () {
|
| 113 |
+
if (!pro()) return upsell("Several locations or schedules are part of Rotasprig Pro.", "location");
|
| 114 |
+
var name = window.prompt("Name of the new location or schedule", "Location " + (S.schedules.length + 1));
|
| 115 |
+
if (name == null) return;
|
| 116 |
+
var n = emptySchedule(name.trim() || "Location " + (S.schedules.length + 1));
|
| 117 |
+
S.schedules.push(n); S.cur = n.id; brush = null; touch(); renderAll(); showTab("team");
|
| 118 |
+
toast("Added " + n.name + ". Add the team for this location.");
|
| 119 |
+
});
|
| 120 |
+
|
| 121 |
+
function goWeek(target, mode) {
|
| 122 |
+
target = R.weekStartOf(target, ws());
|
| 123 |
+
if (target === S.week) return;
|
| 124 |
+
var s = sch();
|
| 125 |
+
if (!pro() && !mode) {
|
| 126 |
+
var others = s.shifts.filter(function (x) { return !R.inWeek(x.date, target); });
|
| 127 |
+
if (others.length) {
|
| 128 |
+
pendingWeek = target;
|
| 129 |
+
$("dw-text").textContent = "The free plan keeps one week at a time. Moving to the week of " + R.fmtLong(target) + " clears the week of " + R.fmtLong(S.week) + " (print or download it first if you need a copy).";
|
| 130 |
+
$("dlg-week").showModal();
|
| 131 |
+
return;
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
if (mode === "copy") {
|
| 135 |
+
var copies = R.copyWeek(s.shifts, S.week, target, function () { return uid("s"); });
|
| 136 |
+
if (pro()) s.shifts = s.shifts.filter(function (x) { return !R.inWeek(x.date, target); }).concat(copies);
|
| 137 |
+
else s.shifts = copies;
|
| 138 |
+
} else if (mode === "empty" && !pro()) s.shifts = [];
|
| 139 |
+
S.week = target; touch(); renderAll();
|
| 140 |
+
}
|
| 141 |
+
$("btn-prev").addEventListener("click", function () { goWeek(R.addDays(S.week, -7)); });
|
| 142 |
+
$("btn-next").addEventListener("click", function () { goWeek(R.addDays(S.week, 7)); });
|
| 143 |
+
$("wk-date").addEventListener("change", function () { if (R.isISO(this.value)) goWeek(this.value); });
|
| 144 |
+
$("hist").addEventListener("change", function () { goWeek(this.value); });
|
| 145 |
+
$("btn-hist-lock").addEventListener("click", function () { upsell("Saved weeks history is part of Rotasprig Pro. The free plan keeps one week at a time.", "history"); });
|
| 146 |
+
$("btn-copy-next").addEventListener("click", function () {
|
| 147 |
+
var s = sch(), target = R.addDays(S.week, 7);
|
| 148 |
+
if (!R.weekShifts(s.shifts, S.week).length) return toast("This week has no shifts to copy yet.");
|
| 149 |
+
if (pro() && R.weekShifts(s.shifts, target).length && !window.confirm("The week of " + R.fmtDate(target) + " already has shifts. Replace them with a copy of this week?")) return;
|
| 150 |
+
if (!pro() && !window.confirm("Copy this week into the week of " + R.fmtDate(target) + "? The free plan keeps one week, so this week is replaced (print or download it first if you need it).")) return;
|
| 151 |
+
goWeek(target, "copy");
|
| 152 |
+
toast("Copied into the week of " + R.fmtDate(S.week) + ".");
|
| 153 |
+
});
|
| 154 |
+
$("btn-copy-last").addEventListener("click", function () {
|
| 155 |
+
var s = sch(), from = R.addDays(S.week, -7);
|
| 156 |
+
s.shifts = s.shifts.concat(R.copyWeek(s.shifts, from, S.week, function () { return uid("s"); }));
|
| 157 |
+
touch(); renderAll(); toast("Copied last week's shifts.");
|
| 158 |
+
});
|
| 159 |
+
$("dw-copy").addEventListener("click", function () { $("dlg-week").close(); goWeek(pendingWeek, "copy"); toast("Shifts copied into the week of " + R.fmtDate(S.week) + "."); });
|
| 160 |
+
$("dw-empty").addEventListener("click", function () { $("dlg-week").close(); goWeek(pendingWeek, "empty"); });
|
| 161 |
+
$("dw-cancel").addEventListener("click", function () { $("dlg-week").close(); });
|
| 162 |
+
$("dw-pro").addEventListener("click", function () { $("dlg-week").close(); upsell("Pro keeps every week, so you can go back to any past schedule.", "week-limit"); });
|
| 163 |
+
|
| 164 |
+
/* ---------- brushes (shift templates) ---------- */
|
| 165 |
+
function tplLabel(t) { return t.label + " " + R.fmtRange(t, fmt()); }
|
| 166 |
+
function currentBrush() {
|
| 167 |
+
var s = sch();
|
| 168 |
+
if (brush === "clip" && clip) return "clip";
|
| 169 |
+
if (brush === "custom") return "custom";
|
| 170 |
+
if (brush && s.templates.some(function (t) { return t.id === brush; })) return brush;
|
| 171 |
+
return s.templates.length ? s.templates[0].id : "custom";
|
| 172 |
+
}
|
| 173 |
+
function renderBrushes() {
|
| 174 |
+
var s = sch(), b = currentBrush();
|
| 175 |
+
var items = s.templates.map(function (t) { return { id: t.id, label: tplLabel(t) }; });
|
| 176 |
+
if (clip) items.push({ id: "clip", label: "Copied: " + R.fmtRange(clip, fmt()) + (clip.station ? " " + clip.station : "") });
|
| 177 |
+
items.push({ id: "custom", label: "Custom…" });
|
| 178 |
+
$("brushes").innerHTML = items.map(function (it) {
|
| 179 |
+
return '<button type="button" role="radio" class="brush' + (it.id === b ? " on" : "") + '" aria-checked="' + (it.id === b) + '" data-brush="' + esc(it.id) + '">' + esc(it.label) + "</button>";
|
| 180 |
+
}).join("");
|
| 181 |
+
}
|
| 182 |
+
$("brushes").addEventListener("click", function (e) {
|
| 183 |
+
var t = e.target.closest("[data-brush]"); if (!t) return;
|
| 184 |
+
brush = t.getAttribute("data-brush"); renderBrushes();
|
| 185 |
+
});
|
| 186 |
+
|
| 187 |
+
/* ---------- grid ---------- */
|
| 188 |
+
function warnMap(list) { var m = {}; list.forEach(function (w) { w.shiftIds.forEach(function (id) { (m[id] = m[id] || []).push(w.text); }); }); return m; }
|
| 189 |
+
function chipHTML(sh, p, wm) {
|
| 190 |
+
var w = wm[sh.id], sub = [sh.station, sh.brk ? sh.brk + "m brk" : "", sh.note].filter(Boolean).join(" · ");
|
| 191 |
+
var label = p.name + ", " + R.fmtDate(sh.date) + ", " + R.fmtRange(sh, fmt()) + (sh.station ? ", " + sh.station : "") + (w ? ". Warning: " + w.join("; ") : "") + ". Edit shift";
|
| 192 |
+
return '<button type="button" class="chip' + (w ? " warn" : "") + '" draggable="true" data-s="' + esc(sh.id) + '" style="--c:' + esc(p.color || "#146356") + '" aria-label="' + esc(label) + '" title="' + esc(w ? w.join("\n") : "Tap to edit, drag to move") + '">' +
|
| 193 |
+
(w ? '<em class="wflag" aria-hidden="true">!</em>' : "") + "<b>" + esc(R.fmtRange(sh, fmt())) + "</b>" + (sub ? "<small>" + esc(sub) + "</small>" : "") + "</button>";
|
| 194 |
+
}
|
| 195 |
+
var lastWarnings = [];
|
| 196 |
+
function renderGrid() {
|
| 197 |
+
var s = sch(), d = dates(), t = R.totals(s.staff, s.shifts, S.week);
|
| 198 |
+
var wl = R.warnings(s.staff, s.shifts, S.week, { minRest: settings().minRest, fmt: fmt() }), wm = warnMap(wl);
|
| 199 |
+
lastWarnings = wl;
|
| 200 |
+
var week = R.sortShifts(R.weekShifts(s.shifts, S.week));
|
| 201 |
+
var focusKey = document.activeElement && document.activeElement.getAttribute && (document.activeElement.getAttribute("data-add") || (document.activeElement.getAttribute("data-s") ? "s:" + document.activeElement.getAttribute("data-s") : ""));
|
| 202 |
+
var h = '<colgroup><col class="c-name">' + d.map(function () { return "<col>"; }).join("") + '<col class="c-tot"></colgroup><thead><tr><th scope="col" class="g-name">Staff</th>' + d.map(function (x) { return '<th scope="col" class="g-day"><b>' + R.fmtDay(x) + "</b><small>" + R.fmtDate(x).slice(4) + "</small></th>"; }).join("") + '<th scope="col" class="g-tot">Hours</th></tr></thead><tbody>';
|
| 203 |
+
if (!s.staff.length) h += '<tr><td colspan="9" class="empty"><p>No staff yet.</p><button type="button" class="btn sm" id="btn-empty-team">Add your team</button></td></tr>';
|
| 204 |
+
s.staff.forEach(function (p) {
|
| 205 |
+
var bp = t.byPerson[p.id], mx = R.parseNum(p.maxHours), over = mx && bp.minutes > mx * 60;
|
| 206 |
+
h += '<tr><th scope="row" class="g-person"><div><i class="dot" style="background:' + esc(p.color) + '"></i><span><b>' + esc(p.name || "Unnamed") + "</b><small>" + esc(p.role || "") + "</small></span></div></th>";
|
| 207 |
+
d.forEach(function (x) {
|
| 208 |
+
var off = p.avail && p.avail[R.dow(x)] === false;
|
| 209 |
+
var key = p.id + "|" + x, has = week.some(function (sh) { return sh.staffId === p.id && sh.date === x; });
|
| 210 |
+
h += '<td class="cell' + (off ? " unavail" : "") + (has ? " has" : "") + '" data-p="' + esc(p.id) + '" data-d="' + x + '">' + (off ? '<span class="na">Unavailable</span>' : "") +
|
| 211 |
+
week.filter(function (sh) { return sh.staffId === p.id && sh.date === x; }).map(function (sh) { return chipHTML(sh, p, wm); }).join("") +
|
| 212 |
+
'<button type="button" class="add" data-add="' + esc(key) + '" aria-label="Add shift for ' + esc(p.name) + " on " + R.fmtDate(x) + '">+</button></td>';
|
| 213 |
+
});
|
| 214 |
+
h += '<td class="g-tot num' + (over ? " over" : "") + '"><b>' + R.hrs(bp.minutes) + " h</b>" + (mx ? "<small>max " + mx + " h</small>" : "") + (bp.rate != null && bp.minutes ? "<small>" + money(bp.cost) + "</small>" : "") + "</td></tr>";
|
| 215 |
+
});
|
| 216 |
+
h += "</tbody>";
|
| 217 |
+
if (s.staff.length) {
|
| 218 |
+
h += '<tfoot><tr><th scope="row">People on</th>' + t.byDay.map(function (x) { return '<td class="num">' + x.people + "</td>"; }).join("") + '<td class="num">' + t.total.people + "</td></tr>" +
|
| 219 |
+
'<tr><th scope="row">Hours</th>' + t.byDay.map(function (x) { return '<td class="num">' + R.hrs(x.minutes) + "</td>"; }).join("") + '<td class="num"><b>' + R.hrs(t.total.minutes) + "</b></td></tr>" +
|
| 220 |
+
'<tr><th scope="row">Labour cost</th>' + t.byDay.map(function (x) { return '<td class="num">' + money(x.cost) + "</td>"; }).join("") + '<td class="num"><b id="tot-cost">' + money(t.total.cost) + "</b></td></tr></tfoot>";
|
| 221 |
+
}
|
| 222 |
+
$("grid").innerHTML = h;
|
| 223 |
+
if ($("btn-empty-team")) $("btn-empty-team").addEventListener("click", function () { showTab("team"); });
|
| 224 |
+
if (focusKey) {
|
| 225 |
+
var el = focusKey.indexOf("s:") === 0 ? document.querySelector('[data-s="' + focusKey.slice(2) + '"]') : document.querySelector('[data-add="' + focusKey + '"]');
|
| 226 |
+
if (el) el.focus();
|
| 227 |
+
}
|
| 228 |
+
$("warns").innerHTML = wl.map(function (w) { return '<li class="w-' + w.type + '"><b>' + ({ rest: "Short rest", max: "Over max hours", overlap: "Overlap", unavailable: "Unavailable", invalid: "Check times" }[w.type]) + ":</b> " + esc(w.text) + "</li>"; }).join("") ||
|
| 229 |
+
(week.length ? '<li class="ok">No clashes: rest of at least ' + esc(settings().minRest) + " h, no overlaps, nobody over their maximum or on a day off.</li>" : "");
|
| 230 |
+
var unrated = t.total.unrated ? '<small>' + R.hrs(t.total.unrated) + " h without a rate not costed</small>" : "<small>at the hourly rates you entered</small>";
|
| 231 |
+
$("kpis").innerHTML =
|
| 232 |
+
'<div class="tile hero-tile"><span>Labour cost this week</span><b id="k-cost">' + money(t.total.cost) + "</b>" + unrated + "</div>" +
|
| 233 |
+
'<div class="tile"><span>Paid hours (after breaks)</span><b id="k-hours">' + R.hrs(t.total.minutes) + " h</b><small>" + t.total.shifts + " shifts</small></div>" +
|
| 234 |
+
'<div class="tile"><span>Staff scheduled</span><b id="k-people">' + t.total.people + "</b><small>of " + s.staff.length + " on the team</small></div>" +
|
| 235 |
+
'<div class="tile"><span>Warnings</span><b id="k-warn" class="' + (wl.length ? "over" : "ok") + '">' + wl.length + "</b><small>" + (wl.length ? "see the list above" : "all clear") + "</small></div>";
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
function addShift(pid, date) {
|
| 239 |
+
var s = sch(), b = currentBrush(), src = null;
|
| 240 |
+
if (b === "custom") return openShift(null, pid, date);
|
| 241 |
+
if (b === "clip") src = clip; else src = s.templates.filter(function (t) { return t.id === b; })[0];
|
| 242 |
+
if (!src) return openShift(null, pid, date);
|
| 243 |
+
var sh = { id: uid("s"), staffId: pid, date: date, start: src.start, end: src.end, brk: Number(src.brk) || 0, station: src.station || "", note: b === "clip" ? src.note || "" : "" };
|
| 244 |
+
s.shifts.push(sh); touch(); renderMain();
|
| 245 |
+
}
|
| 246 |
+
function copyShift(sh) {
|
| 247 |
+
clip = { start: sh.start, end: sh.end, brk: sh.brk, station: sh.station, note: sh.note };
|
| 248 |
+
brush = "clip"; renderBrushes();
|
| 249 |
+
toast("Copied " + R.fmtRange(sh, fmt()) + ". Tap + on any day to paste.");
|
| 250 |
+
}
|
| 251 |
+
function deleteShift(id) { var s = sch(); s.shifts = s.shifts.filter(function (x) { return x.id !== id; }); touch(); renderMain(); }
|
| 252 |
+
|
| 253 |
+
$("grid").addEventListener("click", function (e) {
|
| 254 |
+
var add = e.target.closest("[data-add]");
|
| 255 |
+
if (add) { var td = add.closest("td"); return addShift(td.getAttribute("data-p"), td.getAttribute("data-d")); }
|
| 256 |
+
var chip = e.target.closest("[data-s]");
|
| 257 |
+
if (chip) { var sh = shiftById(chip.getAttribute("data-s")); if (sh) openShift(sh); }
|
| 258 |
+
});
|
| 259 |
+
$("grid").addEventListener("keydown", function (e) {
|
| 260 |
+
var mod = e.ctrlKey || e.metaKey;
|
| 261 |
+
var chip = e.target.closest && e.target.closest("[data-s]");
|
| 262 |
+
if (chip) {
|
| 263 |
+
var sh = shiftById(chip.getAttribute("data-s"));
|
| 264 |
+
if (mod && (e.key === "c" || e.key === "C")) { e.preventDefault(); if (sh) copyShift(sh); }
|
| 265 |
+
else if (e.key === "Delete" || e.key === "Backspace") { e.preventDefault(); if (sh) { deleteShift(sh.id); toast("Shift deleted."); } }
|
| 266 |
+
return;
|
| 267 |
+
}
|
| 268 |
+
var add = e.target.closest && e.target.closest("[data-add]");
|
| 269 |
+
if (add && mod && (e.key === "v" || e.key === "V")) {
|
| 270 |
+
e.preventDefault();
|
| 271 |
+
if (!clip) return toast("Copy a shift first: select it and press Ctrl+C.");
|
| 272 |
+
brush = "clip"; var td = add.closest("td"); addShift(td.getAttribute("data-p"), td.getAttribute("data-d")); renderBrushes();
|
| 273 |
+
}
|
| 274 |
+
});
|
| 275 |
+
// drag to move; hold Ctrl/Alt/Cmd to copy
|
| 276 |
+
var dragId = null;
|
| 277 |
+
$("grid").addEventListener("dragstart", function (e) {
|
| 278 |
+
var chip = e.target.closest && e.target.closest("[data-s]"); if (!chip) return;
|
| 279 |
+
dragId = chip.getAttribute("data-s");
|
| 280 |
+
try { e.dataTransfer.setData("text/plain", dragId); e.dataTransfer.effectAllowed = "copyMove"; } catch (er) { /* */ }
|
| 281 |
+
});
|
| 282 |
+
$("grid").addEventListener("dragover", function (e) {
|
| 283 |
+
var td = e.target.closest && e.target.closest("td.cell"); if (!td || !dragId) return;
|
| 284 |
+
e.preventDefault();
|
| 285 |
+
try { e.dataTransfer.dropEffect = e.ctrlKey || e.altKey || e.metaKey ? "copy" : "move"; } catch (er) { /* */ }
|
| 286 |
+
qsa("td.cell.over").forEach(function (x) { if (x !== td) x.classList.remove("over"); });
|
| 287 |
+
td.classList.add("over");
|
| 288 |
+
});
|
| 289 |
+
$("grid").addEventListener("dragleave", function (e) { var td = e.target.closest && e.target.closest("td.cell"); if (td && !td.contains(e.relatedTarget)) td.classList.remove("over"); });
|
| 290 |
+
$("grid").addEventListener("drop", function (e) {
|
| 291 |
+
var td = e.target.closest && e.target.closest("td.cell"); if (!td || !dragId) return;
|
| 292 |
+
e.preventDefault();
|
| 293 |
+
var sh = shiftById(dragId); dragId = null;
|
| 294 |
+
if (!sh) return;
|
| 295 |
+
var pid = td.getAttribute("data-p"), d = td.getAttribute("data-d");
|
| 296 |
+
if (e.ctrlKey || e.altKey || e.metaKey) { var c = {}; Object.keys(sh).forEach(function (k) { c[k] = sh[k]; }); c.id = uid("s"); c.staffId = pid; c.date = d; sch().shifts.push(c); toast("Shift copied."); }
|
| 297 |
+
else { sh.staffId = pid; sh.date = d; }
|
| 298 |
+
touch(); renderMain();
|
| 299 |
+
});
|
| 300 |
+
$("grid").addEventListener("dragend", function () { dragId = null; qsa("td.cell.over").forEach(function (x) { x.classList.remove("over"); }); });
|
| 301 |
+
|
| 302 |
+
/* ---------- shift dialog ---------- */
|
| 303 |
+
function hhmm(min) { return R.fmtTime(min, "hhmm"); }
|
| 304 |
+
function openShift(sh, pid, date) {
|
| 305 |
+
var s = sch();
|
| 306 |
+
if (!s.staff.length) { toast("Add a person first."); return showTab("team"); }
|
| 307 |
+
editing = sh ? sh.id : null;
|
| 308 |
+
var base = sh || { staffId: pid || s.staff[0].id, date: date || S.week, start: 540, end: 1020, brk: 30, station: "", note: "" };
|
| 309 |
+
$("dlg-title").textContent = sh ? "Edit shift" : "New shift";
|
| 310 |
+
$("d-staff").innerHTML = s.staff.map(function (p) { return '<option value="' + esc(p.id) + '">' + esc(p.name) + "</option>"; }).join("");
|
| 311 |
+
$("d-date").innerHTML = dates().map(function (x) { return '<option value="' + x + '">' + R.fmtDate(x) + "</option>"; }).join("");
|
| 312 |
+
$("d-staff").value = base.staffId; $("d-date").value = base.date;
|
| 313 |
+
$("d-start").value = hhmm(base.start); $("d-end").value = hhmm(base.end);
|
| 314 |
+
$("d-brk").value = base.brk || 0; $("d-station").value = base.station || ""; $("d-note").value = base.note || "";
|
| 315 |
+
$("d-del").hidden = $("d-copy").hidden = !sh;
|
| 316 |
+
$("d-tpls").innerHTML = s.templates.length ? '<span class="hint">Use a template:</span> ' + s.templates.map(function (t) { return '<button type="button" class="btn ghost sm" data-tpl="' + esc(t.id) + '">' + esc(tplLabel(t)) + "</button>"; }).join("") : "";
|
| 317 |
+
$("dl-stations").innerHTML = uniq(s.shifts.map(function (x) { return x.station; }).concat(s.staff.map(function (p) { return p.role; }))).map(function (x) { return '<option value="' + esc(x) + '">'; }).join("");
|
| 318 |
+
dlgCalc();
|
| 319 |
+
$("dlg").showModal();
|
| 320 |
+
$("d-start").focus();
|
| 321 |
+
}
|
| 322 |
+
function uniq(a) { var m = {}, out = []; a.forEach(function (x) { x = (x || "").trim(); if (x && !m[x.toLowerCase()]) { m[x.toLowerCase()] = 1; out.push(x); } }); return out; }
|
| 323 |
+
function dlgValues() {
|
| 324 |
+
return { start: R.parseTime($("d-start").value), end: R.parseTime($("d-end").value), brk: Math.max(0, Math.round(R.parseNum($("d-brk").value) || 0)), station: $("d-station").value.trim(), note: $("d-note").value.trim(), staffId: $("d-staff").value, date: $("d-date").value };
|
| 325 |
+
}
|
| 326 |
+
function dlgCalc() {
|
| 327 |
+
var v = dlgValues();
|
| 328 |
+
if (v.start == null || v.end == null) { $("d-calc").textContent = "Enter a start and end time."; return; }
|
| 329 |
+
var len = R.duration(v.start, v.end);
|
| 330 |
+
$("d-calc").textContent = !len ? "End time is the same as the start." : R.hrs(len) + " h shift" + (v.end <= v.start ? " (ends the next day)" : "") + ", " + R.hrs(R.paidMinutes(v)) + " paid hours after the break";
|
| 331 |
+
}
|
| 332 |
+
["d-start", "d-end", "d-brk"].forEach(function (id) { $(id).addEventListener("input", dlgCalc); });
|
| 333 |
+
$("d-tpls").addEventListener("click", function (e) {
|
| 334 |
+
var b = e.target.closest("[data-tpl]"); if (!b) return;
|
| 335 |
+
var t = sch().templates.filter(function (x) { return x.id === b.getAttribute("data-tpl"); })[0]; if (!t) return;
|
| 336 |
+
$("d-start").value = hhmm(t.start); $("d-end").value = hhmm(t.end); $("d-brk").value = t.brk || 0; if (t.station) $("d-station").value = t.station; dlgCalc();
|
| 337 |
+
});
|
| 338 |
+
$("dlg-form").addEventListener("submit", function (e) {
|
| 339 |
+
e.preventDefault();
|
| 340 |
+
var v = dlgValues();
|
| 341 |
+
if (v.start == null || v.end == null || !R.duration(v.start, v.end)) { dlgCalc(); toast("Check the start and end times."); return; }
|
| 342 |
+
var s = sch(), sh = editing ? shiftById(editing) : null;
|
| 343 |
+
if (!sh) { sh = { id: uid("s") }; s.shifts.push(sh); }
|
| 344 |
+
Object.keys(v).forEach(function (k) { sh[k] = v[k]; });
|
| 345 |
+
$("dlg").close(); touch(); renderMain();
|
| 346 |
+
});
|
| 347 |
+
$("d-copy").addEventListener("click", function () { var v = dlgValues(); if (v.start == null || v.end == null) return; $("dlg").close(); copyShift(v); });
|
| 348 |
+
$("d-del").addEventListener("click", function () { if (editing) deleteShift(editing); $("dlg").close(); });
|
| 349 |
+
$("d-cancel").addEventListener("click", function () { $("dlg").close(); });
|
| 350 |
+
|
| 351 |
+
/* ---------- team ---------- */
|
| 352 |
+
function dayOrder() { var o = []; for (var i = 0; i < 7; i++) o.push((ws() + i) % 7); return o; }
|
| 353 |
+
function renderTeam() {
|
| 354 |
+
var s = sch();
|
| 355 |
+
$("staff-list").innerHTML = s.staff.map(function (p, i) {
|
| 356 |
+
var av = dayOrder().map(function (k) {
|
| 357 |
+
return '<label class="av"><input type="checkbox" data-av="' + k + '"' + (!p.avail || p.avail[k] !== false ? " checked" : "") + "><span>" + R.DOW[k].slice(0, 2) + "</span></label>";
|
| 358 |
+
}).join("");
|
| 359 |
+
return '<div class="person" data-p="' + esc(p.id) + '">' +
|
| 360 |
+
'<div class="pf-name"><label for="pn-' + i + '">Name</label><input id="pn-' + i + '" data-f="name" value="' + esc(p.name) + '"></div>' +
|
| 361 |
+
'<div class="pf-role"><label for="pr-' + i + '">Role</label><input id="pr-' + i + '" data-f="role" value="' + esc(p.role || "") + '"></div>' +
|
| 362 |
+
'<div class="pf-col"><label for="pc-' + i + '">Colour</label><input id="pc-' + i + '" type="color" data-f="color" value="' + esc(p.color || "#146356") + '"></div>' +
|
| 363 |
+
'<div class="pf-rate"><label for="pp-' + i + '">Rate / h</label><input id="pp-' + i + '" data-f="rate" inputmode="decimal" value="' + esc(p.rate == null ? "" : p.rate) + '"></div>' +
|
| 364 |
+
'<div class="pf-max"><label for="pm-' + i + '">Max h / week</label><input id="pm-' + i + '" data-f="maxHours" inputmode="decimal" value="' + esc(p.maxHours == null ? "" : p.maxHours) + '"></div>' +
|
| 365 |
+
'<fieldset class="pf-av"><legend>Can work</legend>' + av + "</fieldset>" +
|
| 366 |
+
'<div class="pf-del"><button type="button" class="icon-btn" data-del aria-label="Remove ' + esc(p.name) + '">×</button></div></div>';
|
| 367 |
+
}).join("") || '<p class="hint">No staff yet. Add the first person below, or load an example at the top.</p>';
|
| 368 |
+
$("tpl-list").innerHTML = s.templates.map(function (t, i) {
|
| 369 |
+
return '<div class="tpl" data-t="' + esc(t.id) + '">' +
|
| 370 |
+
'<div><label for="tl-' + i + '">Name</label><input id="tl-' + i + '" data-f="label" value="' + esc(t.label) + '"></div>' +
|
| 371 |
+
'<div><label for="ts-' + i + '">Start</label><input id="ts-' + i + '" type="time" step="300" data-f="start" value="' + hhmm(t.start) + '"></div>' +
|
| 372 |
+
'<div><label for="te-' + i + '">End</label><input id="te-' + i + '" type="time" step="300" data-f="end" value="' + hhmm(t.end) + '"></div>' +
|
| 373 |
+
'<div><label for="tb-' + i + '">Break (min)</label><input id="tb-' + i + '" data-f="brk" inputmode="numeric" value="' + esc(t.brk || 0) + '"></div>' +
|
| 374 |
+
'<div><label for="tt-' + i + '">Station <span class="opt">optional</span></label><input id="tt-' + i + '" data-f="station" value="' + esc(t.station || "") + '"></div>' +
|
| 375 |
+
'<div class="pf-del"><button type="button" class="icon-btn" data-del aria-label="Remove template ' + esc(t.label) + '">×</button></div></div>';
|
| 376 |
+
}).join("") || '<p class="hint">No templates. Add your usual shifts, such as Open 7:00-15:00.</p>';
|
| 377 |
+
}
|
| 378 |
+
$("staff-list").addEventListener("input", function (e) {
|
| 379 |
+
var row = e.target.closest(".person"); if (!row) return;
|
| 380 |
+
var p = person(row.getAttribute("data-p")); if (!p) return;
|
| 381 |
+
var f = e.target.getAttribute("data-f");
|
| 382 |
+
if (f) { var v = e.target.value; if (f === "rate" || f === "maxHours") { var n = R.parseNum(v); v = v.trim() === "" ? "" : n != null && n >= 0 ? n : p[f]; } p[f] = v; }
|
| 383 |
+
var a = e.target.getAttribute("data-av");
|
| 384 |
+
if (a != null) { p.avail = p.avail || [true, true, true, true, true, true, true]; p.avail[Number(a)] = e.target.checked; }
|
| 385 |
+
touch(); renderMain();
|
| 386 |
+
});
|
| 387 |
+
$("staff-list").addEventListener("change", function (e) { if (e.target.getAttribute("data-av") != null || e.target.type === "color") { /* handled on input */ } });
|
| 388 |
+
$("staff-list").addEventListener("click", function (e) {
|
| 389 |
+
var b = e.target.closest("[data-del]"); if (!b) return;
|
| 390 |
+
var row = b.closest(".person"), id = row.getAttribute("data-p"), p = person(id), s = sch();
|
| 391 |
+
var n = s.shifts.filter(function (x) { return x.staffId === id; }).length;
|
| 392 |
+
if (n && !window.confirm("Remove " + p.name + " and their " + n + " shifts?")) return;
|
| 393 |
+
s.staff = s.staff.filter(function (x) { return x.id !== id; }); s.shifts = s.shifts.filter(function (x) { return x.staffId !== id; });
|
| 394 |
+
touch(); renderAll();
|
| 395 |
+
});
|
| 396 |
+
$("btn-add-staff").addEventListener("click", function () {
|
| 397 |
+
var s = sch();
|
| 398 |
+
if (!pro() && s.staff.length >= FREE_STAFF) return upsell("The free plan schedules up to " + FREE_STAFF + " staff. Pro gives you unlimited staff and several locations.", "staff-limit");
|
| 399 |
+
var used = s.staff.map(function (p) { return p.color; });
|
| 400 |
+
var color = R.COLORS.filter(function (c) { return used.indexOf(c) < 0; })[0] || R.COLORS[s.staff.length % R.COLORS.length];
|
| 401 |
+
s.staff.push({ id: uid("p"), name: "New person " + (s.staff.length + 1), role: "", color: color, rate: "", maxHours: 40, avail: [true, true, true, true, true, true, true] });
|
| 402 |
+
touch(); renderAll();
|
| 403 |
+
var inputs = qsa('#staff-list [data-f="name"]'); var last = inputs[inputs.length - 1]; if (last) { last.focus(); last.select(); }
|
| 404 |
+
});
|
| 405 |
+
$("tpl-list").addEventListener("input", function (e) {
|
| 406 |
+
var row = e.target.closest(".tpl"); if (!row) return;
|
| 407 |
+
var t = sch().templates.filter(function (x) { return x.id === row.getAttribute("data-t"); })[0]; if (!t) return;
|
| 408 |
+
var f = e.target.getAttribute("data-f"), v = e.target.value;
|
| 409 |
+
if (f === "start" || f === "end") { var m = R.parseTime(v); if (m == null) return; t[f] = m; }
|
| 410 |
+
else if (f === "brk") t.brk = Math.max(0, Math.round(R.parseNum(v) || 0));
|
| 411 |
+
else t[f] = v;
|
| 412 |
+
touch(); renderBrushes();
|
| 413 |
+
});
|
| 414 |
+
$("tpl-list").addEventListener("click", function (e) {
|
| 415 |
+
var b = e.target.closest("[data-del]"); if (!b) return;
|
| 416 |
+
var id = b.closest(".tpl").getAttribute("data-t"); sch().templates = sch().templates.filter(function (x) { return x.id !== id; });
|
| 417 |
+
touch(); renderTeam(); renderBrushes();
|
| 418 |
+
});
|
| 419 |
+
$("btn-add-tpl").addEventListener("click", function () {
|
| 420 |
+
sch().templates.push({ id: uid("t"), label: "Shift " + (sch().templates.length + 1), start: 540, end: 1020, brk: 30, station: "" });
|
| 421 |
+
touch(); renderTeam(); renderBrushes();
|
| 422 |
+
});
|
| 423 |
+
|
| 424 |
+
/* ---------- settings ---------- */
|
| 425 |
+
$("s-currency").innerHTML = R.CURRENCIES.map(function (c) { return '<option value="' + c + '">' + c + "</option>"; }).join("");
|
| 426 |
+
function settingsToForm() {
|
| 427 |
+
var st = settings();
|
| 428 |
+
$("s-rest").value = st.minRest; $("s-currency").value = st.currency; $("s-time").value = st.time; $("s-wstart").value = String(ws());
|
| 429 |
+
$("s-paper").value = st.paper; $("s-printcost").checked = !!st.printCost; $("s-otafter").value = st.otAfter; $("s-otmult").value = st.otMult;
|
| 430 |
+
}
|
| 431 |
+
$("s-rest").addEventListener("input", function () { var v = R.parseNum(this.value); settings().minRest = v != null && v >= 0 && v <= 24 ? v : 10; touch(); renderMain(); });
|
| 432 |
+
$("s-currency").addEventListener("change", function () { settings().currency = this.value; touch(); renderMain(); });
|
| 433 |
+
$("s-time").addEventListener("change", function () { settings().time = this.value; touch(); renderMain(); renderTeam(); });
|
| 434 |
+
$("s-wstart").addEventListener("change", function () { settings().wstart = Number(this.value); S.week = R.weekStartOf(S.week, ws()); touch(); renderAll(); });
|
| 435 |
+
$("s-paper").addEventListener("change", function () { settings().paper = this.value; touch(); renderPrintable(); });
|
| 436 |
+
$("s-printcost").addEventListener("change", function () { settings().printCost = this.checked; touch(); renderPrintable(); });
|
| 437 |
+
$("s-otafter").addEventListener("input", function () { var v = R.parseNum(this.value); settings().otAfter = v != null && v >= 0 ? v : 40; touch(); renderLabour(); });
|
| 438 |
+
$("s-otmult").addEventListener("input", function () { var v = R.parseNum(this.value); settings().otMult = v != null && v >= 1 ? v : 1.5; touch(); renderLabour(); });
|
| 439 |
+
|
| 440 |
+
/* ---------- coverage ---------- */
|
| 441 |
+
function renderCoverage() {
|
| 442 |
+
var s = sch(), sel = $("cov-filter"), prev = sel.value || "all";
|
| 443 |
+
var roles = uniq(s.staff.map(function (p) { return p.role; })), stations = uniq(R.weekShifts(s.shifts, S.week).map(function (x) { return x.station; }));
|
| 444 |
+
sel.innerHTML = '<option value="all">Everyone</option>' + (roles.length ? '<optgroup label="Role">' + roles.map(function (r) { return '<option value="r:' + esc(r) + '">' + esc(r) + "</option>"; }).join("") + "</optgroup>" : "") +
|
| 445 |
+
(stations.length ? '<optgroup label="Station">' + stations.map(function (r) { return '<option value="s:' + esc(r) + '">' + esc(r) + "</option>"; }).join("") + "</optgroup>" : "");
|
| 446 |
+
sel.value = prev; if (sel.value !== prev) sel.value = "all";
|
| 447 |
+
var f = sel.value, filter = null;
|
| 448 |
+
if (f.indexOf("r:") === 0) filter = function (sh, p) { return (p.role || "").toLowerCase() === f.slice(2).toLowerCase(); };
|
| 449 |
+
if (f.indexOf("s:") === 0) filter = function (sh) { return (sh.station || "").toLowerCase() === f.slice(2).toLowerCase(); };
|
| 450 |
+
var c = R.coverage(s.staff, s.shifts, S.week, filter), d = dates();
|
| 451 |
+
var hours = []; for (var hh = c.first; hh <= c.last; hh++) hours.push(hh);
|
| 452 |
+
var h = '<caption class="sr">People on shift per hour, week of ' + R.fmtDate(S.week) + '</caption><thead><tr><th scope="col">Day</th>' + hours.map(function (x) { return '<th scope="col">' + esc(fmt() === "12" ? R.fmtTime(x * 60, "12") : String(x)) + "</th>"; }).join("") + "</tr></thead><tbody>";
|
| 453 |
+
d.forEach(function (x, i) {
|
| 454 |
+
h += '<tr><th scope="row">' + R.fmtDay(x) + "</th>" + hours.map(function (hr) {
|
| 455 |
+
var n = c.grid[i][hr], pct = c.peak ? Math.round(12 + 78 * n / c.peak) : 0;
|
| 456 |
+
var label = R.fmtDay(x) + " " + R.fmtTime(hr * 60, fmt()) + "-" + R.fmtTime(hr * 60 + 60, fmt()) + ": " + n + (n === 1 ? " person" : " people");
|
| 457 |
+
return '<td class="cv' + (n ? "" : " z") + (pct > 55 ? " dk" : "") + '"' + (n ? ' style="--p:' + pct + '%"' : "") + ' title="' + esc(label) + '">' + (n || "") + "</td>";
|
| 458 |
+
}).join("") + "</tr>";
|
| 459 |
+
});
|
| 460 |
+
$("cov-table").innerHTML = h + "</tbody>";
|
| 461 |
+
var single = R.hourRanges(c.single, d, fmt());
|
| 462 |
+
$("cov-sum").innerHTML = c.peak ? "<b>Busiest:</b> " + c.peak + " people, " + esc(R.hourRanges(c.peaks, d, fmt()).slice(0, 4).join(", ")) + ". " +
|
| 463 |
+
(single.length ? "<b>Only one person on:</b> " + esc(single.slice(0, 6).join(", ")) + (single.length > 6 ? " and " + (single.length - 6) + " more" : "") + "." : "Never fewer than two people on while open.") : "No shifts this week yet.";
|
| 464 |
+
}
|
| 465 |
+
$("cov-filter").addEventListener("change", renderCoverage);
|
| 466 |
+
|
| 467 |
+
/* ---------- per-person text ---------- */
|
| 468 |
+
function textFor(p) { return R.personText(p, sch().shifts, S.week, { fmt: fmt(), place: sch().name }); }
|
| 469 |
+
function renderShare() {
|
| 470 |
+
var s = sch();
|
| 471 |
+
$("people").innerHTML = s.staff.map(function (p) {
|
| 472 |
+
return '<div class="pcard-s" data-p="' + esc(p.id) + '"><div class="pc-head"><i class="dot" style="background:' + esc(p.color) + '"></i><b>' + esc(p.name) + "</b></div><pre>" + esc(textFor(p)) + '</pre><div class="btns"><button type="button" class="btn sm" data-copy>Copy text</button><button type="button" class="btn ghost sm" data-ppng>PNG <span class="pro-tag">PRO</span></button></div></div>';
|
| 473 |
+
}).join("") || '<p class="hint">Add your team first.</p>';
|
| 474 |
+
}
|
| 475 |
+
function copyText(t) {
|
| 476 |
+
function fallback() {
|
| 477 |
+
var ta = document.createElement("textarea"); ta.value = t; ta.setAttribute("readonly", ""); ta.style.position = "fixed"; ta.style.opacity = "0";
|
| 478 |
+
document.body.appendChild(ta); ta.select(); var ok = false; try { ok = document.execCommand("copy"); } catch (e) { ok = false; } ta.remove(); return ok;
|
| 479 |
+
}
|
| 480 |
+
if (navigator.clipboard && window.isSecureContext) return navigator.clipboard.writeText(t).then(function () { return true; }, function () { return fallback(); });
|
| 481 |
+
return Promise.resolve(fallback());
|
| 482 |
+
}
|
| 483 |
+
$("people").addEventListener("click", function (e) {
|
| 484 |
+
var card = e.target.closest("[data-p]"); if (!card) return;
|
| 485 |
+
var p = person(card.getAttribute("data-p")); if (!p) return;
|
| 486 |
+
if (e.target.closest("[data-copy]")) copyText(textFor(p)).then(function (ok) { toast(ok ? "Copied " + p.name + "'s shifts." : "Select the text and copy it."); });
|
| 487 |
+
if (e.target.closest("[data-ppng]")) {
|
| 488 |
+
if (!pro()) return upsell("A PNG for each person is part of Rotasprig Pro.", "person-png");
|
| 489 |
+
personCanvas(p).toBlob(function (b) { X.download("rotasprig-" + slugify(p.name) + "-" + S.week + ".png", b, "image/png"); toast("Downloaded " + p.name + "'s PNG."); }, "image/png");
|
| 490 |
+
}
|
| 491 |
+
});
|
| 492 |
+
$("btn-copy-all").addEventListener("click", function () {
|
| 493 |
+
var all = sch().staff.map(textFor).join("\n\n");
|
| 494 |
+
copyText(all).then(function (ok) { toast(ok ? "Copied everyone's shifts." : "Select the text and copy it."); });
|
| 495 |
+
});
|
| 496 |
+
$("btn-goto-share").addEventListener("click", function () { showTab("share"); $("p-share").scrollIntoView({ behavior: "smooth", block: "start" }); });
|
| 497 |
+
|
| 498 |
+
/* ---------- labour report (Pro) ---------- */
|
| 499 |
+
function renderLabour() {
|
| 500 |
+
var on = pro();
|
| 501 |
+
$("labour-lock").hidden = on; $("labour-tool").hidden = !on;
|
| 502 |
+
if (!on) return;
|
| 503 |
+
var s = sch(), L = R.labour(s.staff, s.shifts, S.week, { otAfter: settings().otAfter, otMult: settings().otMult });
|
| 504 |
+
$("lab-table").innerHTML = '<caption>By person, week of ' + esc(R.fmtLong(S.week)) + '</caption><thead><tr><th>Name</th><th>Role</th><th class="num">Shifts</th><th class="num">Hours</th><th class="num">Regular</th><th class="num">Overtime</th><th class="num">Rate</th><th class="num">Base pay</th><th class="num">OT premium</th><th class="num">Total</th></tr></thead><tbody>' +
|
| 505 |
+
L.rows.map(function (r) {
|
| 506 |
+
return "<tr><td>" + esc(r.name) + "</td><td>" + esc(r.role) + '</td><td class="num">' + r.shifts + '</td><td class="num">' + R.hrs(r.minutes) + '</td><td class="num">' + R.hrs(r.regular) + '</td><td class="num' + (r.ot ? " up" : "") + '">' + R.hrs(r.ot) + '</td><td class="num">' + (r.rate == null ? "no rate" : money(r.rate)) + '</td><td class="num">' + money(r.base) + '</td><td class="num">' + money(r.premium) + '</td><td class="num"><b>' + money(r.total) + "</b></td></tr>";
|
| 507 |
+
}).join("") + '</tbody><tfoot><tr><th scope="row">Total</th><td></td><td></td><td class="num">' + R.hrs(L.sum.minutes) + '</td><td class="num">' + R.hrs(L.sum.regular) + '</td><td class="num">' + R.hrs(L.sum.ot) + '</td><td></td><td class="num">' + money(L.sum.base) + '</td><td class="num">' + money(L.sum.premium) + '</td><td class="num"><b id="lab-total">' + money(L.sum.total) + "</b></td></tr></tfoot>";
|
| 508 |
+
$("lab-days").innerHTML = '<caption>By day (base rate)</caption><thead><tr><th>Day</th><th class="num">People</th><th class="num">Hours</th><th class="num">Labour cost</th></tr></thead><tbody>' +
|
| 509 |
+
L.days.map(function (d) { return "<tr><td>" + R.fmtDate(d.date) + '</td><td class="num">' + d.people + '</td><td class="num">' + R.hrs(d.minutes) + '</td><td class="num">' + money(d.cost) + "</td></tr>"; }).join("") + "</tbody>";
|
| 510 |
+
}
|
| 511 |
+
function csv(kind) {
|
| 512 |
+
if (!pro()) return upsell("CSV export for payroll is part of Rotasprig Pro.", "csv");
|
| 513 |
+
var s = sch();
|
| 514 |
+
var body = kind === "hours" ? R.hoursCSV(s.staff, s.shifts, S.week, { otAfter: settings().otAfter, otMult: settings().otMult }, s.name) : R.shiftsCSV(s.staff, s.shifts, S.week, s.name);
|
| 515 |
+
X.download("rotasprig-" + kind + "-" + slugify(s.name) + "-" + S.week + ".csv", "" + body, "text/csv;charset=utf-8");
|
| 516 |
+
toast("CSV downloaded.");
|
| 517 |
+
}
|
| 518 |
+
$("btn-csv-shifts").addEventListener("click", function () { csv("shifts"); });
|
| 519 |
+
$("btn-csv-hours").addEventListener("click", function () { csv("hours"); });
|
| 520 |
+
|
| 521 |
+
/* ---------- print ---------- */
|
| 522 |
+
function printableHTML() {
|
| 523 |
+
var s = sch(), d = dates(), t = R.totals(s.staff, s.shifts, S.week), week = R.sortShifts(R.weekShifts(s.shifts, S.week)), showCost = !!settings().printCost;
|
| 524 |
+
var h = '<div class="psheet"><header><div><h1>' + esc(s.name || "Staff schedule") + "</h1><p>Staff schedule · " + esc(R.fmtWeek(S.week)) + '</p></div><p class="ps-meta">' + t.total.shifts + " shifts · " + R.hrs(t.total.minutes) + " paid hours" + (showCost ? " · labour " + money(t.total.cost) : "") + "</p></header>";
|
| 525 |
+
h += '<table><thead><tr><th class="ps-name">Name</th>' + d.map(function (x) { return "<th>" + R.fmtDate(x) + "</th>"; }).join("") + '<th class="num">Hours</th></tr></thead><tbody>';
|
| 526 |
+
s.staff.forEach(function (p) {
|
| 527 |
+
h += '<tr><th class="ps-name" style="border-left-color:' + esc(p.color) + '"><b>' + esc(p.name) + "</b><small>" + esc(p.role || "") + "</small></th>";
|
| 528 |
+
d.forEach(function (x) {
|
| 529 |
+
var list = week.filter(function (sh) { return sh.staffId === p.id && sh.date === x; });
|
| 530 |
+
h += "<td>" + (list.length ? list.map(function (sh) { return "<div class=\"ps-shift\"><b>" + esc(R.fmtRange(sh, fmt())) + "</b>" + (sh.station || sh.note ? "<small>" + esc([sh.station, sh.note].filter(Boolean).join(" · ")) + "</small>" : "") + "</div>"; }).join("") : '<span class="ps-off">off</span>') + "</td>";
|
| 531 |
+
});
|
| 532 |
+
h += '<td class="num"><b>' + R.hrs(t.byPerson[p.id].minutes) + "</b></td></tr>";
|
| 533 |
+
});
|
| 534 |
+
h += '</tbody><tfoot><tr><th class="ps-name">Hours</th>' + t.byDay.map(function (x) { return '<td class="num">' + R.hrs(x.minutes) + "</td>"; }).join("") + '<td class="num"><b>' + R.hrs(t.total.minutes) + "</b></td></tr>" +
|
| 535 |
+
(showCost ? '<tr><th class="ps-name">Labour cost</th>' + t.byDay.map(function (x) { return '<td class="num">' + money(x.cost) + "</td>"; }).join("") + '<td class="num"><b>' + money(t.total.cost) + "</b></td></tr>" : "") + "</tfoot></table>";
|
| 536 |
+
h += '<p class="ps-foot">Hours are after unpaid breaks.' + (pro() ? "" : ' <span class="ps-credit">' + CREDIT + " · " + HUB + "</span>") + "</p></div>";
|
| 537 |
+
return h;
|
| 538 |
+
}
|
| 539 |
+
function renderPrintable() {
|
| 540 |
+
$("page-style").textContent = "@media print{@page{size:" + (settings().paper === "A4" ? "A4" : "letter") + " landscape;margin:9mm}}";
|
| 541 |
+
}
|
| 542 |
+
$("btn-print").addEventListener("click", function () {
|
| 543 |
+
if (!sch().staff.length) return toast("Add your team first.");
|
| 544 |
+
renderPrintable(); $("print-area").innerHTML = printableHTML(); document.body.classList.add("printing");
|
| 545 |
+
setTimeout(function () { window.print(); }, 30);
|
| 546 |
+
});
|
| 547 |
+
window.addEventListener("beforeprint", function () { renderPrintable(); $("print-area").innerHTML = printableHTML(); });
|
| 548 |
+
window.addEventListener("afterprint", function () { document.body.classList.remove("printing"); });
|
| 549 |
+
|
| 550 |
+
/* ---------- PNG ---------- */
|
| 551 |
+
var FONT = 'system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
| 552 |
+
function rr(ctx, x, y, w, h, r) { ctx.beginPath(); ctx.moveTo(x + r, y); ctx.arcTo(x + w, y, x + w, y + h, r); ctx.arcTo(x + w, y + h, x, y + h, r); ctx.arcTo(x, y + h, x, y, r); ctx.arcTo(x, y, x + w, y, r); ctx.closePath(); }
|
| 553 |
+
function fit(ctx, text, w) { if (ctx.measureText(text).width <= w) return text; while (text.length > 1 && ctx.measureText(text + "…").width > w) text = text.slice(0, -1); return text + "…"; }
|
| 554 |
+
function tint(hex, a) { var m = /^#?([0-9a-f]{6})$/i.exec(hex || ""); if (!m) return "rgba(20,99,86," + a + ")"; var n = parseInt(m[1], 16); return "rgba(" + (n >> 16) + "," + ((n >> 8) & 255) + "," + (n & 255) + "," + a + ")"; }
|
| 555 |
+
function weekCanvas() {
|
| 556 |
+
var s = sch(), d = dates(), t = R.totals(s.staff, s.shifts, S.week), week = R.sortShifts(R.weekShifts(s.shifts, S.week)), showCost = !!settings().printCost;
|
| 557 |
+
var W = 1600, M = 40, nameW = 250, totW = 110, dayW = (W - 2 * M - nameW - totW) / 7, headH = 126, thH = 54;
|
| 558 |
+
var rows = s.staff.map(function (p) { var mx = 1; d.forEach(function (x) { mx = Math.max(mx, week.filter(function (sh) { return sh.staffId === p.id && sh.date === x; }).length); }); return Math.max(66, 14 + mx * 52); });
|
| 559 |
+
var footRows = showCost ? 2 : 1, H = headH + thH + rows.reduce(function (a, b) { return a + b; }, 0) + footRows * 44 + 70;
|
| 560 |
+
var cv = document.createElement("canvas"), sc = 1.5; cv.width = W * sc; cv.height = H * sc;
|
| 561 |
+
var ctx = cv.getContext("2d"); ctx.scale(sc, sc);
|
| 562 |
+
ctx.fillStyle = "#FFFFFF"; ctx.fillRect(0, 0, W, H);
|
| 563 |
+
ctx.fillStyle = "#146356"; ctx.fillRect(0, 0, W, 8);
|
| 564 |
+
ctx.fillStyle = "#11141B"; ctx.font = "800 36px " + FONT; ctx.textBaseline = "alphabetic";
|
| 565 |
+
ctx.fillText(fit(ctx, s.name || "Staff schedule", W - 2 * M - 420), M, 66);
|
| 566 |
+
ctx.font = "500 21px " + FONT; ctx.fillStyle = "#4B5262"; ctx.fillText("Staff schedule · " + R.fmtWeek(S.week), M, 100);
|
| 567 |
+
ctx.textAlign = "right"; ctx.font = "600 19px " + FONT;
|
| 568 |
+
ctx.fillText(t.total.shifts + " shifts · " + R.hrs(t.total.minutes) + " paid hours" + (showCost ? " · labour " + money(t.total.cost) : ""), W - M, 100);
|
| 569 |
+
ctx.textAlign = "left";
|
| 570 |
+
var y = headH;
|
| 571 |
+
ctx.fillStyle = "#F1EEE6"; ctx.fillRect(M, y, W - 2 * M, thH);
|
| 572 |
+
ctx.fillStyle = "#11141B"; ctx.font = "700 18px " + FONT; ctx.fillText("Name", M + 14, y + 33);
|
| 573 |
+
d.forEach(function (x, i) { var cx = M + nameW + i * dayW; ctx.font = "800 19px " + FONT; ctx.fillText(R.fmtDay(x), cx + 10, y + 25); ctx.font = "500 15px " + FONT; ctx.fillStyle = "#5B6170"; ctx.fillText(R.fmtDate(x).slice(4), cx + 10, y + 45); ctx.fillStyle = "#11141B"; });
|
| 574 |
+
ctx.textAlign = "right"; ctx.font = "700 18px " + FONT; ctx.fillText("Hours", W - M - 12, y + 33); ctx.textAlign = "left";
|
| 575 |
+
y += thH;
|
| 576 |
+
s.staff.forEach(function (p, ri) {
|
| 577 |
+
var rh = rows[ri];
|
| 578 |
+
if (ri % 2) { ctx.fillStyle = "#FAF8F3"; ctx.fillRect(M, y, W - 2 * M, rh); }
|
| 579 |
+
ctx.fillStyle = p.color || "#146356"; ctx.fillRect(M, y + 8, 6, rh - 16);
|
| 580 |
+
ctx.fillStyle = "#11141B"; ctx.font = "700 20px " + FONT; ctx.fillText(fit(ctx, p.name || "", nameW - 30), M + 18, y + 30);
|
| 581 |
+
ctx.fillStyle = "#5B6170"; ctx.font = "500 15px " + FONT; ctx.fillText(fit(ctx, p.role || "", nameW - 30), M + 18, y + 51);
|
| 582 |
+
d.forEach(function (x, i) {
|
| 583 |
+
var cx = M + nameW + i * dayW, list = week.filter(function (sh) { return sh.staffId === p.id && sh.date === x; });
|
| 584 |
+
if (!list.length) { ctx.fillStyle = "#A3A8B3"; ctx.font = "500 16px " + FONT; ctx.fillText("off", cx + 12, y + 38); return; }
|
| 585 |
+
list.forEach(function (sh, k) {
|
| 586 |
+
var by = y + 7 + k * 52;
|
| 587 |
+
ctx.fillStyle = tint(p.color, 0.13); rr(ctx, cx + 5, by, dayW - 10, 46, 8); ctx.fill();
|
| 588 |
+
ctx.fillStyle = p.color || "#146356"; ctx.fillRect(cx + 5, by + 5, 4, 36);
|
| 589 |
+
ctx.fillStyle = "#11141B"; ctx.font = "800 18px " + FONT; ctx.fillText(fit(ctx, R.fmtRange(sh, fmt()), dayW - 28), cx + 16, by + 21);
|
| 590 |
+
var sub = [sh.station, sh.note].filter(Boolean).join(" · ");
|
| 591 |
+
if (sub) { ctx.fillStyle = "#4B5262"; ctx.font = "500 14px " + FONT; ctx.fillText(fit(ctx, sub, dayW - 28), cx + 16, by + 39); }
|
| 592 |
+
});
|
| 593 |
+
});
|
| 594 |
+
ctx.textAlign = "right"; ctx.fillStyle = "#11141B"; ctx.font = "800 20px " + FONT; ctx.fillText(R.hrs(t.byPerson[p.id].minutes) + " h", W - M - 12, y + 38); ctx.textAlign = "left";
|
| 595 |
+
ctx.strokeStyle = "#E2DED3"; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(M, y + rh); ctx.lineTo(W - M, y + rh); ctx.stroke();
|
| 596 |
+
y += rh;
|
| 597 |
+
});
|
| 598 |
+
function footRow(label, vals, total) {
|
| 599 |
+
ctx.fillStyle = "#F1EEE6"; ctx.fillRect(M, y, W - 2 * M, 44);
|
| 600 |
+
ctx.fillStyle = "#11141B"; ctx.font = "700 17px " + FONT; ctx.fillText(label, M + 14, y + 28);
|
| 601 |
+
ctx.font = "600 17px " + FONT; vals.forEach(function (v, i) { ctx.fillText(v, M + nameW + i * dayW + 12, y + 28); });
|
| 602 |
+
ctx.textAlign = "right"; ctx.font = "800 17px " + FONT; ctx.fillText(total, W - M - 12, y + 28); ctx.textAlign = "left";
|
| 603 |
+
y += 44;
|
| 604 |
+
}
|
| 605 |
+
footRow("Hours", t.byDay.map(function (x) { return R.hrs(x.minutes) + " h"; }), R.hrs(t.total.minutes) + " h");
|
| 606 |
+
if (showCost) footRow("Labour cost", t.byDay.map(function (x) { return money(x.cost); }), money(t.total.cost));
|
| 607 |
+
ctx.fillStyle = "#6B7180"; ctx.font = "500 15px " + FONT;
|
| 608 |
+
ctx.fillText("Hours are after unpaid breaks.", M, H - 26);
|
| 609 |
+
if (!pro()) { ctx.textAlign = "right"; ctx.fillText(CREDIT + " · " + HUB, W - M, H - 26); ctx.textAlign = "left"; }
|
| 610 |
+
return cv;
|
| 611 |
+
}
|
| 612 |
+
function personCanvas(p) {
|
| 613 |
+
var s = sch(), d = dates(), week = R.sortShifts(R.weekShifts(s.shifts, S.week)).filter(function (sh) { return sh.staffId === p.id; });
|
| 614 |
+
var W = 1080, M = 64, rowH = 104, H = 300 + 7 * rowH + 150, sc = 1;
|
| 615 |
+
var cv = document.createElement("canvas"); cv.width = W * sc; cv.height = H * sc;
|
| 616 |
+
var ctx = cv.getContext("2d");
|
| 617 |
+
ctx.fillStyle = "#FFFFFF"; ctx.fillRect(0, 0, W, H);
|
| 618 |
+
ctx.fillStyle = p.color || "#146356"; ctx.fillRect(0, 0, W, 18);
|
| 619 |
+
ctx.fillStyle = "#11141B"; ctx.font = "800 58px " + FONT; ctx.fillText(fit(ctx, p.name || "", W - 2 * M), M, 118);
|
| 620 |
+
ctx.fillStyle = "#4B5262"; ctx.font = "500 30px " + FONT; ctx.fillText(fit(ctx, [p.role, s.name].filter(Boolean).join(" · "), W - 2 * M), M, 168);
|
| 621 |
+
ctx.font = "700 30px " + FONT; ctx.fillStyle = "#146356"; ctx.fillText("Week of " + R.fmtLong(S.week), M, 226);
|
| 622 |
+
var y = 270, mins = 0;
|
| 623 |
+
d.forEach(function (x, i) {
|
| 624 |
+
if (i % 2 === 0) { ctx.fillStyle = "#FAF8F3"; ctx.fillRect(M - 20, y, W - 2 * M + 40, rowH); }
|
| 625 |
+
ctx.fillStyle = "#11141B"; ctx.font = "800 34px " + FONT; ctx.fillText(R.fmtDay(x), M, y + 50);
|
| 626 |
+
ctx.fillStyle = "#5B6170"; ctx.font = "500 24px " + FONT; ctx.fillText(R.fmtDate(x).slice(4), M, y + 82);
|
| 627 |
+
var list = week.filter(function (sh) { return sh.date === x; });
|
| 628 |
+
if (!list.length) { ctx.fillStyle = "#A3A8B3"; ctx.font = "500 32px " + FONT; ctx.fillText("Off", M + 200, y + 64); }
|
| 629 |
+
else {
|
| 630 |
+
list.forEach(function (sh) { mins += R.paidMinutes(sh); });
|
| 631 |
+
ctx.fillStyle = "#11141B"; ctx.font = "800 38px " + FONT;
|
| 632 |
+
ctx.fillText(fit(ctx, list.map(function (sh) { return R.fmtRange(sh, fmt()); }).join(" + "), W - 2 * M - 200), M + 200, y + 50);
|
| 633 |
+
var sub = list.map(function (sh) { return [sh.station, sh.brk ? sh.brk + " min break" : "", sh.note].filter(Boolean).join(", "); }).filter(Boolean).join(" / ");
|
| 634 |
+
if (sub) { ctx.fillStyle = "#4B5262"; ctx.font = "500 25px " + FONT; ctx.fillText(fit(ctx, sub, W - 2 * M - 200), M + 200, y + 84); }
|
| 635 |
+
}
|
| 636 |
+
y += rowH;
|
| 637 |
+
});
|
| 638 |
+
ctx.fillStyle = "#11141B"; ctx.font = "800 40px " + FONT; ctx.fillText("Total " + R.hrs(mins) + " h", M, y + 70);
|
| 639 |
+
return cv;
|
| 640 |
+
}
|
| 641 |
+
$("btn-png").addEventListener("click", function () {
|
| 642 |
+
if (!sch().staff.length) return toast("Add your team first.");
|
| 643 |
+
weekCanvas().toBlob(function (b) { X.download("rotasprig-" + slugify(sch().name) + "-" + S.week + ".png", b, "image/png"); toast("PNG downloaded. Post it in the staff chat."); }, "image/png");
|
| 644 |
+
});
|
| 645 |
+
|
| 646 |
+
/* ---------- backup ---------- */
|
| 647 |
+
$("btn-backup").addEventListener("click", function () {
|
| 648 |
+
if (!pro()) return upsell("JSON backup is part of Rotasprig Pro.", "backup");
|
| 649 |
+
X.download("rotasprig-backup-" + R.todayISO() + ".json", JSON.stringify({ app: "rotasprig", v: 1, exported: new Date().toISOString(), data: S }, null, 1), "application/json");
|
| 650 |
+
});
|
| 651 |
+
$("lbl-restore").addEventListener("click", function (e) { if (!pro()) { e.preventDefault(); upsell("Restoring a backup is part of Rotasprig Pro.", "backup"); } });
|
| 652 |
+
$("f-restore").addEventListener("change", function () {
|
| 653 |
+
var f = this.files && this.files[0]; this.value = "";
|
| 654 |
+
if (!f || !pro()) return;
|
| 655 |
+
f.text().then(function (txt) {
|
| 656 |
+
var j = JSON.parse(txt), d = j && j.app === "rotasprig" ? j.data : null;
|
| 657 |
+
if (!d || !Array.isArray(d.schedules) || !d.schedules.length) throw new Error("bad");
|
| 658 |
+
var fs = freshSettings(); d.settings = d.settings || {}; Object.keys(fs).forEach(function (k) { if (d.settings[k] == null) d.settings[k] = fs[k]; });
|
| 659 |
+
if (!R.isISO(d.week)) d.week = nextWeek(d.settings.wstart);
|
| 660 |
+
S = d; brush = null; save(); settingsToForm(); renderAll();
|
| 661 |
+
toast("Backup restored: " + S.schedules.length + " location(s).");
|
| 662 |
+
}).catch(function () { toast("That file is not a Rotasprig backup."); });
|
| 663 |
+
});
|
| 664 |
+
$("btn-clear").addEventListener("click", function () {
|
| 665 |
+
if (!window.confirm("Start an empty schedule? This clears the staff and shifts saved in this browser.")) return;
|
| 666 |
+
S = { v: 1, settings: S.settings, schedules: [emptySchedule("My business")], cur: null, week: nextWeek(ws()), dirty: true };
|
| 667 |
+
S.cur = S.schedules[0].id; brush = null; save(); renderAll(); showTab("team");
|
| 668 |
+
});
|
| 669 |
+
$("btn-example").addEventListener("click", function () {
|
| 670 |
+
if (S.dirty && !window.confirm("Replace your schedule with the example? (Your current staff and shifts in this location are replaced.)")) return;
|
| 671 |
+
loadExample($("example-kind").value); settingsToForm(); showTab("week"); renderAll();
|
| 672 |
+
var s = sch(); toast("Example loaded: " + s.staff.length + " staff, " + R.weekShifts(s.shifts, S.week).length + " shifts.");
|
| 673 |
+
});
|
| 674 |
+
|
| 675 |
+
/* ---------- Pro chrome + render ---------- */
|
| 676 |
+
$("btn-cta").addEventListener("click", function () { upsell("", "mid-cta"); });
|
| 677 |
+
function renderMain() { renderBar(); renderBrushes(); renderGrid(); renderCoverage(); renderShare(); renderLabour(); renderPrintable(); }
|
| 678 |
+
function renderAll() { renderMain(); renderTeam(); }
|
| 679 |
+
X.onChange(function (on) {
|
| 680 |
+
$("pro-pill").textContent = on ? "Pro ✓" : "Pro";
|
| 681 |
+
$("pro-pill").title = on ? "Rotasprig Pro is on" : "See Pro plans";
|
| 682 |
+
$("pro-cta").hidden = on;
|
| 683 |
+
if (S) renderAll();
|
| 684 |
+
});
|
| 685 |
+
|
| 686 |
+
/* ---------- install + offline ---------- */
|
| 687 |
+
var deferred = null;
|
| 688 |
+
window.addEventListener("beforeinstallprompt", function (e) { e.preventDefault(); deferred = e; $("btn-install").hidden = false; });
|
| 689 |
+
$("btn-install").addEventListener("click", function () {
|
| 690 |
+
if (!deferred) return;
|
| 691 |
+
deferred.prompt(); deferred.userChoice.finally(function () { deferred = null; $("btn-install").hidden = true; });
|
| 692 |
+
});
|
| 693 |
+
window.addEventListener("appinstalled", function () { $("btn-install").hidden = true; });
|
| 694 |
+
if ("serviceWorker" in navigator && (location.protocol === "https:" || /^(localhost|127\.0\.0\.1)$/.test(location.hostname))) {
|
| 695 |
+
window.addEventListener("load", function () { navigator.serviceWorker.register("sw.js").catch(function () { /* offline cache is optional */ }); });
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
settingsToForm();
|
| 699 |
+
renderAll();
|
| 700 |
+
})();
|
rotasprig/icon-192.png
ADDED
|
|
rotasprig/icon-512.png
ADDED
|
|
rotasprig/icon.svg
ADDED
|
|
rotasprig/index.html
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 6 |
+
<title>Employee Schedule Maker: Free Shift Schedule | Rotasprig</title>
|
| 7 |
+
<meta name="description" content="Free employee schedule maker for restaurants, cafes, shops and salons: build the weekly shift schedule, see hours and labour cost, print or post it. Nothing uploaded.">
|
| 8 |
+
<meta name="keywords" content="employee schedule maker, shift schedule template, free work schedule maker, staff rota, restaurant staff schedule template, salon staff rota, weekly work schedule, labour cost calculator">
|
| 9 |
+
<meta name="theme-color" content="#146356">
|
| 10 |
+
<link rel="canonical" href="https://cybermax-tools-cybermax.static.hf.space/rotasprig/index.html">
|
| 11 |
+
<link rel="manifest" href="manifest.webmanifest">
|
| 12 |
+
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
| 13 |
+
<link rel="apple-touch-icon" href="icon-192.png">
|
| 14 |
+
<meta property="og:type" content="website">
|
| 15 |
+
<meta property="og:site_name" content="CyberMax">
|
| 16 |
+
<meta property="og:title" content="Rotasprig: free employee schedule maker">
|
| 17 |
+
<meta property="og:description" content="Build next week's shift schedule in minutes: hours after breaks, labour cost, rest and overtime warnings, then print it or post a PNG in the staff chat. Free, nothing uploaded.">
|
| 18 |
+
<meta property="og:url" content="https://cybermax-tools-cybermax.static.hf.space/rotasprig/index.html">
|
| 19 |
+
<meta property="og:image" content="https://cybermax-tools-cybermax.static.hf.space/rotasprig/og.png">
|
| 20 |
+
<meta name="twitter:card" content="summary_large_image">
|
| 21 |
+
<script type="application/ld+json">
|
| 22 |
+
{"@context":"https://schema.org","@graph":[
|
| 23 |
+
{"@type":"WebApplication","name":"Rotasprig","alternateName":"Rotasprig employee schedule maker","url":"https://cybermax-tools-cybermax.static.hf.space/rotasprig/index.html","image":"https://cybermax-tools-cybermax.static.hf.space/rotasprig/og.png","applicationCategory":"BusinessApplication","operatingSystem":"Any (web browser)","browserRequirements":"Requires JavaScript","description":"Employee schedule maker and shift schedule template for restaurants, cafes, retail shops and salons: staff list with roles, rates, maximum hours and availability, weekly shift grid with tap-to-add shift templates, drag and copy, hours after breaks, labour cost per day and week, rest-between-shifts, overlap, maximum hours and availability warnings, hourly coverage view, printable schedule, PNG for the staff group chat and per-person schedule text. Works offline, nothing uploaded.","offers":[{"@type":"Offer","name":"Free","price":"0","priceCurrency":"USD","description":"Up to 8 staff and 1 saved week, hours, labour cost totals, warnings, coverage, print and PNG (with a small footer line), per-person text"},{"@type":"Offer","name":"Rotasprig Pro Monthly","price":"6","priceCurrency":"USD","description":"Unlimited staff, several locations, saved weeks history, labour cost and overtime report, CSV export for payroll, no footer, per-person PNGs, JSON backup; cancel any time"},{"@type":"Offer","name":"Rotasprig Pro Lifetime","price":"49","priceCurrency":"USD","description":"Every Pro feature, pay once"}],"publisher":{"@type":"Organization","name":"CyberMax","email":"cybermax.tools@gmail.com"}},
|
| 24 |
+
{"@type":"FAQPage","mainEntity":[
|
| 25 |
+
{"@type":"Question","name":"Is Rotasprig really free?","acceptedAnswer":{"@type":"Answer","text":"Yes. The free plan schedules up to 8 staff for one saved week at a time, with hours, labour cost totals, warnings, the coverage view, print, PNG and per-person text. There is no account and no per-user fee."}},
|
| 26 |
+
{"@type":"Question","name":"Why not Homebase, When I Work or Sling?","acceptedAnswer":{"@type":"Answer","text":"They are full workforce platforms with staff apps, shift swaps, time clocks and notifications. Homebase Basic is free for up to 10 employees with paid plans from $30 per location a month, When I Work starts at $2.50 per user a month and Sling Premium is $2 per user a month (prices checked 2 Oct 2026). If you want to build, print and post the schedule fast, with labour cost and no per-user fees, Rotasprig is free for up to 8 staff and Pro is $49 once."}},
|
| 27 |
+
{"@type":"Question","name":"Is my data private?","acceptedAnswer":{"@type":"Answer","text":"Yes. Rotasprig runs entirely in your browser. Staff names, rates and shifts are saved only on this device. Nothing is uploaded."}},
|
| 28 |
+
{"@type":"Question","name":"What does Pro add?","acceptedAnswer":{"@type":"Answer","text":"Unlimited staff, several locations or schedules, every past week saved, the labour cost and overtime report, CSV export for payroll, prints and PNGs without the footer line, a PNG for each person and a JSON backup."}},
|
| 29 |
+
{"@type":"Question","name":"Can I cancel?","acceptedAnswer":{"@type":"Answer","text":"Yes. The $6 monthly plan cancels any time from the link in your Stripe receipt email. The $49 Lifetime plan is one payment with nothing to cancel."}},
|
| 30 |
+
{"@type":"Question","name":"How are hours and labour cost worked out?","acceptedAnswer":{"@type":"Answer","text":"Paid hours are each shift's length less its unpaid break. Labour cost is paid hours times the hourly rate you enter. The overtime report (Pro) adds a premium above a weekly threshold you set, 40 hours at 1.5x by default."}}]}
|
| 31 |
+
]}
|
| 32 |
+
</script>
|
| 33 |
+
<link rel="stylesheet" href="style.css">
|
| 34 |
+
</head>
|
| 35 |
+
<body>
|
| 36 |
+
<header class="top"><div class="wrap top-in">
|
| 37 |
+
<a class="brand" href="./" aria-label="Rotasprig home"><img src="icon.svg" alt="" width="30" height="30"><span><b>Rotasprig</b> <small>by CyberMax</small></span></a>
|
| 38 |
+
<nav class="top-nav">
|
| 39 |
+
<button class="btn ghost sm" id="btn-install" type="button" hidden>Install app</button>
|
| 40 |
+
<a href="#cmx-pro" class="top-link">Pricing</a>
|
| 41 |
+
<a href="#cmx-pro" class="pill" id="pro-pill">Pro</a>
|
| 42 |
+
</nav>
|
| 43 |
+
</div></header>
|
| 44 |
+
|
| 45 |
+
<main>
|
| 46 |
+
<div class="wrap">
|
| 47 |
+
<section class="hero">
|
| 48 |
+
<h1>Employee schedule maker: next week's rota in minutes</h1>
|
| 49 |
+
<p class="lede">For restaurants, cafes, retail shops and salons. Tap shifts onto the week, see everyone's hours and your labour cost, catch short rest and overtime before they happen, then print it or post it in the staff chat. <b>Free, no sign-up, nothing uploaded.</b></p>
|
| 50 |
+
<div class="hero-row">
|
| 51 |
+
<button class="btn" id="btn-example" type="button">Load example</button>
|
| 52 |
+
<label class="sel-inline" for="example-kind"><span class="sr">Example</span>
|
| 53 |
+
<select id="example-kind">
|
| 54 |
+
<option value="cafe">Cafe: open, mid and close shifts</option>
|
| 55 |
+
<option value="restaurant">Restaurant: FOH + BOH, split shifts</option>
|
| 56 |
+
<option value="salon">Salon: chairs, late nights</option>
|
| 57 |
+
</select></label>
|
| 58 |
+
<span class="hero-note">Up to 8 staff free · works offline</span>
|
| 59 |
+
</div>
|
| 60 |
+
</section>
|
| 61 |
+
</div>
|
| 62 |
+
|
| 63 |
+
<section id="app" class="app wrap" aria-label="Employee schedule maker">
|
| 64 |
+
<div class="card bar-card">
|
| 65 |
+
<div class="week-bar">
|
| 66 |
+
<div class="loc">
|
| 67 |
+
<label for="loc-name">Business or location</label>
|
| 68 |
+
<div class="combo"><input id="loc-name" autocomplete="off"><select id="loc-select" aria-label="Switch location" hidden></select><button type="button" class="btn ghost sm" id="btn-add-loc" title="Add another location">+ Location <span class="pro-tag">PRO</span></button></div>
|
| 69 |
+
</div>
|
| 70 |
+
<div class="weeknav" role="group" aria-label="Week">
|
| 71 |
+
<button type="button" class="icon-btn" id="btn-prev" aria-label="Previous week">‹</button>
|
| 72 |
+
<div class="wk"><b id="wk-label"></b><small id="wk-sub"></small></div>
|
| 73 |
+
<button type="button" class="icon-btn" id="btn-next" aria-label="Next week">›</button>
|
| 74 |
+
<label class="sr" for="wk-date">Jump to week</label><input type="date" id="wk-date" class="wk-date">
|
| 75 |
+
</div>
|
| 76 |
+
<div class="wk-acts">
|
| 77 |
+
<button type="button" class="btn ghost sm" id="btn-copy-next">Copy to next week →</button>
|
| 78 |
+
<button type="button" class="btn ghost sm" id="btn-copy-last" hidden>Copy last week</button>
|
| 79 |
+
<label class="sr" for="hist">Saved weeks</label><select id="hist" class="hist" hidden></select>
|
| 80 |
+
<button type="button" class="btn ghost sm" id="btn-hist-lock">Saved weeks <span class="pro-tag">PRO</span></button>
|
| 81 |
+
</div>
|
| 82 |
+
</div>
|
| 83 |
+
<p class="limit-line"><span class="limit" id="staff-limit" aria-live="polite"></span> <span class="limit" id="week-limit"></span></p>
|
| 84 |
+
</div>
|
| 85 |
+
|
| 86 |
+
<div class="tabs" role="tablist" aria-label="Sections">
|
| 87 |
+
<button type="button" role="tab" id="tab-week" aria-controls="p-week" aria-selected="true">Schedule</button>
|
| 88 |
+
<button type="button" role="tab" id="tab-team" aria-controls="p-team" aria-selected="false">Staff & shifts</button>
|
| 89 |
+
<button type="button" role="tab" id="tab-cover" aria-controls="p-cover" aria-selected="false">Coverage</button>
|
| 90 |
+
<button type="button" role="tab" id="tab-share" aria-controls="p-share" aria-selected="false">Send to staff</button>
|
| 91 |
+
<button type="button" role="tab" id="tab-labour" aria-controls="p-labour" aria-selected="false">Labour report <span class="pro-tag">PRO</span></button>
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
<!-- SCHEDULE -->
|
| 95 |
+
<div role="tabpanel" id="p-week" aria-labelledby="tab-week">
|
| 96 |
+
<div class="card">
|
| 97 |
+
<div class="brush-row" role="radiogroup" aria-label="Tap a day to add">
|
| 98 |
+
<span class="brush-lbl">Tap a day to add:</span>
|
| 99 |
+
<span id="brushes" class="brushes"></span>
|
| 100 |
+
</div>
|
| 101 |
+
<p class="hint grid-hint">Tap <b>+</b> to add the selected shift, tap a shift to edit it. <span class="kbd-hint">Drag a shift to move it (hold Ctrl or Alt to copy). Keyboard: Ctrl+C on a shift, Ctrl+V on a <b>+</b>.</span> To copy on a phone, open a shift and tap Copy.</p>
|
| 102 |
+
<div class="table-wrap grid-wrap"><table class="grid" id="grid"></table></div>
|
| 103 |
+
<ul class="warns" id="warns" aria-live="polite"></ul>
|
| 104 |
+
<div class="kpis" id="kpis"></div>
|
| 105 |
+
<div class="act-row">
|
| 106 |
+
<button type="button" class="btn" id="btn-print">Print schedule</button>
|
| 107 |
+
<button type="button" class="btn ghost" id="btn-png">Download PNG for the staff chat</button>
|
| 108 |
+
<button type="button" class="btn ghost" id="btn-goto-share">Copy each person's shifts</button>
|
| 109 |
+
</div>
|
| 110 |
+
<p class="hint xlink">Week done? <a href="https://cybermax-tools-cybermax.static.hf.space/hoursprig/index.html" target="_blank" rel="noopener">Turn the schedule into hours worked with Hoursprig timesheets</a>.</p>
|
| 111 |
+
</div>
|
| 112 |
+
</div>
|
| 113 |
+
|
| 114 |
+
<!-- TEAM -->
|
| 115 |
+
<div role="tabpanel" id="p-team" aria-labelledby="tab-team" hidden>
|
| 116 |
+
<div class="card">
|
| 117 |
+
<div class="hist-head"><h2>Staff</h2><span class="limit" id="staff-limit2"></span></div>
|
| 118 |
+
<p class="hint">Hourly rate is optional and only used for labour cost. Untick the days someone cannot work and Rotasprig warns you if you schedule them.</p>
|
| 119 |
+
<div id="staff-list"></div>
|
| 120 |
+
<div class="btns"><button type="button" class="btn sm" id="btn-add-staff">+ Add person</button></div>
|
| 121 |
+
</div>
|
| 122 |
+
<div class="card">
|
| 123 |
+
<h2>Shift templates</h2>
|
| 124 |
+
<p class="hint">Your usual shifts, shown as buttons above the schedule. Tap one, then tap a day to add it.</p>
|
| 125 |
+
<div id="tpl-list"></div>
|
| 126 |
+
<div class="btns"><button type="button" class="btn ghost sm" id="btn-add-tpl">+ Add template</button></div>
|
| 127 |
+
</div>
|
| 128 |
+
<div class="card">
|
| 129 |
+
<h2>Settings</h2>
|
| 130 |
+
<div class="set-grid">
|
| 131 |
+
<div><label for="s-rest">Minimum rest between shifts (hours)</label><input id="s-rest" inputmode="decimal" aria-describedby="s-rest-help"><small class="hint" id="s-rest-help">Default 10 h, an editable assumption: check the rule where you work (often 8 to 11 h)</small></div>
|
| 132 |
+
<div><label for="s-currency">Currency</label><select id="s-currency"></select></div>
|
| 133 |
+
<div><label for="s-time">Time format</label><select id="s-time"><option value="24">7:00-15:00</option><option value="12">7am-3pm</option></select></div>
|
| 134 |
+
<div><label for="s-wstart">Week starts on</label><select id="s-wstart"><option value="1">Monday</option><option value="0">Sunday</option></select></div>
|
| 135 |
+
<div><label for="s-paper">Paper</label><select id="s-paper"><option value="letter">Letter, landscape</option><option value="A4">A4, landscape</option></select></div>
|
| 136 |
+
<div><label class="check"><input type="checkbox" id="s-printcost"> Show labour cost on print and PNG</label><small class="hint">Off by default, so rates stay private on the posted copy</small></div>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
</div>
|
| 140 |
+
|
| 141 |
+
<!-- COVERAGE -->
|
| 142 |
+
<div role="tabpanel" id="p-cover" aria-labelledby="tab-cover" hidden>
|
| 143 |
+
<div class="card">
|
| 144 |
+
<div class="hist-head"><h2>Coverage by hour</h2><label class="inline-sel"><span>Show</span> <select id="cov-filter"></select></label></div>
|
| 145 |
+
<p class="hint">How many people are on at each hour of the week (someone counts for an hour when they work at least 30 minutes of it; breaks are not taken out).</p>
|
| 146 |
+
<p class="cov-sum" id="cov-sum"></p>
|
| 147 |
+
<div class="table-wrap"><table class="cov" id="cov-table"></table></div>
|
| 148 |
+
</div>
|
| 149 |
+
</div>
|
| 150 |
+
|
| 151 |
+
<!-- SHARE -->
|
| 152 |
+
<div role="tabpanel" id="p-share" aria-labelledby="tab-share" hidden>
|
| 153 |
+
<div class="card">
|
| 154 |
+
<div class="hist-head"><h2>Each person's shifts</h2><div class="btns"><button type="button" class="btn sm" id="btn-copy-all">Copy everyone</button></div></div>
|
| 155 |
+
<p class="hint">Copy a message for each person to paste into a text or chat. Pro adds a PNG for each person.</p>
|
| 156 |
+
<div class="people" id="people"></div>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
|
| 160 |
+
<!-- LABOUR -->
|
| 161 |
+
<div role="tabpanel" id="p-labour" aria-labelledby="tab-labour" hidden>
|
| 162 |
+
<div class="card">
|
| 163 |
+
<h2>Labour cost and overtime <span class="pro-tag">PRO</span></h2>
|
| 164 |
+
<p class="hint">Hours, regular and overtime hours, and cost per person and per day, ready for payroll.</p>
|
| 165 |
+
<div class="locked" id="labour-lock"><p>The labour cost and overtime report and CSV export for payroll are part of Rotasprig Pro. Free schedules already show hours and labour cost per day and week.</p><button type="button" class="btn" data-upsell="labour">Unlock with Pro</button></div>
|
| 166 |
+
<div id="labour-tool">
|
| 167 |
+
<div class="set-grid">
|
| 168 |
+
<div><label for="s-otafter">Overtime after (hours per week)</label><input id="s-otafter" inputmode="decimal"><small class="hint">Default 40, an editable assumption; daily overtime rules are not applied</small></div>
|
| 169 |
+
<div><label for="s-otmult">Overtime rate (x base)</label><input id="s-otmult" inputmode="decimal"><small class="hint">Default 1.5, an editable assumption</small></div>
|
| 170 |
+
</div>
|
| 171 |
+
<div class="table-wrap"><table class="ht" id="lab-table"></table></div>
|
| 172 |
+
<div class="table-wrap"><table class="ht" id="lab-days"></table></div>
|
| 173 |
+
</div>
|
| 174 |
+
<div class="btns">
|
| 175 |
+
<button type="button" class="btn ghost sm" id="btn-csv-shifts">Shifts CSV for payroll <span class="pro-tag">PRO</span></button>
|
| 176 |
+
<button type="button" class="btn ghost sm" id="btn-csv-hours">Hours by person CSV <span class="pro-tag">PRO</span></button>
|
| 177 |
+
</div>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
+
|
| 181 |
+
<div class="card data-card">
|
| 182 |
+
<div class="hist-head"><h2>Your data</h2><div class="btns"><button type="button" class="btn ghost sm" id="btn-backup">Download backup (JSON) <span class="pro-tag">PRO</span></button><label class="btn ghost sm file-btn" for="f-restore" id="lbl-restore">Restore backup <span class="pro-tag">PRO</span></label><input type="file" id="f-restore" accept="application/json,.json" hidden><button type="button" class="btn ghost sm danger" id="btn-clear">Start empty</button></div></div>
|
| 183 |
+
<p class="hint">Everything is saved in this browser only. Nothing is uploaded.</p>
|
| 184 |
+
</div>
|
| 185 |
+
</section>
|
| 186 |
+
|
| 187 |
+
<div class="wrap">
|
| 188 |
+
<section class="pro-cta card" id="pro-cta" hidden>
|
| 189 |
+
<div>
|
| 190 |
+
<h2>Scheduling a bigger team or a second site?</h2>
|
| 191 |
+
<p>Rotasprig Pro: unlimited staff, several locations, every past week saved, the labour cost and overtime report, CSV export for payroll, a PNG for each person and no footer line. <b>$6/month</b> or <b>$49 once</b>, with no per-user fees.</p>
|
| 192 |
+
</div>
|
| 193 |
+
<button type="button" class="btn" id="btn-cta">See Pro plans</button>
|
| 194 |
+
</section>
|
| 195 |
+
|
| 196 |
+
<section class="how" id="how">
|
| 197 |
+
<h2>How it works</h2>
|
| 198 |
+
<ol class="steps">
|
| 199 |
+
<li><b>Add your team.</b> Names, roles, a colour each, and if you like an hourly rate, a weekly maximum and the days they cannot work.</li>
|
| 200 |
+
<li><b>Tap in the week.</b> Pick a shift template (Open, Mid, Close or your own) and tap each day. Drag to move, copy last week, fix anything flagged: short rest, overlaps, over max hours, unavailable days.</li>
|
| 201 |
+
<li><b>Post it.</b> Print a clean landscape schedule for the back office, download a PNG for the staff group chat, or copy each person's shifts as a text.</li>
|
| 202 |
+
</ol>
|
| 203 |
+
</section>
|
| 204 |
+
|
| 205 |
+
<section class="compare" id="compare">
|
| 206 |
+
<h2>Rotasprig vs other employee scheduling apps</h2>
|
| 207 |
+
<div class="table-wrap">
|
| 208 |
+
<table class="cmp">
|
| 209 |
+
<thead><tr><th scope="col">Tool</th><th scope="col">Price</th><th scope="col">Good to know</th></tr></thead>
|
| 210 |
+
<tbody>
|
| 211 |
+
<tr class="us"><th scope="row">Rotasprig Free</th><td>$0</td><td>Up to 8 staff, 1 saved week, hours after breaks, labour cost per day and week, rest/overlap/max hours/availability warnings, coverage by hour, print and PNG; no account, works offline, nothing uploaded</td></tr>
|
| 212 |
+
<tr class="us"><th scope="row">Rotasprig Pro</th><td>$6/month or <b>$49 once</b>, any team size</td><td>Unlimited staff, several locations, saved weeks, labour cost and overtime report, CSV for payroll, no footer, per-person PNGs, JSON backup</td></tr>
|
| 213 |
+
<tr><th scope="row"><a href="https://joinhomebase.com/pricing" target="_blank" rel="noopener nofollow">Homebase</a></th><td>Basic free (up to 10 employees); Essentials $30, Plus $70, All-in-One $120 per location a month</td><td>Full platform: staff app, time clock, shift trades, messaging; staff sign up to the app</td></tr>
|
| 214 |
+
<tr><th scope="row"><a href="https://www.capterra.com/p/121248/When-I-Work/" target="_blank" rel="noopener nofollow">When I Work</a></th><td>From $2.50 per user a month</td><td>Popular scheduling and time clock app with 1,300+ Capterra reviews; cost grows with every person</td></tr>
|
| 215 |
+
<tr><th scope="row"><a href="https://www.cloudwards.net/sling-schedule-review/" target="_blank" rel="noopener nofollow">Sling</a></th><td>Free up to 30 users; Premium $2, Business $4 per user a month</td><td>Scheduling app with messaging and shift swaps; labour cost tools sit on paid plans</td></tr>
|
| 216 |
+
</tbody>
|
| 217 |
+
</table>
|
| 218 |
+
</div>
|
| 219 |
+
<p class="hint">Rival prices checked 2 Oct 2026 from the linked pages (Homebase from its pricing page, When I Work from Capterra, Sling from a search summary of a Cloudwards review). Prices can change; check their sites. They offer staff apps, shift swaps, time clocks and notifications that Rotasprig does not; Rotasprig is the fast, private, printable schedule with labour cost and no per-user fees.</p>
|
| 220 |
+
</section>
|
| 221 |
+
|
| 222 |
+
<section class="faq" id="faq">
|
| 223 |
+
<h2>Questions</h2>
|
| 224 |
+
<details><summary>Is Rotasprig really free?</summary><p>Yes. The free plan schedules up to 8 staff for one saved week at a time, with hours, labour cost totals, warnings, the coverage view, print, PNG and per-person text. Prints and PNGs carry a small "Schedule made with Rotasprig" line. No account, no per-user fee.</p></details>
|
| 225 |
+
<details><summary>Why not Homebase, When I Work or Sling?</summary><p>They are full workforce platforms: staff apps, shift swaps, time clocks and notifications. Homebase Basic is free for up to 10 employees and its paid plans start at $30 per location a month; When I Work starts at $2.50 per user a month; Sling is free up to 30 users and Premium is $2 per user a month (checked 2 Oct 2026). If your team reads the schedule on the wall or in the group chat, Rotasprig builds it faster, shows labour cost as you go and costs $49 once for any team size.</p></details>
|
| 226 |
+
<details><summary>How are hours and labour cost worked out?</summary><p>Paid hours are each shift's length less its unpaid break, so 7:00-15:00 with a 30-minute break is 7.5 hours. Labour cost is paid hours times the hourly rate you enter; people without a rate are left out of the cost. The Pro report adds weekly overtime above a threshold you set (40 hours at 1.5x by default).</p></details>
|
| 227 |
+
<details><summary>What do the warnings check?</summary><p>Overlapping shifts, less rest than your minimum between shifts on different days (10 hours by default, set your own; split shifts on the same day are fine), more hours than someone's weekly maximum, and shifts on days someone marked as unavailable. They are reminders, not legal advice.</p></details>
|
| 228 |
+
<details><summary>Is my data private?</summary><p>Yes. Rotasprig runs entirely in your browser. Staff names, pay rates and shifts are saved only on this device. Nothing is uploaded. Pro adds a JSON backup to move your schedules to another device.</p></details>
|
| 229 |
+
<details><summary>What does Pro add?</summary><p>Unlimited staff, several locations or schedules, every past week saved, the labour cost and overtime report, CSV export for payroll, prints and PNGs without the footer line, a PNG for each person and a JSON backup.</p></details>
|
| 230 |
+
<details><summary>Can I cancel?</summary><p>Yes. The $6 monthly plan cancels any time from the link in your Stripe receipt email, and Pro then switches off by itself; your schedule stays. The $49 Lifetime plan is one payment with nothing to cancel.</p></details>
|
| 231 |
+
<details><summary>Does it handle overnight and split shifts?</summary><p>Yes. An end time earlier than the start (22:00-6:00) runs past midnight and counts on the coverage view the next morning. Add two shifts on one day for a split shift, such as lunch 11:00-15:00 and dinner 17:00-22:00.</p></details>
|
| 232 |
+
<details><summary>Does it work on my phone and offline?</summary><p>Yes. Tap to add shifts on a phone, and once the page has loaded you can install it and use it with no connection.</p></details>
|
| 233 |
+
</section>
|
| 234 |
+
|
| 235 |
+
<p class="disclaimer">Rotasprig is a scheduling tool, not payroll or legal advice. Rest, break and overtime rules differ by country, state and contract; the thresholds here are your own assumptions.</p>
|
| 236 |
+
</div>
|
| 237 |
+
</main>
|
| 238 |
+
|
| 239 |
+
<div class="wrap">
|
| 240 |
+
<footer class="more">
|
| 241 |
+
<div class="more-title">More free tools for business from CyberMax</div>
|
| 242 |
+
<div class="more-links">
|
| 243 |
+
<a href="https://cybermax-tools-cybermax.static.hf.space/hoursprig/index.html" target="_blank" rel="noopener">Hoursprig · timesheets from your schedule</a>
|
| 244 |
+
<a href="https://cybermax-tools-cybermax.static.hf.space/menumoor/index.html" target="_blank" rel="noopener">Menumoor · printed menus & price lists</a>
|
| 245 |
+
<a href="https://cybermax-tools-cybermax.static.hf.space/platesprig/index.html" target="_blank" rel="noopener">Platesprig · food cost calculator</a>
|
| 246 |
+
<a href="https://cybermax-tools-cybermax.static.hf.space/billsprig/index.html" target="_blank" rel="noopener">Billsprig · invoices & receipts</a>
|
| 247 |
+
<a href="https://cybermax-tools-cybermax.static.hf.space/tagwren/index.html" target="_blank" rel="noopener">Tagwren · price tags & labels</a>
|
| 248 |
+
<a href="https://cybermax-tools-cybermax.static.hf.space/sigsprig/index.html" target="_blank" rel="noopener">Sigsprig · email signatures</a>
|
| 249 |
+
<a href="https://cybermax.cybermax-tools.workers.dev/store/?utm_source=rotasprig&utm_medium=more-from" target="_blank" rel="noopener">CyberMax Store</a>
|
| 250 |
+
</div>
|
| 251 |
+
<div class="copy">© 2026 CyberMax. All rights reserved. · Support: <a href="mailto:cybermax.tools@gmail.com">cybermax.tools@gmail.com</a></div>
|
| 252 |
+
</footer>
|
| 253 |
+
</div>
|
| 254 |
+
|
| 255 |
+
<dialog id="dlg" class="dlg" aria-labelledby="dlg-title">
|
| 256 |
+
<form id="dlg-form" method="dialog" autocomplete="off" novalidate>
|
| 257 |
+
<h2 id="dlg-title">Shift</h2>
|
| 258 |
+
<div class="g2">
|
| 259 |
+
<div><label for="d-staff">Person</label><select id="d-staff"></select></div>
|
| 260 |
+
<div><label for="d-date">Day</label><select id="d-date"></select></div>
|
| 261 |
+
<div><label for="d-start">Start</label><input id="d-start" type="time" step="300" required></div>
|
| 262 |
+
<div><label for="d-end">End <span class="opt">earlier = overnight</span></label><input id="d-end" type="time" step="300" required></div>
|
| 263 |
+
<div><label for="d-brk">Unpaid break (min)</label><input id="d-brk" inputmode="numeric"></div>
|
| 264 |
+
<div><label for="d-station">Station / role <span class="opt">optional</span></label><input id="d-station" list="dl-stations"></div>
|
| 265 |
+
<div class="span2"><label for="d-note">Note <span class="opt">optional</span></label><input id="d-note" maxlength="80"></div>
|
| 266 |
+
</div>
|
| 267 |
+
<p class="hint" id="d-calc" aria-live="polite"></p>
|
| 268 |
+
<div class="tpl-quick" id="d-tpls"></div>
|
| 269 |
+
<div class="dlg-acts">
|
| 270 |
+
<button type="submit" class="btn" id="d-save" value="save">Save shift</button>
|
| 271 |
+
<button type="button" class="btn ghost" id="d-copy">Copy</button>
|
| 272 |
+
<button type="button" class="btn ghost danger" id="d-del">Delete</button>
|
| 273 |
+
<button type="button" class="btn ghost" id="d-cancel">Cancel</button>
|
| 274 |
+
</div>
|
| 275 |
+
</form>
|
| 276 |
+
</dialog>
|
| 277 |
+
|
| 278 |
+
<dialog id="dlg-week" class="dlg" aria-labelledby="dw-title">
|
| 279 |
+
<form method="dialog">
|
| 280 |
+
<h2 id="dw-title">Move to another week</h2>
|
| 281 |
+
<p id="dw-text"></p>
|
| 282 |
+
<div class="dlg-acts">
|
| 283 |
+
<button type="button" class="btn" id="dw-copy">Copy shifts into it</button>
|
| 284 |
+
<button type="button" class="btn ghost" id="dw-empty">Start it empty</button>
|
| 285 |
+
<button type="button" class="btn ghost" id="dw-cancel">Cancel</button>
|
| 286 |
+
</div>
|
| 287 |
+
<p class="hint"><button type="button" class="linkbtn" id="dw-pro">Keep every week with Pro</button></p>
|
| 288 |
+
</form>
|
| 289 |
+
</dialog>
|
| 290 |
+
|
| 291 |
+
<div id="print-area" aria-hidden="true"></div>
|
| 292 |
+
<style id="page-style"></style>
|
| 293 |
+
<datalist id="dl-stations"></datalist>
|
| 294 |
+
<div class="toast" id="toast" role="status" aria-live="polite" hidden></div>
|
| 295 |
+
<script>window.CMX_PRO={"id":"rotasprig","name":"Rotasprig","free":"up to 8 staff and 1 saved week, hours and labour cost totals, warnings, coverage, print and PNG (with a small footer line).","perks":["Unlimited staff","Several locations or schedules","Every past week saved (week history)","Labour cost and overtime report","CSV export for payroll","Print and PNG without the footer line","A PNG for each person","JSON backup to move to another device"],"plans":[{"offer":"st-rotasprig-pro-monthly","label":"Monthly","price":"$6","per":"/month","note":"Cancel any time"},{"offer":"st-rotasprig-pro-lifetime","label":"Lifetime","price":"$49","per":" once","note":"Pay once, keep forever","best":true}]};</script>
|
| 296 |
+
<script src="pro.js"></script>
|
| 297 |
+
<script src="lib/rota.js"></script>
|
| 298 |
+
<script src="app.js"></script>
|
| 299 |
+
</body>
|
| 300 |
+
</html>
|
rotasprig/lib/rota.js
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Rotasprig scheduling engine: times, dates, shift hours after breaks, totals, labour cost, overtime,
|
| 2 |
+
* warnings (max hours, rest between shifts, overlap, unavailable day), hourly coverage, per-person text, CSV, examples.
|
| 3 |
+
* Pure functions, no DOM. Loaded by the app (window.Rota) and by the unit tests (require).
|
| 4 |
+
* © 2026 CyberMax. All rights reserved. */
|
| 5 |
+
(function (root, factory) {
|
| 6 |
+
if (typeof module === "object" && module.exports) module.exports = factory();
|
| 7 |
+
else root.Rota = factory();
|
| 8 |
+
})(typeof self !== "undefined" ? self : this, function () {
|
| 9 |
+
"use strict";
|
| 10 |
+
|
| 11 |
+
var DAY = 1440;
|
| 12 |
+
var DOW = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
| 13 |
+
var DOW_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
| 14 |
+
var MON = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
| 15 |
+
var COLORS = ["#0E6B5C", "#C2410C", "#1D4ED8", "#A21CAF", "#4D7C0F", "#B45309", "#0E7490", "#BE123C", "#6D28D9", "#475569"];
|
| 16 |
+
var CURRENCIES = ["USD", "CAD", "GBP", "EUR", "AUD", "NZD", "ZAR", "INR", "SGD", "AED"];
|
| 17 |
+
|
| 18 |
+
/* ---------- numbers ---------- */
|
| 19 |
+
function parseNum(v) {
|
| 20 |
+
if (typeof v === "number") return isFinite(v) ? v : null;
|
| 21 |
+
var s = String(v == null ? "" : v).trim().replace(/[\s$€£]/g, "");
|
| 22 |
+
if (!s) return null;
|
| 23 |
+
if (/^-?\d+,\d{1,2}$/.test(s)) s = s.replace(",", ".");
|
| 24 |
+
s = s.replace(/,/g, "");
|
| 25 |
+
var n = Number(s);
|
| 26 |
+
return isFinite(n) ? n : null;
|
| 27 |
+
}
|
| 28 |
+
function round(n, d) { var p = Math.pow(10, d || 0); return Math.round((n + (n >= 0 ? 1e-9 : -1e-9)) * p) / p; }
|
| 29 |
+
function money(n, cur) {
|
| 30 |
+
cur = cur || "USD";
|
| 31 |
+
try { return new Intl.NumberFormat("en-US", { style: "currency", currency: cur, minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(round(n || 0, 2)); }
|
| 32 |
+
catch (e) { return cur + " " + round(n || 0, 2).toFixed(2); }
|
| 33 |
+
}
|
| 34 |
+
/** minutes -> "7.5" (hours, up to 2 decimals, no trailing zeros) */
|
| 35 |
+
function hrs(min) { var h = round((min || 0) / 60, 2); return String(h); }
|
| 36 |
+
|
| 37 |
+
/* ---------- times (minutes from midnight) ---------- */
|
| 38 |
+
/** "7", "07:30", "730", "7am", "3:15 pm", "15", "15:00", "noon", "midnight", "24:00" -> minutes, or null. */
|
| 39 |
+
function parseTime(v) {
|
| 40 |
+
if (typeof v === "number") return v >= 0 && v <= DAY ? Math.round(v) : null;
|
| 41 |
+
var s = String(v == null ? "" : v).trim().toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
| 42 |
+
if (!s) return null;
|
| 43 |
+
if (s === "noon") return 720;
|
| 44 |
+
if (s === "midnight") return 0;
|
| 45 |
+
var m = /^(\d{1,2})(?::?(\d{2}))?(am|pm|a|p)?$/.exec(s);
|
| 46 |
+
if (!m) return null;
|
| 47 |
+
var h = Number(m[1]), mi = m[2] ? Number(m[2]) : 0, ap = m[3];
|
| 48 |
+
if (!m[2] && m[1].length > 2) return null;
|
| 49 |
+
if (mi > 59) return null;
|
| 50 |
+
if (ap) {
|
| 51 |
+
if (h < 1 || h > 12) return null;
|
| 52 |
+
if (h === 12) h = 0;
|
| 53 |
+
if (ap[0] === "p") h += 12;
|
| 54 |
+
} else if (h > 24 || (h === 24 && mi > 0)) return null;
|
| 55 |
+
return h * 60 + mi;
|
| 56 |
+
}
|
| 57 |
+
function pad(n) { return (n < 10 ? "0" : "") + n; }
|
| 58 |
+
/** minutes -> "7:00" / "15:30" (fmt "24") or "7am" / "3:30pm" (fmt "12"); "HH:MM" with fmt "hhmm". */
|
| 59 |
+
function fmtTime(min, fmt) {
|
| 60 |
+
min = ((Math.round(min) % DAY) + DAY) % DAY;
|
| 61 |
+
var h = Math.floor(min / 60), mi = min % 60;
|
| 62 |
+
if (fmt === "hhmm") return pad(h) + ":" + pad(mi);
|
| 63 |
+
if (fmt === "12") {
|
| 64 |
+
var ap = h < 12 ? "am" : "pm", h12 = h % 12 || 12;
|
| 65 |
+
return h12 + (mi ? ":" + pad(mi) : "") + ap;
|
| 66 |
+
}
|
| 67 |
+
return h + ":" + pad(mi);
|
| 68 |
+
}
|
| 69 |
+
function fmtRange(sh, fmt) { return fmtTime(sh.start, fmt) + "-" + fmtTime(sh.end, fmt); }
|
| 70 |
+
/** shift length in minutes; an end at or before the start runs past midnight. */
|
| 71 |
+
function duration(start, end) {
|
| 72 |
+
if (start == null || end == null) return 0;
|
| 73 |
+
if (end === start) return 0;
|
| 74 |
+
return end > start ? end - start : end + DAY - start;
|
| 75 |
+
}
|
| 76 |
+
/** paid minutes = length less unpaid break (never below 0) */
|
| 77 |
+
function paidMinutes(sh) { return Math.max(0, duration(sh.start, sh.end) - Math.max(0, Number(sh.brk) || 0)); }
|
| 78 |
+
|
| 79 |
+
/* ---------- dates (ISO yyyy-mm-dd, UTC maths) ---------- */
|
| 80 |
+
function toDate(iso) { var p = String(iso).split("-"); return new Date(Date.UTC(+p[0], +p[1] - 1, +p[2])); }
|
| 81 |
+
function iso(d) { return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()); }
|
| 82 |
+
function isISO(s) { return typeof s === "string" && /^\d{4}-\d{2}-\d{2}$/.test(s) && iso(toDate(s)) === s; }
|
| 83 |
+
function addDays(s, n) { var d = toDate(s); d.setUTCDate(d.getUTCDate() + n); return iso(d); }
|
| 84 |
+
function dow(s) { return toDate(s).getUTCDay(); }
|
| 85 |
+
function dayNum(s) { return Math.round(toDate(s).getTime() / 864e5); }
|
| 86 |
+
function diffDays(a, b) { return dayNum(b) - dayNum(a); }
|
| 87 |
+
/** start of the week containing s; startDay 1 = Monday, 0 = Sunday */
|
| 88 |
+
function weekStartOf(s, startDay) { var sd = startDay == null ? 1 : startDay; return addDays(s, -((dow(s) - sd + 7) % 7)); }
|
| 89 |
+
function weekDates(start) { var out = []; for (var i = 0; i < 7; i++) out.push(addDays(start, i)); return out; }
|
| 90 |
+
function todayISO(now) { var d = now || new Date(); return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate()); }
|
| 91 |
+
function fmtDay(s) { return DOW[dow(s)]; }
|
| 92 |
+
function fmtDate(s) { var d = toDate(s); return DOW[d.getUTCDay()] + " " + d.getUTCDate() + " " + MON[d.getUTCMonth()]; }
|
| 93 |
+
function fmtLong(s) { var d = toDate(s); return fmtDate(s) + " " + d.getUTCFullYear(); }
|
| 94 |
+
function fmtWeek(start) {
|
| 95 |
+
var a = toDate(start), b = toDate(addDays(start, 6));
|
| 96 |
+
var left = a.getUTCDate() + (a.getUTCMonth() !== b.getUTCMonth() ? " " + MON[a.getUTCMonth()] : "") + (a.getUTCFullYear() !== b.getUTCFullYear() ? " " + a.getUTCFullYear() : "");
|
| 97 |
+
return left + " - " + b.getUTCDate() + " " + MON[b.getUTCMonth()] + " " + b.getUTCFullYear();
|
| 98 |
+
}
|
| 99 |
+
function inWeek(date, start) { var k = diffDays(start, date); return k >= 0 && k < 7; }
|
| 100 |
+
|
| 101 |
+
/* ---------- week maths ---------- */
|
| 102 |
+
function byId(list) { var m = {}; (list || []).forEach(function (x) { m[x.id] = x; }); return m; }
|
| 103 |
+
function weekShifts(shifts, start) { return (shifts || []).filter(function (s) { return inWeek(s.date, start); }); }
|
| 104 |
+
function sortShifts(list) {
|
| 105 |
+
return list.slice().sort(function (a, b) { return a.date < b.date ? -1 : a.date > b.date ? 1 : (a.start - b.start) || (a.end - b.end); });
|
| 106 |
+
}
|
| 107 |
+
function rateOf(p) { var r = parseNum(p && p.rate); return r != null && r >= 0 ? r : null; }
|
| 108 |
+
|
| 109 |
+
/** totals for the week: per person, per day and overall (minutes after breaks, labour cost at base rate) */
|
| 110 |
+
function totals(staff, shifts, start) {
|
| 111 |
+
var people = byId(staff), dates = weekDates(start);
|
| 112 |
+
var byPerson = {}, byDay = dates.map(function (d) { return { date: d, minutes: 0, cost: 0, people: 0, shifts: 0, _p: {} }; });
|
| 113 |
+
(staff || []).forEach(function (p) { byPerson[p.id] = { minutes: 0, cost: 0, shifts: 0, days: 0, rate: rateOf(p), _d: {} }; });
|
| 114 |
+
var total = { minutes: 0, cost: 0, shifts: 0, unrated: 0 };
|
| 115 |
+
weekShifts(shifts, start).forEach(function (s) {
|
| 116 |
+
var p = people[s.staffId]; if (!p) return;
|
| 117 |
+
var k = diffDays(start, s.date), m = paidMinutes(s), r = rateOf(p), c = r == null ? 0 : m / 60 * r;
|
| 118 |
+
var bp = byPerson[p.id], bd = byDay[k];
|
| 119 |
+
bp.minutes += m; bp.cost += c; bp.shifts++; if (!bp._d[k]) { bp._d[k] = 1; bp.days++; }
|
| 120 |
+
bd.minutes += m; bd.cost += c; bd.shifts++; if (!bd._p[p.id]) { bd._p[p.id] = 1; bd.people++; }
|
| 121 |
+
total.minutes += m; total.cost += c; total.shifts++; if (r == null && m) total.unrated += m;
|
| 122 |
+
});
|
| 123 |
+
Object.keys(byPerson).forEach(function (k) { delete byPerson[k]._d; byPerson[k].cost = round(byPerson[k].cost, 2); });
|
| 124 |
+
byDay.forEach(function (d) { delete d._p; d.cost = round(d.cost, 2); });
|
| 125 |
+
total.cost = round(total.cost, 2);
|
| 126 |
+
total.people = Object.keys(byPerson).filter(function (k) { return byPerson[k].shifts; }).length;
|
| 127 |
+
return { byPerson: byPerson, byDay: byDay, total: total };
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/** absolute minute span of a shift relative to a reference date */
|
| 131 |
+
function span(s, ref) { var a = diffDays(ref, s.date) * DAY + s.start; return { s: a, e: a + duration(s.start, s.end) }; }
|
| 132 |
+
|
| 133 |
+
/** warnings for one week. opts.minRest = hours between shifts on different days (editable assumption). */
|
| 134 |
+
function warnings(staff, shifts, start, opts) {
|
| 135 |
+
opts = opts || {};
|
| 136 |
+
var minRest = parseNum(opts.minRest); if (minRest == null) minRest = 10;
|
| 137 |
+
var out = [], people = byId(staff), t = totals(staff, shifts, start), fmt = opts.fmt;
|
| 138 |
+
var lo = addDays(start, -1);
|
| 139 |
+
(staff || []).forEach(function (p) {
|
| 140 |
+
var mine = sortShifts((shifts || []).filter(function (s) { return s.staffId === p.id && diffDays(lo, s.date) >= 0 && diffDays(lo, s.date) < 9; }));
|
| 141 |
+
mine.forEach(function (s) {
|
| 142 |
+
if (!inWeek(s.date, start)) return;
|
| 143 |
+
if (!duration(s.start, s.end)) out.push({ type: "invalid", staffId: p.id, shiftIds: [s.id], text: p.name + ": " + fmtDate(s.date) + " shift ends when it starts" });
|
| 144 |
+
if (p.avail && p.avail[dow(s.date)] === false) out.push({ type: "unavailable", staffId: p.id, shiftIds: [s.id], text: p.name + " is marked unavailable on " + DOW_LONG[dow(s.date)] + "s (" + fmtDate(s.date) + " " + fmtRange(s, fmt) + ")" });
|
| 145 |
+
});
|
| 146 |
+
for (var i = 1; i < mine.length; i++) {
|
| 147 |
+
var a = mine[i - 1], b = mine[i];
|
| 148 |
+
if (!inWeek(a.date, start) && !inWeek(b.date, start)) continue;
|
| 149 |
+
// compare b against every earlier shift's end (handles a long shift containing a short one)
|
| 150 |
+
var latest = a, end = span(a, lo).e;
|
| 151 |
+
for (var j = 0; j < i - 1; j++) { var e2 = span(mine[j], lo).e; if (e2 > end) { end = e2; latest = mine[j]; } }
|
| 152 |
+
var gap = span(b, lo).s - end;
|
| 153 |
+
if (gap < 0) out.push({ type: "overlap", staffId: p.id, shiftIds: [latest.id, b.id], text: p.name + ": shifts overlap on " + fmtDate(b.date) + " (" + fmtRange(latest, fmt) + " and " + fmtRange(b, fmt) + ")" });
|
| 154 |
+
else if (b.date !== latest.date && gap < minRest * 60) out.push({ type: "rest", staffId: p.id, shiftIds: [latest.id, b.id], gap: gap, text: p.name + ": only " + hrs(gap) + " h rest between " + fmtDate(latest.date) + " " + fmtRange(latest, fmt) + " and " + fmtDate(b.date) + " " + fmtRange(b, fmt) + " (your minimum: " + minRest + " h)" });
|
| 155 |
+
}
|
| 156 |
+
var mx = parseNum(p.maxHours), bp = t.byPerson[p.id];
|
| 157 |
+
if (mx != null && mx > 0 && bp && bp.minutes > mx * 60 + 1e-6) {
|
| 158 |
+
out.push({ type: "max", staffId: p.id, shiftIds: weekShifts(shifts, start).filter(function (s) { return s.staffId === p.id; }).map(function (s) { return s.id; }), text: p.name + ": " + hrs(bp.minutes) + " h scheduled, over the " + mx + " h weekly maximum by " + hrs(bp.minutes - mx * 60) + " h" });
|
| 159 |
+
}
|
| 160 |
+
});
|
| 161 |
+
var order = { overlap: 0, invalid: 1, rest: 2, max: 3, unavailable: 4 };
|
| 162 |
+
var idx = {}; (staff || []).forEach(function (p, i) { idx[p.id] = i; });
|
| 163 |
+
return out.sort(function (x, y) { return (idx[x.staffId] - idx[y.staffId]) || (order[x.type] - order[y.type]); });
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/** people on shift per hour: grid[day][hour]; someone counts for an hour when they work 30+ minutes of it.
|
| 167 |
+
* filter(shift, person) -> bool narrows by role or station. Breaks are not subtracted. */
|
| 168 |
+
function coverage(staff, shifts, start, filter) {
|
| 169 |
+
var people = byId(staff), grid = [], i, h;
|
| 170 |
+
for (i = 0; i < 7; i++) { grid.push([]); for (h = 0; h < 24; h++) grid[i].push(0); }
|
| 171 |
+
var seen = {};
|
| 172 |
+
(shifts || []).forEach(function (s) {
|
| 173 |
+
var p = people[s.staffId]; if (!p) return;
|
| 174 |
+
var k = diffDays(start, s.date); if (k < -1 || k > 6) return;
|
| 175 |
+
if (filter && !filter(s, p)) return;
|
| 176 |
+
var sp = span(s, start);
|
| 177 |
+
for (var slot = Math.max(0, Math.floor(sp.s / 60)); slot * 60 < sp.e && slot < 7 * 24; slot++) {
|
| 178 |
+
var ov = Math.min(sp.e, slot * 60 + 60) - Math.max(sp.s, slot * 60);
|
| 179 |
+
if (ov >= 30) {
|
| 180 |
+
var key = p.id + ":" + slot; if (seen[key]) continue; seen[key] = 1;
|
| 181 |
+
grid[Math.floor(slot / 24)][slot % 24]++;
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
});
|
| 185 |
+
var first = 24, last = -1, peak = 0, peaks = [], thin = [];
|
| 186 |
+
for (i = 0; i < 7; i++) for (h = 0; h < 24; h++) {
|
| 187 |
+
var c = grid[i][h];
|
| 188 |
+
if (c) { if (h < first) first = h; if (h > last) last = h; }
|
| 189 |
+
if (c > peak) { peak = c; peaks = [[i, h]]; } else if (c && c === peak) peaks.push([i, h]);
|
| 190 |
+
if (c === 1) thin.push([i, h]);
|
| 191 |
+
}
|
| 192 |
+
return { grid: grid, first: last < 0 ? 9 : first, last: last < 0 ? 17 : last, peak: peak, peaks: peaks, single: thin };
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
/** group consecutive hours [[day,h],...] into "Mon 7:00-9:00" ranges */
|
| 196 |
+
function hourRanges(cells, dates, fmt) {
|
| 197 |
+
var out = [], cur = null;
|
| 198 |
+
cells.forEach(function (c) {
|
| 199 |
+
if (cur && cur.d === c[0] && cur.e === c[1]) { cur.e++; return; }
|
| 200 |
+
if (cur) out.push(cur);
|
| 201 |
+
cur = { d: c[0], s: c[1], e: c[1] + 1 };
|
| 202 |
+
});
|
| 203 |
+
if (cur) out.push(cur);
|
| 204 |
+
return out.map(function (r) { return fmtDay(dates[r.d]) + " " + fmtTime(r.s * 60, fmt) + "-" + fmtTime(r.e * 60, fmt); });
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
/** labour report with weekly overtime (opts.otAfter hours, opts.otMult): editable assumptions */
|
| 208 |
+
function labour(staff, shifts, start, opts) {
|
| 209 |
+
opts = opts || {};
|
| 210 |
+
var after = parseNum(opts.otAfter); if (after == null) after = 40;
|
| 211 |
+
var mult = parseNum(opts.otMult); if (mult == null) mult = 1.5;
|
| 212 |
+
var t = totals(staff, shifts, start), rows = [], sum = { minutes: 0, regular: 0, ot: 0, base: 0, premium: 0, total: 0 };
|
| 213 |
+
(staff || []).forEach(function (p) {
|
| 214 |
+
var bp = t.byPerson[p.id] || { minutes: 0, shifts: 0 }, r = rateOf(p);
|
| 215 |
+
var ot = Math.max(0, bp.minutes - after * 60), reg = bp.minutes - ot;
|
| 216 |
+
var base = r == null ? 0 : round(bp.minutes / 60 * r, 2), prem = r == null ? 0 : round(ot / 60 * r * (mult - 1), 2);
|
| 217 |
+
rows.push({ id: p.id, name: p.name, role: p.role || "", shifts: bp.shifts, minutes: bp.minutes, regular: reg, ot: ot, rate: r, base: base, premium: prem, total: round(base + prem, 2) });
|
| 218 |
+
sum.minutes += bp.minutes; sum.regular += reg; sum.ot += ot; sum.base += base; sum.premium += prem;
|
| 219 |
+
});
|
| 220 |
+
sum.base = round(sum.base, 2); sum.premium = round(sum.premium, 2); sum.total = round(sum.base + sum.premium, 2);
|
| 221 |
+
return { rows: rows, sum: sum, days: t.byDay, otAfter: after, otMult: mult };
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
/** "Maya (Manager), week of Mon 5 Oct\nMon 7:00-15:00 Bar\nTue off\n...\nTotal 37.5 h" */
|
| 225 |
+
function personText(p, shifts, start, opts) {
|
| 226 |
+
opts = opts || {};
|
| 227 |
+
var fmt = opts.fmt, mine = sortShifts(weekShifts(shifts, start).filter(function (s) { return s.staffId === p.id; }));
|
| 228 |
+
var lines = [p.name + (p.role ? " (" + p.role + ")" : "") + ", week of " + fmtDate(start) + (opts.place ? " at " + opts.place : "")];
|
| 229 |
+
var mins = 0;
|
| 230 |
+
weekDates(start).forEach(function (d) {
|
| 231 |
+
var day = mine.filter(function (s) { return s.date === d; });
|
| 232 |
+
if (!day.length) { lines.push(fmtDay(d) + " off"); return; }
|
| 233 |
+
lines.push(fmtDay(d) + " " + day.map(function (s) {
|
| 234 |
+
mins += paidMinutes(s);
|
| 235 |
+
return fmtRange(s, fmt) + (s.station ? " " + s.station : "") + (s.note ? " (" + s.note + ")" : "");
|
| 236 |
+
}).join(" + "));
|
| 237 |
+
});
|
| 238 |
+
lines.push("Total " + hrs(mins) + " h");
|
| 239 |
+
return lines.join("\n");
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/* ---------- CSV ---------- */
|
| 243 |
+
function csvCell(v) { var s = v == null ? "" : String(v); return /[",\n\r]/.test(s) || /^[=+\-@]/.test(s) ? '"' + s.replace(/"/g, '""') + '"' : s; }
|
| 244 |
+
function toCSV(rows) { return rows.map(function (r) { return r.map(csvCell).join(","); }).join("\r\n") + "\r\n"; }
|
| 245 |
+
/** one row per shift, for payroll */
|
| 246 |
+
function shiftsCSV(staff, shifts, start, place) {
|
| 247 |
+
var people = byId(staff), rows = [["Location", "Week starting", "Date", "Day", "Name", "Role", "Station", "Start", "End", "Break (min)", "Paid hours", "Hourly rate", "Cost", "Note"]];
|
| 248 |
+
var idx = {}; (staff || []).forEach(function (p, i) { idx[p.id] = i; });
|
| 249 |
+
sortShifts(weekShifts(shifts, start)).sort(function (a, b) { return (idx[a.staffId] - idx[b.staffId]) || (a.date < b.date ? -1 : a.date > b.date ? 1 : a.start - b.start); }).forEach(function (s) {
|
| 250 |
+
var p = people[s.staffId]; if (!p) return;
|
| 251 |
+
var m = paidMinutes(s), r = rateOf(p);
|
| 252 |
+
rows.push([place || "", start, s.date, fmtDay(s.date), p.name, p.role || "", s.station || "", fmtTime(s.start, "hhmm"), fmtTime(s.end, "hhmm"), Number(s.brk) || 0, hrs(m), r == null ? "" : r.toFixed(2), r == null ? "" : round(m / 60 * r, 2).toFixed(2), s.note || ""]);
|
| 253 |
+
});
|
| 254 |
+
return toCSV(rows);
|
| 255 |
+
}
|
| 256 |
+
/** one row per person with weekly overtime split */
|
| 257 |
+
function hoursCSV(staff, shifts, start, opts, place) {
|
| 258 |
+
var L = labour(staff, shifts, start, opts);
|
| 259 |
+
var rows = [["Location", "Week starting", "Name", "Role", "Shifts", "Paid hours", "Regular hours", "Overtime hours", "Hourly rate", "Base pay", "Overtime premium", "Total"]];
|
| 260 |
+
L.rows.forEach(function (r) {
|
| 261 |
+
rows.push([place || "", start, r.name, r.role, r.shifts, hrs(r.minutes), hrs(r.regular), hrs(r.ot), r.rate == null ? "" : r.rate.toFixed(2), r.base.toFixed(2), r.premium.toFixed(2), r.total.toFixed(2)]);
|
| 262 |
+
});
|
| 263 |
+
rows.push([place || "", start, "Total", "", "", hrs(L.sum.minutes), hrs(L.sum.regular), hrs(L.sum.ot), "", L.sum.base.toFixed(2), L.sum.premium.toFixed(2), L.sum.total.toFixed(2)]);
|
| 264 |
+
return toCSV(rows);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
/** copy the shifts of week `from` into week `to` (new ids from makeId) */
|
| 268 |
+
function copyWeek(shifts, from, to, makeId) {
|
| 269 |
+
var k = diffDays(from, to);
|
| 270 |
+
return weekShifts(shifts, from).map(function (s) {
|
| 271 |
+
var c = {}; Object.keys(s).forEach(function (x) { c[x] = s[x]; });
|
| 272 |
+
c.id = makeId(); c.date = addDays(s.date, k); return c;
|
| 273 |
+
});
|
| 274 |
+
}
|
| 275 |
+
/** list of week starts that hold shifts, newest first */
|
| 276 |
+
function savedWeeks(shifts, startDay) {
|
| 277 |
+
var m = {};
|
| 278 |
+
(shifts || []).forEach(function (s) { m[weekStartOf(s.date, startDay)] = (m[weekStartOf(s.date, startDay)] || 0) + 1; });
|
| 279 |
+
return Object.keys(m).sort().reverse().map(function (w) { return { start: w, shifts: m[w] }; });
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
/* ---------- examples ---------- */
|
| 283 |
+
var ALL = [true, true, true, true, true, true, true];
|
| 284 |
+
function avail(offDows) { var a = ALL.slice(); (offDows || []).forEach(function (d) { a[d] = false; }); return a; }
|
| 285 |
+
var EXAMPLES = {
|
| 286 |
+
cafe: {
|
| 287 |
+
name: "Corner Cafe",
|
| 288 |
+
staff: [
|
| 289 |
+
["Maya Ortiz", "Manager", 24, 45, []],
|
| 290 |
+
["Leo Park", "Barista", 17, 40, [0]],
|
| 291 |
+
["Priya Shah", "Barista", 17, 24, [1]],
|
| 292 |
+
["Sam Reid", "Cook", 19.5, 40, []],
|
| 293 |
+
["Jordan Lee", "Cook", 18, 32, []],
|
| 294 |
+
["Ava Brooks", "Server", 14, 30, [6]],
|
| 295 |
+
["Noah Kim", "Dishwasher", 15, 25, []],
|
| 296 |
+
],
|
| 297 |
+
templates: [["Open", "7:00", "15:00", 30, ""], ["Mid", "11:00", "19:00", 30, ""], ["Close", "15:00", "23:00", 30, ""]],
|
| 298 |
+
shifts: [
|
| 299 |
+
[0, 0, "7:00", "15:00", 30, "Floor"], [0, 1, "7:00", "15:00", 30, "Floor"], [0, 2, "11:00", "19:00", 30, "Floor"], [0, 3, "7:00", "15:00", 30, "Floor"], [0, 4, "7:00", "15:00", 30, "Floor", "Stock order"],
|
| 300 |
+
[1, 0, "15:00", "23:00", 30, "Bar"], [1, 1, "15:00", "23:00", 30, "Bar"], [1, 2, "7:00", "15:00", 30, "Bar"], [1, 4, "15:00", "23:00", 30, "Bar"], [1, 5, "15:00", "23:00", 30, "Bar"],
|
| 301 |
+
[2, 2, "15:00", "23:00", 30, "Bar"], [2, 3, "15:00", "23:00", 30, "Bar"], [2, 5, "7:00", "15:00", 30, "Bar"], [2, 6, "7:00", "15:00", 30, "Bar"],
|
| 302 |
+
[3, 0, "7:00", "15:00", 30, "Kitchen"], [3, 1, "7:00", "15:00", 30, "Kitchen"], [3, 2, "7:00", "15:00", 30, "Kitchen"], [3, 5, "11:00", "19:00", 30, "Kitchen"], [3, 6, "11:00", "19:00", 30, "Kitchen"],
|
| 303 |
+
[4, 0, "15:00", "23:00", 30, "Kitchen"], [4, 3, "15:00", "23:00", 30, "Kitchen"], [4, 4, "15:00", "23:00", 30, "Kitchen"], [4, 5, "15:00", "23:00", 30, "Kitchen"],
|
| 304 |
+
[5, 4, "11:00", "15:00", 0, "Floor"], [5, 5, "17:00", "22:00", 0, "Floor"], [5, 6, "10:00", "16:00", 30, "Floor"],
|
| 305 |
+
[6, 4, "17:00", "23:00", 0, "Dish"], [6, 5, "17:00", "23:00", 0, "Dish"], [6, 6, "12:00", "20:00", 30, "Dish"],
|
| 306 |
+
],
|
| 307 |
+
},
|
| 308 |
+
restaurant: {
|
| 309 |
+
name: "Harbor Bistro",
|
| 310 |
+
staff: [
|
| 311 |
+
["Elena Ruiz", "FOH manager", 26, 50, []],
|
| 312 |
+
["Marcus Hill", "Server", 12, 40, []],
|
| 313 |
+
["Chloe Adams", "Server", 12, 32, [2]],
|
| 314 |
+
["Diego Santos", "Bartender", 14, 40, []],
|
| 315 |
+
["Hannah Price", "Host", 15, 25, []],
|
| 316 |
+
["Omar Haddad", "Line cook", 21, 45, []],
|
| 317 |
+
["Tess Nguyen", "Prep cook", 18, 40, []],
|
| 318 |
+
["Ray Cole", "Dishwasher", 16, 45, []],
|
| 319 |
+
],
|
| 320 |
+
templates: [["Lunch", "11:00", "15:00", 0, "Floor"], ["Dinner", "17:00", "22:00", 0, "Floor"], ["Prep", "8:00", "16:30", 30, "Prep"], ["Line", "14:00", "22:30", 30, "Grill"], ["Bar close", "16:00", "23:30", 30, "Bar"]],
|
| 321 |
+
shifts: [
|
| 322 |
+
[0, 1, "10:30", "19:00", 30, "Pass"], [0, 2, "10:30", "19:00", 30, "Pass"], [0, 3, "10:30", "19:00", 30, "Pass"], [0, 4, "10:30", "19:00", 30, "Pass"], [0, 5, "10:30", "19:00", 30, "Pass"],
|
| 323 |
+
[1, 1, "11:00", "15:00", 0, "Floor", "Split"], [1, 1, "17:00", "22:00", 0, "Floor", "Split"], [1, 2, "16:30", "22:30", 0, "Floor"], [1, 4, "11:00", "15:00", 0, "Floor", "Split"], [1, 4, "17:00", "22:00", 0, "Floor", "Split"], [1, 5, "16:30", "23:00", 0, "Floor"], [1, 6, "10:00", "16:00", 30, "Floor", "Brunch"],
|
| 324 |
+
[2, 3, "11:00", "15:00", 0, "Floor", "Split"], [2, 3, "17:00", "22:00", 0, "Floor", "Split"], [2, 4, "16:30", "22:30", 0, "Floor"], [2, 5, "11:00", "15:00", 0, "Floor", "Split"], [2, 5, "17:00", "22:00", 0, "Floor", "Split"], [2, 6, "10:00", "16:00", 30, "Floor", "Brunch"],
|
| 325 |
+
[3, 2, "16:00", "23:30", 30, "Bar"], [3, 3, "16:00", "23:30", 30, "Bar"], [3, 4, "16:00", "23:30", 30, "Bar"], [3, 5, "16:00", "23:30", 30, "Bar"], [3, 6, "16:00", "23:30", 30, "Bar"],
|
| 326 |
+
[4, 4, "17:00", "21:30", 0, "Host stand"], [4, 5, "17:00", "21:30", 0, "Host stand"], [4, 6, "10:00", "15:00", 0, "Host stand"],
|
| 327 |
+
[5, 1, "14:00", "22:30", 30, "Grill"], [5, 2, "14:00", "22:30", 30, "Grill"], [5, 3, "14:00", "22:30", 30, "Grill"], [5, 4, "14:00", "22:30", 30, "Grill"], [5, 5, "14:00", "22:30", 30, "Grill"], [5, 6, "9:30", "15:30", 30, "Grill"],
|
| 328 |
+
[6, 1, "8:00", "16:30", 30, "Prep"], [6, 2, "8:00", "16:30", 30, "Prep"], [6, 3, "8:00", "16:30", 30, "Prep"], [6, 4, "8:00", "16:30", 30, "Prep"], [6, 5, "8:00", "16:30", 30, "Prep"],
|
| 329 |
+
[7, 1, "15:00", "23:00", 30, "Dish"], [7, 2, "15:00", "23:00", 30, "Dish"], [7, 3, "15:00", "23:00", 30, "Dish"], [7, 4, "15:00", "23:30", 30, "Dish"], [7, 5, "15:00", "23:30", 30, "Dish"], [7, 6, "8:00", "14:00", 0, "Dish"],
|
| 330 |
+
],
|
| 331 |
+
},
|
| 332 |
+
salon: {
|
| 333 |
+
name: "Studio Nine Salon",
|
| 334 |
+
staff: [
|
| 335 |
+
["Grace Bell", "Owner, senior stylist", null, 50, []],
|
| 336 |
+
["Mia Torres", "Stylist", 20, 40, [0, 1]],
|
| 337 |
+
["Kai Morgan", "Stylist", 20, 32, [2]],
|
| 338 |
+
["Zoe Carter", "Colourist", 22, 36, []],
|
| 339 |
+
["Lily Evans", "Junior stylist", 15, 30, []],
|
| 340 |
+
["Ben Wright", "Reception", 16, 40, []],
|
| 341 |
+
],
|
| 342 |
+
templates: [["Day", "9:00", "17:30", 30, ""], ["Late", "12:00", "20:30", 30, ""], ["Half day", "9:00", "13:00", 0, ""]],
|
| 343 |
+
shifts: [
|
| 344 |
+
[0, 1, "9:00", "17:30", 30, "Chair 1"], [0, 2, "9:00", "17:30", 30, "Chair 1"], [0, 3, "9:00", "17:30", 30, "Chair 1"], [0, 4, "9:00", "17:30", 30, "Chair 1"], [0, 5, "9:00", "17:30", 30, "Chair 1"],
|
| 345 |
+
[1, 1, "9:00", "17:30", 30, "Chair 2"], [1, 2, "9:00", "17:30", 30, "Chair 2"], [1, 3, "12:00", "20:30", 30, "Chair 2"], [1, 4, "9:00", "17:30", 30, "Chair 2"], [1, 5, "9:00", "17:30", 30, "Chair 2"],
|
| 346 |
+
[2, 2, "12:00", "20:30", 30, "Chair 3"], [2, 3, "12:00", "20:30", 30, "Chair 3"], [2, 4, "12:00", "20:30", 30, "Chair 3"], [2, 5, "9:00", "17:30", 30, "Chair 3"],
|
| 347 |
+
[3, 1, "9:00", "17:30", 30, "Colour bar"], [3, 2, "9:00", "17:30", 30, "Colour bar"], [3, 3, "12:00", "20:30", 30, "Colour bar"], [3, 4, "12:00", "20:30", 30, "Colour bar"],
|
| 348 |
+
[4, 1, "9:00", "13:00", 0, "Chair 4", "Training"], [4, 3, "12:00", "20:30", 30, "Chair 4"], [4, 4, "12:00", "20:30", 30, "Chair 4"], [4, 5, "9:00", "17:30", 30, "Chair 4"],
|
| 349 |
+
[5, 1, "9:00", "17:30", 30, "Desk"], [5, 2, "9:00", "17:30", 30, "Desk"], [5, 3, "12:00", "20:30", 30, "Desk"], [5, 4, "9:00", "17:30", 30, "Desk"], [5, 5, "9:00", "17:30", 30, "Desk"],
|
| 350 |
+
],
|
| 351 |
+
},
|
| 352 |
+
};
|
| 353 |
+
/** example schedule for the week starting `start` (a Monday); kinds: cafe, restaurant, salon */
|
| 354 |
+
function example(kind, start) {
|
| 355 |
+
var ex = EXAMPLES[kind] || EXAMPLES.cafe, n = 0;
|
| 356 |
+
var staff = ex.staff.map(function (r, i) { return { id: "p" + (i + 1), name: r[0], role: r[1], color: COLORS[i % COLORS.length], rate: r[2] == null ? "" : r[2], maxHours: r[3], avail: avail(r[4]) }; });
|
| 357 |
+
var templates = ex.templates.map(function (r, i) { return { id: "t" + (i + 1), label: r[0], start: parseTime(r[1]), end: parseTime(r[2]), brk: r[3], station: r[4] || "" }; });
|
| 358 |
+
var shifts = ex.shifts.map(function (r) { n++; return { id: "s" + n, staffId: staff[r[0]].id, date: addDays(start, r[1]), start: parseTime(r[2]), end: parseTime(r[3]), brk: r[4], station: r[5] || "", note: r[6] || "" }; });
|
| 359 |
+
return { name: ex.name, staff: staff, templates: templates, shifts: shifts };
|
| 360 |
+
}
|
| 361 |
+
function defaultTemplates() {
|
| 362 |
+
return [{ id: "t1", label: "Open", start: 420, end: 900, brk: 30, station: "" }, { id: "t2", label: "Mid", start: 660, end: 1140, brk: 30, station: "" }, { id: "t3", label: "Close", start: 900, end: 1380, brk: 30, station: "" }];
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
return {
|
| 366 |
+
DAY: DAY, DOW: DOW, DOW_LONG: DOW_LONG, COLORS: COLORS, CURRENCIES: CURRENCIES,
|
| 367 |
+
parseNum: parseNum, round: round, money: money, hrs: hrs,
|
| 368 |
+
parseTime: parseTime, fmtTime: fmtTime, fmtRange: fmtRange, duration: duration, paidMinutes: paidMinutes,
|
| 369 |
+
addDays: addDays, dow: dow, diffDays: diffDays, isISO: isISO, weekStartOf: weekStartOf, weekDates: weekDates, todayISO: todayISO,
|
| 370 |
+
fmtDay: fmtDay, fmtDate: fmtDate, fmtLong: fmtLong, fmtWeek: fmtWeek, inWeek: inWeek,
|
| 371 |
+
weekShifts: weekShifts, sortShifts: sortShifts, totals: totals, warnings: warnings, coverage: coverage, hourRanges: hourRanges, labour: labour,
|
| 372 |
+
personText: personText, toCSV: toCSV, shiftsCSV: shiftsCSV, hoursCSV: hoursCSV, copyWeek: copyWeek, savedWeeks: savedWeeks,
|
| 373 |
+
example: example, defaultTemplates: defaultTemplates,
|
| 374 |
+
};
|
| 375 |
+
});
|
rotasprig/manifest.webmanifest
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "Rotasprig: employee schedule maker",
|
| 3 |
+
"short_name": "Rotasprig",
|
| 4 |
+
"description": "Weekly staff shift schedule with hours, labour cost and warnings; print it or post a PNG. Free, no sign-up, nothing uploaded, works offline.",
|
| 5 |
+
"start_url": "./?utm_source=pwa",
|
| 6 |
+
"scope": "./",
|
| 7 |
+
"display": "standalone",
|
| 8 |
+
"background_color": "#F6F3EC",
|
| 9 |
+
"theme_color": "#146356",
|
| 10 |
+
"categories": ["business", "productivity"],
|
| 11 |
+
"icons": [
|
| 12 |
+
{"src": "icon.svg", "sizes": "any", "type": "image/svg+xml"},
|
| 13 |
+
{"src": "icon-192.png", "sizes": "192x192", "type": "image/png"},
|
| 14 |
+
{"src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any"},
|
| 15 |
+
{"src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable"}
|
| 16 |
+
]
|
| 17 |
+
}
|
rotasprig/og.png
ADDED
|
Git LFS Details
|
rotasprig/pro.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* CyberMax Pro unlock with plans, for static web apps (copied into each product's web/ folder; each product stays
|
| 2 |
+
* self-contained). Extends pro.js with several plans (monthly, yearly, one-time) and a re-check for subscriptions.
|
| 3 |
+
* Config before this script:
|
| 4 |
+
* window.CMX_PRO = { id, name, perks: [..], plans: [{ offer, label, price, per, note, best }], free: "one line" }
|
| 5 |
+
* Buy: counted link https://data.cybermax-tools.workers.dev/buy/<offer>?s=app-<id> -> Stripe Payment Link.
|
| 6 |
+
* After checkout Stripe sends the buyer to data.cybermax-tools.workers.dev/unlock/<id>?session_id=..., which checks the
|
| 7 |
+
* Checkout Session (and, for a subscription, that it is still active) and returns here with #cmx-pro=<session id>.
|
| 8 |
+
* The app checks that code once (/unlock/<id>?json=1&session_id=..) and remembers Pro in this browser; it re-checks every
|
| 9 |
+
* 3 days, so a cancelled subscription turns off by itself (one tiny request per buyer every 3 days, none for free users).
|
| 10 |
+
* The same code (shown on the receipt page and in the Pro box) unlocks Pro on another device. No account, no tracking.
|
| 11 |
+
* (c) 2026 CyberMax. All rights reserved. */
|
| 12 |
+
(function () {
|
| 13 |
+
"use strict";
|
| 14 |
+
var C = window.CMX_PRO || {};
|
| 15 |
+
if (!C.id) return;
|
| 16 |
+
var DATA = "https://data.cybermax-tools.workers.dev";
|
| 17 |
+
var KEY = "cmx-pro:" + C.id;
|
| 18 |
+
var SID = /^cs_(live|test)_[A-Za-z0-9]{10,200}$/;
|
| 19 |
+
var RECHECK = 3 * 864e5;
|
| 20 |
+
var listeners = [];
|
| 21 |
+
|
| 22 |
+
function get() { try { return JSON.parse(localStorage.getItem(KEY) || "null"); } catch (e) { return null; } }
|
| 23 |
+
function set(v) { try { if (v) localStorage.setItem(KEY, JSON.stringify(v)); else localStorage.removeItem(KEY); } catch (e) { /* private mode */ } mem = v; }
|
| 24 |
+
var mem = get();
|
| 25 |
+
function isPro() { return !!(mem && mem.code); }
|
| 26 |
+
|
| 27 |
+
function check(code) {
|
| 28 |
+
return fetch(DATA + "/unlock/" + encodeURIComponent(C.id) + "?json=1&session_id=" + encodeURIComponent(code))
|
| 29 |
+
.then(function (r) { return r.json(); })
|
| 30 |
+
.then(function (j) { return j && typeof j.pro === "boolean" ? j.pro : null; })
|
| 31 |
+
.catch(function () { return null; });
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function unlock(code) {
|
| 35 |
+
return check(code).then(function (ok) {
|
| 36 |
+
if (ok) { set({ code: code, at: new Date().toISOString(), checked: Date.now() }); apply(); toast("Pro unlocked. Thank you for choosing " + C.name + "!"); }
|
| 37 |
+
else if (ok === false) toast("That code is not an active " + C.name + " Pro order.");
|
| 38 |
+
else toast("Could not reach the unlock check. Try again in a minute.");
|
| 39 |
+
return ok;
|
| 40 |
+
});
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function recheck() {
|
| 44 |
+
if (!isPro() || Date.now() - (mem.checked || 0) < RECHECK) return;
|
| 45 |
+
check(mem.code).then(function (ok) {
|
| 46 |
+
if (ok === false) { set(null); apply(); toast(C.name + " Pro has ended in this browser. Everything free is still here."); }
|
| 47 |
+
else if (ok) set(Object.assign({}, mem, { checked: Date.now() }));
|
| 48 |
+
});
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function toast(msg) {
|
| 52 |
+
var t = document.getElementById("toast");
|
| 53 |
+
if (t) { t.textContent = msg; t.hidden = false; t.classList.add("show"); setTimeout(function () { t.classList.remove("show"); }, 3500); }
|
| 54 |
+
var s = document.getElementById("cmx-pro-msg");
|
| 55 |
+
if (s) s.textContent = msg;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return { "&": "&", "<": "<", ">": ">", '"': """ }[c]; }); }
|
| 59 |
+
function buyUrl(offer, from) { return DATA + "/buy/" + offer + "?s=app-" + C.id + (from ? "-" + from : ""); }
|
| 60 |
+
|
| 61 |
+
function box() {
|
| 62 |
+
var el = document.getElementById("cmx-pro");
|
| 63 |
+
if (!el) {
|
| 64 |
+
el = document.createElement("section");
|
| 65 |
+
el.id = "cmx-pro";
|
| 66 |
+
var anchor = document.querySelector("footer.more") || document.querySelector("main footer") || document.querySelector("footer");
|
| 67 |
+
if (anchor && anchor.parentNode) anchor.parentNode.insertBefore(el, anchor); else (document.querySelector("main") || document.body).appendChild(el);
|
| 68 |
+
}
|
| 69 |
+
el.className = "cmx-pro";
|
| 70 |
+
return el;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
function render() {
|
| 74 |
+
var el = box();
|
| 75 |
+
if (isPro()) {
|
| 76 |
+
el.innerHTML = '<h2>' + esc(C.name) + ' Pro <span class="cmx-pro-badge">on</span></h2><p>Thank you! Pro is on in this browser: ' + C.perks.map(esc).join(" · ") +
|
| 77 |
+
'.</p><p class="cmx-pro-small">Your unlock code (paste it on another device): <code style="user-select:all;word-break:break-all">' + esc(mem.code) +
|
| 78 |
+
'</code></p><p class="cmx-pro-small">Monthly or yearly plan? Cancel any time from the link in your Stripe receipt email.</p>';
|
| 79 |
+
return;
|
| 80 |
+
}
|
| 81 |
+
var plans = (C.plans || []).map(function (p) {
|
| 82 |
+
return '<a class="cmx-plan' + (p.best ? " best" : "") + '" href="' + buyUrl(p.offer) + '" rel="nofollow" data-offer="' + esc(p.offer) + '">' +
|
| 83 |
+
(p.best ? "<i>Best value</i>" : "") + "<b>" + esc(p.label) + '</b><span class="cmx-price">' + esc(p.price) + "<small>" + esc(p.per || "") +
|
| 84 |
+
'</small></span><span class="cmx-note">' + esc(p.note || "") + "</span></a>";
|
| 85 |
+
}).join("");
|
| 86 |
+
el.innerHTML = '<h2>' + esc(C.name) + ' Pro</h2>' + (C.free ? '<p class="cmx-pro-small">Free: ' + esc(C.free) + "</p>" : "") +
|
| 87 |
+
"<ul>" + C.perks.map(function (p) { return "<li>" + esc(p) + "</li>"; }).join("") + '</ul><div class="cmx-plans">' + plans +
|
| 88 |
+
'</div><p class="cmx-pro-small">Secure Stripe checkout. Pro turns on the moment you pay; no account needed. Subscriptions cancel any time.</p>' +
|
| 89 |
+
'<details><summary>Already bought Pro?</summary><form id="cmx-pro-form"><label>Unlock code <input id="cmx-pro-code" autocomplete="off" placeholder="cs_live_…"></label> <button class="btn ghost" type="submit">Unlock</button></form></details><p id="cmx-pro-msg" class="cmx-pro-small" aria-live="polite"></p>';
|
| 90 |
+
var f = document.getElementById("cmx-pro-form");
|
| 91 |
+
if (f) f.onsubmit = function (e) { e.preventDefault(); var c = (document.getElementById("cmx-pro-code").value || "").trim(); if (SID.test(c)) unlock(c); else toast("Paste the code from your receipt page (it starts with cs_live_)."); };
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
function apply() {
|
| 95 |
+
document.documentElement.classList.toggle("cmx-pro", isPro());
|
| 96 |
+
render();
|
| 97 |
+
listeners.forEach(function (fn) { try { fn(isPro()); } catch (e) { /* app hook */ } });
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/** Scroll to the Pro box (call when a free user hits a limit); `from` tags the counted buy links. */
|
| 101 |
+
function upsell(reason, from) {
|
| 102 |
+
var el = box();
|
| 103 |
+
if (from) Array.prototype.forEach.call(el.querySelectorAll("a.cmx-plan"), function (a) { a.href = buyUrl(a.getAttribute("data-offer"), from); });
|
| 104 |
+
if (reason) toast(reason);
|
| 105 |
+
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
| 106 |
+
el.classList.add("cmx-pro-flash"); setTimeout(function () { el.classList.remove("cmx-pro-flash"); }, 1600);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
/** Free monthly allowance kept in this browser: quota("pdf", 5) -> {used, left, take()}. */
|
| 110 |
+
function quota(name, limit) {
|
| 111 |
+
var k = "cmx-quota:" + C.id + ":" + name, month = new Date().toISOString().slice(0, 7), q;
|
| 112 |
+
try { q = JSON.parse(localStorage.getItem(k) || "null"); } catch (e) { q = null; }
|
| 113 |
+
if (!q || q.m !== month) q = { m: month, n: 0 };
|
| 114 |
+
return {
|
| 115 |
+
used: q.n, left: Math.max(0, limit - q.n), limit: limit,
|
| 116 |
+
take: function () { if (isPro()) return true; if (q.n >= limit) return false; q.n++; try { localStorage.setItem(k, JSON.stringify(q)); } catch (e) { /* */ } this.used = q.n; this.left = Math.max(0, limit - q.n); return true; },
|
| 117 |
+
};
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
function download(name, data, type) {
|
| 121 |
+
var a = document.createElement("a");
|
| 122 |
+
a.href = URL.createObjectURL(data instanceof Blob ? data : new Blob([data], { type: type || "text/csv;charset=utf-8" }));
|
| 123 |
+
a.download = name;
|
| 124 |
+
document.body.appendChild(a); a.click(); a.remove();
|
| 125 |
+
setTimeout(function () { URL.revokeObjectURL(a.href); }, 2000);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
window.CMXPro = { isPro: isPro, onChange: function (fn) { listeners.push(fn); fn(isPro()); }, upsell: upsell, quota: quota, download: download, toast: toast };
|
| 129 |
+
|
| 130 |
+
var m = /[#&]cmx-pro=([^&]+)/.exec(location.hash || "");
|
| 131 |
+
function start() {
|
| 132 |
+
if (m && SID.test(decodeURIComponent(m[1]))) {
|
| 133 |
+
var code = decodeURIComponent(m[1]);
|
| 134 |
+
history.replaceState(null, "", location.pathname + location.search);
|
| 135 |
+
apply(); unlock(code);
|
| 136 |
+
} else { apply(); recheck(); }
|
| 137 |
+
}
|
| 138 |
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start); else start();
|
| 139 |
+
})();
|
rotasprig/robots.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
User-agent: *
|
| 2 |
+
Allow: /
|
| 3 |
+
Sitemap: https://cybermax-tools-cybermax.static.hf.space/rotasprig/sitemap.xml
|
rotasprig/sitemap.xml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://cybermax-tools-cybermax.static.hf.space/rotasprig/index.html</loc><lastmod>2026-10-02</lastmod><changefreq>monthly</changefreq></url></urlset>
|
rotasprig/style.css
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Rotasprig. © 2026 CyberMax. All rights reserved. */
|
| 2 |
+
:root{
|
| 3 |
+
--accent:#146356;--accent2:#0C443B;--ink:#11141B;--muted:#5B6170;--bg:#F6F3EC;--card:#FFFFFF;--line:#E2DED3;--field:#FFFFFF;
|
| 4 |
+
--soft:#E3F1EC;--ok:#17734F;--okbg:#DDF1E7;--over:#A33A0B;--overbg:#FCE6D6;--track:#F1ECE4;--onacc:#FFFFFF;--hatch:#EFEBE2;
|
| 5 |
+
--shadow:0 1px 2px rgba(17,20,27,.06),0 6px 24px rgba(17,20,27,.06);
|
| 6 |
+
color-scheme:light dark;
|
| 7 |
+
}
|
| 8 |
+
@media (prefers-color-scheme:dark){
|
| 9 |
+
:root{--accent:#5FD0B5;--accent2:#9BE4D1;--ink:#ECEFF3;--muted:#A3A9B6;--bg:#12151B;--card:#1B1F27;--line:#2E3440;--field:#141820;--soft:#16302A;
|
| 10 |
+
--ok:#6DD3A3;--okbg:#173126;--over:#FFB07A;--overbg:#3A2416;--track:#262B35;--onacc:#062019;--hatch:#232833;--shadow:none}
|
| 11 |
+
}
|
| 12 |
+
*{box-sizing:border-box}
|
| 13 |
+
[hidden]{display:none!important}
|
| 14 |
+
html{-webkit-text-size-adjust:100%;scroll-padding-top:70px}
|
| 15 |
+
body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif}
|
| 16 |
+
a{color:var(--accent)}
|
| 17 |
+
.wrap{max-width:1280px;margin:0 auto;padding:0 16px}
|
| 18 |
+
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
| 19 |
+
h1,h2,h3{line-height:1.2;letter-spacing:-.01em}
|
| 20 |
+
h1{font-size:clamp(1.7rem,4.4vw,2.6rem);margin:18px 0 8px;font-weight:800}
|
| 21 |
+
h2{font-size:1.15rem;margin:0}
|
| 22 |
+
:focus-visible{outline:3px solid color-mix(in srgb,var(--accent) 55%,transparent);outline-offset:2px}
|
| 23 |
+
|
| 24 |
+
/* header */
|
| 25 |
+
.top{position:sticky;top:0;z-index:20;background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:blur(8px);border-bottom:1px solid var(--line)}
|
| 26 |
+
.top-in{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:56px}
|
| 27 |
+
.brand{display:flex;align-items:center;gap:9px;text-decoration:none;color:var(--ink);font-size:1.12rem;min-width:0}
|
| 28 |
+
.brand small{color:var(--muted);font-weight:500;font-size:.78rem}
|
| 29 |
+
.top-nav{display:flex;align-items:center;gap:8px}
|
| 30 |
+
.top-link{color:var(--ink);text-decoration:none;font-weight:600;font-size:.93rem;padding:6px 4px}
|
| 31 |
+
.pill{background:var(--accent);color:var(--onacc);text-decoration:none;font-weight:800;font-size:.8rem;padding:5px 12px;border-radius:999px;letter-spacing:.02em}
|
| 32 |
+
html.cmx-pro .pill{background:transparent;color:var(--accent);border:2px solid var(--accent)}
|
| 33 |
+
|
| 34 |
+
/* hero */
|
| 35 |
+
.hero{padding:4px 0 12px}
|
| 36 |
+
.lede{font-size:1.06rem;max-width:800px;margin:0 0 14px}
|
| 37 |
+
.hero-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px}
|
| 38 |
+
.hero-note{color:var(--muted);font-size:.9rem}
|
| 39 |
+
.sel-inline select{width:auto;max-width:100%}
|
| 40 |
+
|
| 41 |
+
/* controls */
|
| 42 |
+
.btn{appearance:none;border:2px solid var(--accent);background:var(--accent);color:var(--onacc);font:inherit;font-weight:700;border-radius:10px;padding:9px 16px;cursor:pointer;text-decoration:none;display:inline-flex;align-items:center;gap:6px;line-height:1.2;justify-content:center}
|
| 43 |
+
.btn:hover{filter:brightness(1.06)}
|
| 44 |
+
.btn:disabled{opacity:.5;cursor:not-allowed}
|
| 45 |
+
.btn.ghost{background:transparent;color:var(--ink);border-color:var(--line)}
|
| 46 |
+
.btn.ghost:hover{border-color:var(--accent)}
|
| 47 |
+
.btn.sm{padding:6px 11px;font-size:.88rem;border-radius:9px}
|
| 48 |
+
.btn.danger{color:#B42318}
|
| 49 |
+
@media (prefers-color-scheme:dark){.btn.danger{color:#FF8A80}}
|
| 50 |
+
.linkbtn{appearance:none;border:0;background:none;color:var(--accent);font:inherit;font-weight:700;padding:0;cursor:pointer;text-decoration:underline}
|
| 51 |
+
.pro-tag{display:inline-block;font-size:.66rem;font-weight:800;letter-spacing:.04em;background:var(--accent);color:var(--onacc);border-radius:5px;padding:1px 5px;vertical-align:middle}
|
| 52 |
+
html.cmx-pro .pro-tag{display:none}
|
| 53 |
+
label{display:block;font-size:.84rem;font-weight:600;margin:10px 0 4px}
|
| 54 |
+
label.check{display:flex;gap:8px;align-items:center;margin-top:34px}
|
| 55 |
+
label.check input{width:auto}
|
| 56 |
+
.opt{font-weight:400;color:var(--muted)}
|
| 57 |
+
input,select,textarea{width:100%;font:inherit;font-size:16px;color:var(--ink);background:var(--field);border:1.5px solid var(--line);border-radius:9px;padding:8px 10px;min-width:0}
|
| 58 |
+
input[type=color]{padding:2px 4px;height:40px;cursor:pointer}
|
| 59 |
+
input:focus,select:focus,textarea:focus{border-color:var(--accent);outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 22%,transparent)}
|
| 60 |
+
.hint{color:var(--muted);font-size:.86rem;margin:6px 0}
|
| 61 |
+
small.hint{display:block;margin:3px 0 0;font-size:.76rem}
|
| 62 |
+
.btns{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:12px}
|
| 63 |
+
.combo{display:flex;gap:6px;align-items:center}.combo input{flex:1 1 140px}.combo select{width:auto;flex:0 1 180px}
|
| 64 |
+
.card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:14px 16px;box-shadow:var(--shadow);min-width:0}
|
| 65 |
+
.g2{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}
|
| 66 |
+
.span2{grid-column:span 2}
|
| 67 |
+
.file-btn{margin:0;cursor:pointer}
|
| 68 |
+
.limit{font-weight:700;font-size:.9rem;color:var(--muted)}
|
| 69 |
+
.limit.out{color:var(--over)}
|
| 70 |
+
.icon-btn{appearance:none;border:1.5px solid var(--line);background:var(--card);color:var(--ink);width:38px;height:38px;border-radius:9px;cursor:pointer;font-size:1.3rem;line-height:1;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto}
|
| 71 |
+
.icon-btn:hover{border-color:var(--accent);color:var(--accent)}
|
| 72 |
+
|
| 73 |
+
/* app */
|
| 74 |
+
.app{padding-bottom:10px;display:flex;flex-direction:column;gap:14px}
|
| 75 |
+
.week-bar{display:flex;flex-wrap:wrap;gap:10px 20px;align-items:flex-end}
|
| 76 |
+
.loc{flex:1 1 300px;min-width:0}
|
| 77 |
+
.loc label{margin-top:0}
|
| 78 |
+
.weeknav{display:flex;align-items:center;gap:8px}
|
| 79 |
+
.wk{display:flex;flex-direction:column;min-width:170px;text-align:center;line-height:1.25}
|
| 80 |
+
.wk b{font-size:1.05rem}.wk small{color:var(--muted);font-size:.8rem}
|
| 81 |
+
.wk-date{width:44px;padding:8px 4px;color:transparent;cursor:pointer}
|
| 82 |
+
.wk-date::-webkit-datetime-edit{display:none}
|
| 83 |
+
.wk-acts{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
|
| 84 |
+
.hist{width:auto;max-width:280px;padding:6px 8px;font-size:.9rem}
|
| 85 |
+
.limit-line{margin:10px 0 0}
|
| 86 |
+
.tabs{display:flex;flex-wrap:wrap;gap:4px;background:var(--card);border:1px solid var(--line);border-radius:12px;padding:4px;box-shadow:var(--shadow);align-self:flex-start;max-width:100%}
|
| 87 |
+
.tabs button{appearance:none;font:inherit;font-weight:700;border:0;background:transparent;color:var(--ink);padding:8px 14px;border-radius:9px;cursor:pointer}
|
| 88 |
+
.tabs button[aria-selected=true]{background:var(--accent);color:var(--onacc)}
|
| 89 |
+
.tabs button[aria-selected=true] .pro-tag{background:var(--onacc);color:var(--accent)}
|
| 90 |
+
[role=tabpanel]{display:flex;flex-direction:column;gap:14px;min-width:0}
|
| 91 |
+
.hist-head{display:flex;flex-wrap:wrap;gap:8px 14px;align-items:center;justify-content:space-between}
|
| 92 |
+
.hist-head .btns{margin:0}
|
| 93 |
+
|
| 94 |
+
/* brushes */
|
| 95 |
+
.brush-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
|
| 96 |
+
.brush-lbl{font-weight:700;font-size:.9rem}
|
| 97 |
+
.brushes{display:flex;flex-wrap:wrap;gap:6px}
|
| 98 |
+
.brush{appearance:none;font:inherit;font-size:.88rem;font-weight:700;border:1.5px solid var(--line);background:var(--bg);color:var(--ink);border-radius:999px;padding:5px 12px;cursor:pointer;font-variant-numeric:tabular-nums}
|
| 99 |
+
.brush.on{background:var(--accent);border-color:var(--accent);color:var(--onacc)}
|
| 100 |
+
.grid-hint{margin:8px 0 10px}
|
| 101 |
+
|
| 102 |
+
/* grid */
|
| 103 |
+
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
|
| 104 |
+
.grid{border-collapse:separate;border-spacing:0;width:100%;min-width:940px;font-size:.88rem;table-layout:fixed}
|
| 105 |
+
.grid col.c-name{width:168px}.grid col.c-tot{width:92px}
|
| 106 |
+
.grid th,.grid td{border-bottom:1px solid var(--line);vertical-align:top}
|
| 107 |
+
.grid thead th{position:sticky;top:0;background:var(--card);text-align:left;padding:6px 6px 8px;font-size:.82rem}
|
| 108 |
+
.g-day b{display:block;font-size:.92rem}.g-day small{color:var(--muted);font-weight:600}
|
| 109 |
+
.g-name{width:170px}
|
| 110 |
+
.g-person,.grid tfoot th{position:sticky;left:0;z-index:1;background:var(--card);text-align:left;padding:8px 8px 8px 4px}
|
| 111 |
+
.g-person{border-right:1px solid var(--line)}
|
| 112 |
+
.g-person>div{display:flex;gap:8px;align-items:flex-start;min-width:0}
|
| 113 |
+
.grid tfoot th{border-right:1px solid var(--line);font-size:.8rem;color:var(--muted)}
|
| 114 |
+
.g-person span{display:flex;flex-direction:column;min-width:0}
|
| 115 |
+
.g-person b{font-size:.92rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 116 |
+
.g-person small{color:var(--muted);font-size:.76rem;font-weight:500}
|
| 117 |
+
.dot{display:inline-block;width:12px;height:12px;border-radius:4px;flex:0 0 12px;margin-top:4px}
|
| 118 |
+
.cell{padding:4px;position:relative;min-width:0}
|
| 119 |
+
.cell.unavail{background:repeating-linear-gradient(135deg,var(--hatch) 0 6px,transparent 6px 12px)}
|
| 120 |
+
.cell.over{outline:2px dashed var(--accent);outline-offset:-3px;background:var(--soft)}
|
| 121 |
+
.na{display:block;font-size:.68rem;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;padding:0 2px 2px}
|
| 122 |
+
.chip{appearance:none;display:flex;flex-direction:column;width:100%;text-align:left;font:inherit;color:var(--ink);background:color-mix(in srgb,var(--c) 13%,var(--card));border:1.5px solid color-mix(in srgb,var(--c) 40%,transparent);border-left:5px solid var(--c);border-radius:8px;padding:4px 7px;margin-bottom:4px;cursor:grab;position:relative;line-height:1.25}
|
| 123 |
+
.chip b{font-size:.86rem;font-variant-numeric:tabular-nums;white-space:nowrap}
|
| 124 |
+
.chip small{font-size:.72rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 125 |
+
.chip.warn{border-color:var(--over);border-left-color:var(--c);box-shadow:0 0 0 1px var(--over) inset}
|
| 126 |
+
.wflag{position:absolute;top:-6px;right:-5px;font-style:normal;font-weight:900;font-size:.72rem;color:var(--onacc);background:var(--over);border-radius:50%;width:16px;height:16px;display:flex;align-items:center;justify-content:center}
|
| 127 |
+
.add{appearance:none;display:block;width:100%;min-height:30px;border:1.5px dashed var(--line);background:transparent;color:var(--muted);border-radius:8px;font:inherit;font-weight:800;cursor:pointer;opacity:.75}
|
| 128 |
+
.cell.has .add{min-height:20px;line-height:1;font-size:.8rem;border-color:transparent}
|
| 129 |
+
.cell:hover .add,.add:focus-visible{opacity:1;border-color:var(--accent);color:var(--accent)}
|
| 130 |
+
.g-tot{text-align:right;padding:8px 8px;white-space:nowrap;min-width:84px}
|
| 131 |
+
.g-tot b{display:block;font-size:.98rem}
|
| 132 |
+
.g-tot small{display:block;color:var(--muted);font-size:.74rem}
|
| 133 |
+
.g-tot.over b{color:var(--over)}
|
| 134 |
+
.grid tfoot td{padding:6px;font-variant-numeric:tabular-nums;font-size:.84rem;background:var(--bg)}
|
| 135 |
+
.num{text-align:right;font-variant-numeric:tabular-nums}
|
| 136 |
+
.grid tfoot td.num{text-align:left}
|
| 137 |
+
.grid tfoot td:last-child{text-align:right}
|
| 138 |
+
.empty{padding:24px;text-align:center;color:var(--muted)}
|
| 139 |
+
.warns{margin:12px 0 0;padding:0;list-style:none}
|
| 140 |
+
.warns li{background:var(--overbg);color:var(--over);border-radius:8px;padding:6px 10px;font-size:.88rem;margin-top:6px}
|
| 141 |
+
.warns li.ok{background:var(--okbg);color:var(--ok)}
|
| 142 |
+
.kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-top:12px}
|
| 143 |
+
.tile{border:1px solid var(--line);border-radius:12px;padding:10px 12px;background:var(--bg);display:flex;flex-direction:column;min-width:0}
|
| 144 |
+
.tile span{font-size:.78rem;color:var(--muted);font-weight:600}
|
| 145 |
+
.tile b{font-size:1.45rem;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.25}
|
| 146 |
+
.tile b.ok{color:var(--ok)}.tile b.over{color:var(--over)}
|
| 147 |
+
.tile small{font-size:.78rem;color:var(--muted)}
|
| 148 |
+
.hero-tile{background:var(--soft);border-color:color-mix(in srgb,var(--accent) 35%,var(--line))}
|
| 149 |
+
.act-row{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}
|
| 150 |
+
.act-row .btn{flex:1 1 auto}
|
| 151 |
+
.xlink{margin-top:12px}
|
| 152 |
+
|
| 153 |
+
/* team */
|
| 154 |
+
.person{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(0,1.2fr) 64px 100px 100px auto 40px;gap:6px 10px;align-items:end;padding:10px 0;border-bottom:1px dashed var(--line)}
|
| 155 |
+
.person label,.tpl label{margin:0 0 3px;font-size:.74rem;color:var(--muted)}
|
| 156 |
+
.pf-av{border:0;margin:0;padding:0;min-width:0}
|
| 157 |
+
.pf-av legend{font-size:.74rem;color:var(--muted);font-weight:600;padding:0;margin-bottom:3px}
|
| 158 |
+
.av{display:inline-flex;flex-direction:column;align-items:center;margin:0 3px 0 0;font-size:.7rem;font-weight:700;color:var(--muted)}
|
| 159 |
+
.av input{width:20px;height:20px;margin:0 0 1px;accent-color:var(--accent)}
|
| 160 |
+
.pf-del{display:flex;justify-content:flex-end}
|
| 161 |
+
.tpl{display:grid;grid-template-columns:minmax(0,1.3fr) 120px 120px 90px minmax(0,1fr) 40px;gap:6px 10px;align-items:end;padding:8px 0;border-bottom:1px dashed var(--line)}
|
| 162 |
+
.set-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0 14px}
|
| 163 |
+
|
| 164 |
+
/* coverage */
|
| 165 |
+
.inline-sel{display:flex;align-items:center;gap:8px;margin:0}
|
| 166 |
+
.inline-sel select{width:auto}
|
| 167 |
+
.cov-sum{font-size:.92rem}
|
| 168 |
+
.cov{border-collapse:separate;border-spacing:2px;font-size:.8rem;font-variant-numeric:tabular-nums}
|
| 169 |
+
.cov th{font-weight:700;color:var(--muted);padding:2px 4px;text-align:center}
|
| 170 |
+
.cov tbody th{text-align:left;color:var(--ink)}
|
| 171 |
+
.cv{width:40px;min-width:34px;height:34px;text-align:center;border-radius:4px;background:color-mix(in srgb,var(--accent) var(--p,0%),var(--card));color:var(--ink);font-weight:700}
|
| 172 |
+
.cv.z{background:var(--track)}
|
| 173 |
+
.cv.dk{color:var(--onacc)}
|
| 174 |
+
|
| 175 |
+
/* share */
|
| 176 |
+
.people{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px}
|
| 177 |
+
.pcard-s{border:1px solid var(--line);border-radius:12px;padding:10px 12px;background:var(--bg);min-width:0}
|
| 178 |
+
.pc-head{display:flex;gap:8px;align-items:center}
|
| 179 |
+
.pc-head .dot{margin-top:0}
|
| 180 |
+
.pcard-s pre{white-space:pre-wrap;font:13.5px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;margin:8px 0 0;overflow-wrap:anywhere}
|
| 181 |
+
.pcard-s .btns{margin-top:8px}
|
| 182 |
+
|
| 183 |
+
/* labour */
|
| 184 |
+
.locked{display:flex;flex-wrap:wrap;align-items:center;gap:12px;justify-content:space-between;color:var(--muted);margin-top:10px;padding:12px;border:1.5px dashed var(--line);border-radius:12px}
|
| 185 |
+
.locked p{margin:0;max-width:680px}
|
| 186 |
+
.ht{width:100%;border-collapse:collapse;font-size:.9rem;margin-top:12px}
|
| 187 |
+
.ht caption{text-align:left;font-weight:700;padding:4px 0}
|
| 188 |
+
.ht th,.ht td{padding:7px 6px;border-bottom:1px solid var(--line);text-align:left;white-space:nowrap}
|
| 189 |
+
.ht thead th{font-size:.74rem;text-transform:uppercase;letter-spacing:.03em;color:var(--muted)}
|
| 190 |
+
.ht .num{text-align:right}
|
| 191 |
+
.ht td.up{color:var(--over);font-weight:800}
|
| 192 |
+
.ht tfoot td,.ht tfoot th{font-weight:700;border-top:1.5px solid var(--ink)}
|
| 193 |
+
|
| 194 |
+
/* dialogs */
|
| 195 |
+
.dlg{border:1px solid var(--line);border-radius:16px;padding:18px 18px 14px;background:var(--card);color:var(--ink);width:min(520px,calc(100vw - 24px));box-shadow:0 20px 60px rgba(0,0,0,.25)}
|
| 196 |
+
.dlg::backdrop{background:rgba(17,20,27,.45)}
|
| 197 |
+
.dlg h2{font-size:1.2rem}
|
| 198 |
+
.dlg-acts{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
|
| 199 |
+
.tpl-quick{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:6px}
|
| 200 |
+
.tpl-quick .hint{margin:0}
|
| 201 |
+
|
| 202 |
+
/* after the app */
|
| 203 |
+
.pro-cta{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:14px;margin:22px 0;border:2px solid var(--accent);background:var(--soft)}
|
| 204 |
+
.pro-cta p{margin:6px 0 0}
|
| 205 |
+
section.how,section.compare,section.faq{margin:34px 0}
|
| 206 |
+
section.how h2,section.compare h2,section.faq h2{font-size:1.45rem;margin-bottom:12px}
|
| 207 |
+
.steps{display:grid;gap:12px;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));padding:0;margin:0;list-style:none;counter-reset:s}
|
| 208 |
+
.steps li{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:16px 16px 16px 58px;position:relative;counter-increment:s}
|
| 209 |
+
.steps li::before{content:counter(s);position:absolute;left:16px;top:14px;width:30px;height:30px;border-radius:50%;background:var(--accent);color:var(--onacc);font-weight:800;display:flex;align-items:center;justify-content:center}
|
| 210 |
+
.cmp{width:100%;border-collapse:collapse;background:var(--card);border-radius:12px;overflow:hidden;font-size:.94rem}
|
| 211 |
+
.cmp th,.cmp td{padding:10px 12px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}
|
| 212 |
+
.cmp thead th{background:var(--soft);font-size:.82rem;text-transform:uppercase;letter-spacing:.03em}
|
| 213 |
+
.cmp tr.us th,.cmp tr.us td{background:color-mix(in srgb,var(--accent) 7%,var(--card))}
|
| 214 |
+
.faq details{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:12px 16px;margin-bottom:8px}
|
| 215 |
+
.faq summary{cursor:pointer;font-weight:700}
|
| 216 |
+
.faq p{margin:8px 0 0}
|
| 217 |
+
.disclaimer{color:var(--muted);font-size:.88rem;border-left:3px solid var(--line);padding-left:12px}
|
| 218 |
+
footer.more{border-top:1px solid var(--line);margin-top:30px;padding:22px 0 40px}
|
| 219 |
+
.more-title{font-weight:800;margin-bottom:10px}
|
| 220 |
+
.more-links{display:flex;flex-wrap:wrap;gap:8px 16px;margin-bottom:16px}
|
| 221 |
+
.more-links a{text-decoration:none;font-weight:600}
|
| 222 |
+
.more-links a:hover{text-decoration:underline}
|
| 223 |
+
.copy{color:var(--muted);font-size:.88rem}
|
| 224 |
+
.toast{position:fixed;left:50%;bottom:20px;transform:translateX(-50%) translateY(20px);background:var(--ink);color:var(--bg);padding:10px 16px;border-radius:10px;font-weight:600;opacity:0;transition:.2s;z-index:50;max-width:calc(100% - 32px);pointer-events:none;text-align:center}
|
| 225 |
+
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
|
| 226 |
+
#print-area{display:none}
|
| 227 |
+
|
| 228 |
+
@media (min-width:981px){
|
| 229 |
+
.person+.person label,.person+.person legend,.tpl+.tpl label{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
| 230 |
+
.person+.person .av span{display:none}
|
| 231 |
+
.person+.person,.tpl+.tpl{padding-top:6px}
|
| 232 |
+
}
|
| 233 |
+
@media (max-width:980px){
|
| 234 |
+
.person{grid-template-columns:minmax(0,1fr) minmax(0,1fr) 64px;align-items:end}
|
| 235 |
+
.pf-rate,.pf-max{grid-column:span 1}
|
| 236 |
+
.pf-av{grid-column:1/3}
|
| 237 |
+
.pf-del{grid-column:3;align-self:end}
|
| 238 |
+
.tpl{grid-template-columns:minmax(0,1fr) minmax(0,1fr) 40px}
|
| 239 |
+
.tpl>div:nth-child(1){grid-column:1/3}
|
| 240 |
+
.set-grid{grid-template-columns:1fr 1fr}
|
| 241 |
+
.kpis{grid-template-columns:1fr 1fr}
|
| 242 |
+
}
|
| 243 |
+
@media (max-width:640px){
|
| 244 |
+
.g2{grid-template-columns:1fr}.span2{grid-column:auto}
|
| 245 |
+
.set-grid{grid-template-columns:1fr}
|
| 246 |
+
label.check{margin-top:12px}
|
| 247 |
+
.tabs{display:grid;grid-template-columns:1fr 1fr;width:100%}
|
| 248 |
+
.tabs button{padding:8px 4px;font-size:.9rem}
|
| 249 |
+
.tabs button:last-child{grid-column:1/-1}
|
| 250 |
+
.cmp thead{display:none}.cmp,.cmp tbody,.cmp tr,.cmp th,.cmp td{display:block;width:100%}
|
| 251 |
+
.cmp tr{border-bottom:1px solid var(--line);padding:6px 0}.cmp th,.cmp td{border:0;padding:3px 12px}
|
| 252 |
+
.top-link{display:none}
|
| 253 |
+
.brand small{display:none}
|
| 254 |
+
.hero-row .btn{flex:1}
|
| 255 |
+
.sel-inline{flex:1 1 100%}.sel-inline select{width:100%}
|
| 256 |
+
.weeknav{width:100%;justify-content:space-between}
|
| 257 |
+
.wk{flex:1;min-width:0}
|
| 258 |
+
.grid{min-width:960px}
|
| 259 |
+
.chip b{font-size:.76rem}.chip{padding:3px 5px}
|
| 260 |
+
.kbd-hint{display:none}
|
| 261 |
+
.grid col.c-name{width:118px}.grid col.c-tot{width:76px}
|
| 262 |
+
.tile b{font-size:1.2rem}
|
| 263 |
+
.person{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
|
| 264 |
+
.pf-name,.pf-role{grid-column:span 1}
|
| 265 |
+
.pf-col{grid-column:1}.pf-rate{grid-column:2}.pf-max{grid-column:1}
|
| 266 |
+
.pf-av{grid-column:1/-1}.pf-del{grid-column:2;grid-row:3;justify-content:flex-end}
|
| 267 |
+
.tpl{grid-template-columns:1fr 1fr}
|
| 268 |
+
.tpl>div:nth-child(1){grid-column:1/-1}
|
| 269 |
+
.act-row .btn{flex:1 1 100%}
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
/* Pro box (shared/pro-unlock/pro-plans.css) */
|
| 273 |
+
#cmx-pro.cmx-pro{border:2px solid var(--accent,#b63a10);border-radius:16px;padding:20px;margin:28px 0;background:var(--card,#fff)}
|
| 274 |
+
#cmx-pro h2{margin:0 0 8px}
|
| 275 |
+
#cmx-pro ul{margin:8px 0 14px;padding-left:20px}
|
| 276 |
+
.cmx-pro-badge{background:var(--accent,#b63a10);color:#fff;border-radius:999px;padding:2px 10px;font-size:.7em;vertical-align:middle}
|
| 277 |
+
.cmx-pro-small{font-size:.88em;opacity:.8}
|
| 278 |
+
.cmx-plans{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin:10px 0}
|
| 279 |
+
.cmx-plan{position:relative;display:flex;flex-direction:column;gap:2px;padding:14px;border:1px solid var(--line,#d9d3c7);border-radius:12px;text-decoration:none;color:inherit;background:var(--bg,#faf8f3)}
|
| 280 |
+
.cmx-plan:hover,.cmx-plan:focus{border-color:var(--accent,#b63a10);outline:none}
|
| 281 |
+
.cmx-plan.best{border:2px solid var(--accent,#b63a10)}
|
| 282 |
+
.cmx-plan i{position:absolute;top:-10px;right:10px;background:var(--accent,#b63a10);color:#fff;font-style:normal;font-size:.72em;font-weight:700;border-radius:999px;padding:2px 8px}
|
| 283 |
+
.cmx-price{font-size:1.5em;font-weight:800}
|
| 284 |
+
.cmx-price small{font-size:.55em;font-weight:600;opacity:.75}
|
| 285 |
+
.cmx-note{font-size:.82em;opacity:.75}
|
| 286 |
+
.cmx-pro-flash{animation:cmxflash 1.5s ease}
|
| 287 |
+
@keyframes cmxflash{0%,100%{box-shadow:none}30%{box-shadow:0 0 0 6px color-mix(in srgb,var(--accent,#b63a10) 35%,transparent)}}
|
| 288 |
+
#cmx-pro details{margin-top:8px}
|
| 289 |
+
#cmx-pro input{max-width:280px}
|
| 290 |
+
#cmx-pro form{display:flex;flex-wrap:wrap;gap:8px;align-items:end}
|
| 291 |
+
#cmx-pro form label{flex:1 1 220px;margin:0}
|
| 292 |
+
@media (prefers-color-scheme:dark){.cmx-pro-badge,.cmx-plan i{color:var(--onacc)}}
|
| 293 |
+
#cmx-pro{scroll-margin-top:68px}
|
| 294 |
+
|
| 295 |
+
/* printable schedule (landscape, black-and-white friendly) */
|
| 296 |
+
.psheet{color:#11141B;background:#fff;font:11px/1.35 Helvetica,Arial,sans-serif}
|
| 297 |
+
.psheet header{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;border-bottom:2px solid #11141B;padding-bottom:6px;margin-bottom:8px}
|
| 298 |
+
.psheet h1{font-size:20px;margin:0 0 2px;color:#11141B}
|
| 299 |
+
.psheet header p{margin:0;color:#3D4350}
|
| 300 |
+
.psheet table{width:100%;border-collapse:collapse;table-layout:fixed}
|
| 301 |
+
.psheet th,.psheet td{border:.8px solid #9AA0AC;padding:4px 5px;vertical-align:top;text-align:left}
|
| 302 |
+
.psheet thead th{font-size:10px;text-transform:uppercase;letter-spacing:.03em;background:#F1F1F1}
|
| 303 |
+
.psheet .ps-name{width:15%;border-left:4px solid #11141B}
|
| 304 |
+
.psheet th.ps-name b{display:block;font-size:11.5px}
|
| 305 |
+
.psheet th.ps-name small{display:block;font-weight:400;color:#3D4350;font-size:9.5px}
|
| 306 |
+
.psheet thead .ps-name,.psheet tfoot .ps-name{border-left-color:#9AA0AC}
|
| 307 |
+
.psheet th.num,.psheet td.num{width:7%;text-align:right}
|
| 308 |
+
.ps-shift{margin-bottom:3px}
|
| 309 |
+
.ps-shift b{display:block;font-size:11.5px;font-variant-numeric:tabular-nums}
|
| 310 |
+
.ps-shift small{display:block;color:#3D4350;font-size:9.5px}
|
| 311 |
+
.ps-off{color:#8A8F9C}
|
| 312 |
+
.psheet tfoot td,.psheet tfoot th{font-weight:700;background:#F7F7F7}
|
| 313 |
+
.ps-foot{display:flex;justify-content:space-between;gap:12px;margin:8px 0 0;color:#5B6170;font-size:9.5px}
|
| 314 |
+
|
| 315 |
+
@media print{
|
| 316 |
+
html,body{background:#fff!important;color:#11141B}
|
| 317 |
+
body>*{display:none!important}
|
| 318 |
+
body>#print-area{display:block!important}
|
| 319 |
+
tr{break-inside:avoid}
|
| 320 |
+
.psheet thead{display:table-header-group}
|
| 321 |
+
}
|
| 322 |
+
.grid thead th.g-name{position:sticky;left:0;z-index:2;border-right:1px solid var(--line)}
|
rotasprig/sw.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Rotasprig offline cache. © 2026 CyberMax. All rights reserved. */
|
| 2 |
+
var CACHE = "rotasprig-v1";
|
| 3 |
+
var FILES = ["./", "index.html", "style.css", "pro.js", "lib/rota.js", "app.js", "manifest.webmanifest", "icon.svg", "icon-192.png", "icon-512.png"];
|
| 4 |
+
self.addEventListener("install", function (e) {
|
| 5 |
+
e.waitUntil(caches.open(CACHE).then(function (c) { return c.addAll(FILES); }).then(function () { return self.skipWaiting(); }));
|
| 6 |
+
});
|
| 7 |
+
self.addEventListener("activate", function (e) {
|
| 8 |
+
e.waitUntil(caches.keys().then(function (keys) {
|
| 9 |
+
return Promise.all(keys.filter(function (k) { return k.indexOf("rotasprig-") === 0 && k !== CACHE; }).map(function (k) { return caches.delete(k); }));
|
| 10 |
+
}).then(function () { return self.clients.claim(); }));
|
| 11 |
+
});
|
| 12 |
+
self.addEventListener("fetch", function (e) {
|
| 13 |
+
var req = e.request, url = new URL(req.url);
|
| 14 |
+
if (req.method !== "GET" || url.origin !== location.origin) return;
|
| 15 |
+
var scope = new URL(self.registration.scope);
|
| 16 |
+
if (url.pathname.indexOf(scope.pathname) !== 0) return;
|
| 17 |
+
if (req.mode === "navigate") {
|
| 18 |
+
// Network first for pages so updates arrive quickly; the cached page works offline.
|
| 19 |
+
e.respondWith(fetch(req).then(function (r) {
|
| 20 |
+
var copy = r.clone(); caches.open(CACHE).then(function (c) { c.put("index.html", copy); });
|
| 21 |
+
return r;
|
| 22 |
+
}).catch(function () { return caches.match("index.html"); }));
|
| 23 |
+
return;
|
| 24 |
+
}
|
| 25 |
+
// Cache first for static files in this app's folder, refreshed in the background.
|
| 26 |
+
e.respondWith(caches.match(req, { ignoreSearch: true }).then(function (hit) {
|
| 27 |
+
var net = fetch(req).then(function (r) {
|
| 28 |
+
if (r && r.ok) { var copy = r.clone(); caches.open(CACHE).then(function (c) { c.put(req, copy); }); }
|
| 29 |
+
return r;
|
| 30 |
+
});
|
| 31 |
+
if (hit) { net.catch(function () { /* offline */ }); return hit; }
|
| 32 |
+
return net;
|
| 33 |
+
}));
|
| 34 |
+
});
|