Spaces:
Running
Running
Deploy billsprig to the hub
Browse files- billsprig/app.js +25 -0
- billsprig/index.html +4 -4
- billsprig/pro.js +8 -8
- billsprig/sw.js +1 -1
billsprig/app.js
CHANGED
|
@@ -474,6 +474,31 @@
|
|
| 474 |
window.addEventListener("load", function () { navigator.serviceWorker.register("sw.js").catch(function () { /* offline cache is optional */ }); });
|
| 475 |
}
|
| 476 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
/* ---------- start ---------- */
|
| 478 |
fillSelects();
|
| 479 |
toForm();
|
|
|
|
| 474 |
window.addEventListener("load", function () { navigator.serviceWorker.register("sw.js").catch(function () { /* offline cache is optional */ }); });
|
| 475 |
}
|
| 476 |
|
| 477 |
+
/* ---------- trade template from a link: #preset=<URL-encoded JSON> (cybermaxtools.com/invoice-templates/<trade>/) ----------
|
| 478 |
+
* {"title": "Plumbing invoice", "items": [["Call-out fee", "1"], ...], "terms": "Net 14", "notes": "..."}. Rates stay empty:
|
| 479 |
+
* the person types their own prices. Nothing leaves the browser. */
|
| 480 |
+
function applyPreset() {
|
| 481 |
+
var m = /[#&]preset=([^&]+)/.exec(location.hash || "");
|
| 482 |
+
if (!m) return;
|
| 483 |
+
history.replaceState(null, "", location.pathname + location.search);
|
| 484 |
+
var p;
|
| 485 |
+
try { p = JSON.parse(decodeURIComponent(m[1])); } catch (e) { return; }
|
| 486 |
+
if (!p || !Array.isArray(p.items) || !p.items.length) return;
|
| 487 |
+
var cur = S.doc, mine = cur && cur.to && String(cur.to.name || "").trim() && cur.number !== "INV-0042";
|
| 488 |
+
if (mine && !window.confirm("Replace your current draft with the " + String(p.title || "trade") + " template? Save it to history first if you need it.")) return;
|
| 489 |
+
var d = newDoc("invoice");
|
| 490 |
+
d.items = p.items.slice(0, 30).map(function (r) {
|
| 491 |
+
var q = String((r && r[1]) || "1").slice(0, 12);
|
| 492 |
+
return { desc: String((r && r[0]) || "").slice(0, 200), qty: /^\d+(\.\d+)?$/.test(q) ? q : "1", rate: "", tax: "", disc: "" };
|
| 493 |
+
});
|
| 494 |
+
if (typeof p.terms === "string" && p.terms.length < 40) { d.terms = p.terms; var td = C.termDays(d.terms); if (td != null) d.due = C.addDays(d.date, td); }
|
| 495 |
+
if (typeof p.notes === "string") d.notes = p.notes.slice(0, 600);
|
| 496 |
+
S.doc = doc = d;
|
| 497 |
+
save();
|
| 498 |
+
setTimeout(function () { toast((p.title ? String(p.title).slice(0, 60) + " loaded" : "Template loaded") + ". Type your own rates, then add your business and client."); }, 400);
|
| 499 |
+
}
|
| 500 |
+
applyPreset();
|
| 501 |
+
|
| 502 |
/* ---------- start ---------- */
|
| 503 |
fillSelects();
|
| 504 |
toForm();
|
billsprig/index.html
CHANGED
|
@@ -247,9 +247,9 @@
|
|
| 247 |
<a href="https://cybermax-tools-cybermax.static.hf.space/menumoor/index.html" target="_blank" rel="noopener">Menumoor · menus & price lists</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-tools-cybermax.static.hf.space/profit-margin-calculator/index.html" target="_blank" rel="noopener">Profit margin calculator</a>
|
| 250 |
-
<a href="https://noticewright.
|
| 251 |
-
<a href="https://scanmoor.
|
| 252 |
-
<a href="https://
|
| 253 |
</div>
|
| 254 |
<div class="copy">© 2026 CyberMax. All rights reserved. · Support: <a href="mailto:cybermax.tools@gmail.com">cybermax.tools@gmail.com</a></div>
|
| 255 |
</footer>
|
|
@@ -266,5 +266,5 @@
|
|
| 266 |
<script src="lib/calc.js"></script>
|
| 267 |
<script src="lib/pdf.js"></script>
|
| 268 |
<script src="app.js"></script>
|
| 269 |
-
<
|
| 270 |
</html>
|
|
|
|
| 247 |
<a href="https://cybermax-tools-cybermax.static.hf.space/menumoor/index.html" target="_blank" rel="noopener">Menumoor · menus & price lists</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-tools-cybermax.static.hf.space/profit-margin-calculator/index.html" target="_blank" rel="noopener">Profit margin calculator</a>
|
| 250 |
+
<a href="https://noticewright.cybermaxtools.com/" target="_blank" rel="noopener">Noticewright · privacy policy generator</a>
|
| 251 |
+
<a href="https://scanmoor.cybermaxtools.com/" target="_blank" rel="noopener">Scanmoor · QR codes</a>
|
| 252 |
+
<a href="https://cybermaxtools.com/store/?utm_source=billsprig&utm_medium=more-from" target="_blank" rel="noopener">CyberMax Store</a>
|
| 253 |
</div>
|
| 254 |
<div class="copy">© 2026 CyberMax. All rights reserved. · Support: <a href="mailto:cybermax.tools@gmail.com">cybermax.tools@gmail.com</a></div>
|
| 255 |
</footer>
|
|
|
|
| 266 |
<script src="lib/calc.js"></script>
|
| 267 |
<script src="lib/pdf.js"></script>
|
| 268 |
<script src="app.js"></script>
|
| 269 |
+
</body>
|
| 270 |
</html>
|
billsprig/pro.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 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.
|
| 6 |
-
* After checkout Stripe sends the buyer to data.
|
| 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).
|
|
@@ -13,9 +13,9 @@
|
|
| 13 |
"use strict";
|
| 14 |
var C = window.CMX_PRO || {};
|
| 15 |
if (!C.id) return;
|
| 16 |
-
var DATA = "https://data.
|
| 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 |
|
|
@@ -60,7 +60,7 @@
|
|
| 60 |
|
| 61 |
// Convert kit (funnel beacons, real proof, email capture, phone buy bar), loaded from the CyberMax Store; optional:
|
| 62 |
// if it can't load (offline), the app and the Pro box work exactly the same.
|
| 63 |
-
var KIT = "https://
|
| 64 |
function conv(fn) {
|
| 65 |
if (window.CMXConvert) return fn(window.CMXConvert);
|
| 66 |
kitQ.push(fn);
|
|
@@ -99,15 +99,15 @@
|
|
| 99 |
el.innerHTML = '<h2>' + esc(C.name) + ' Pro</h2>' + (C.free ? '<p class="cmx-pro-small">Free: ' + esc(C.free) + "</p>" : "") +
|
| 100 |
"<ul>" + C.perks.map(function (p) { return "<li>" + esc(p) + "</li>"; }).join("") + '</ul><div class="cmx-plans">' + plans +
|
| 101 |
'</div><p class="cmx-pro-small">Secure Stripe checkout. Pro turns on the moment you pay; no account needed.' + (subs ? " Subscriptions cancel any time from your receipt email." : " One payment, no subscription.") +
|
| 102 |
-
' 14-day promise: if it doesn\'t work as described, we fix it or refund you in full (<a href="https://
|
| 103 |
-
'<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>';
|
| 104 |
Array.prototype.forEach.call(el.querySelectorAll("a.cmx-plan"), function (a) { a.addEventListener("click", function () { conv(function (K) { K.event("upgrade-click", C.id); }); }); });
|
| 105 |
conv(function (K) {
|
| 106 |
K.proof(el.querySelector(".cmx-pro-proof"), C.id);
|
| 107 |
K.capture(el.querySelector(".cmx-pro-cap"), { list: "weekly-" + C.id, src: "app-" + C.id, label: "Not ready for Pro? Email me " + C.name + " tips and new features (about once a week)" });
|
| 108 |
});
|
| 109 |
var f = document.getElementById("cmx-pro-form");
|
| 110 |
-
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_)."); };
|
| 111 |
}
|
| 112 |
|
| 113 |
function apply() {
|
|
|
|
| 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.cybermaxtools.com/buy/<offer>?s=app-<id> -> Stripe Payment Link.
|
| 6 |
+
* After checkout Stripe sends the buyer to data.cybermaxtools.com/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).
|
|
|
|
| 13 |
"use strict";
|
| 14 |
var C = window.CMX_PRO || {};
|
| 15 |
if (!C.id) return;
|
| 16 |
+
var DATA = "https://data.cybermaxtools.com";
|
| 17 |
var KEY = "cmx-pro:" + C.id;
|
| 18 |
+
var SID = /^(cs_(live|test)_[A-Za-z0-9]{10,200}|[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})$/i; // Stripe order code or Gumroad licence key
|
| 19 |
var RECHECK = 3 * 864e5;
|
| 20 |
var listeners = [];
|
| 21 |
|
|
|
|
| 60 |
|
| 61 |
// Convert kit (funnel beacons, real proof, email capture, phone buy bar), loaded from the CyberMax Store; optional:
|
| 62 |
// if it can't load (offline), the app and the Pro box work exactly the same.
|
| 63 |
+
var KIT = "https://cybermaxtools.com/store/convert.js", kitQ = [];
|
| 64 |
function conv(fn) {
|
| 65 |
if (window.CMXConvert) return fn(window.CMXConvert);
|
| 66 |
kitQ.push(fn);
|
|
|
|
| 99 |
el.innerHTML = '<h2>' + esc(C.name) + ' Pro</h2>' + (C.free ? '<p class="cmx-pro-small">Free: ' + esc(C.free) + "</p>" : "") +
|
| 100 |
"<ul>" + C.perks.map(function (p) { return "<li>" + esc(p) + "</li>"; }).join("") + '</ul><div class="cmx-plans">' + plans +
|
| 101 |
'</div><p class="cmx-pro-small">Secure Stripe checkout. Pro turns on the moment you pay; no account needed.' + (subs ? " Subscriptions cancel any time from your receipt email." : " One payment, no subscription.") +
|
| 102 |
+
' 14-day promise: if it doesn\'t work as described, we fix it or refund you in full (<a href="https://cybermaxtools.com/terms#payments" target="_blank" rel="noopener">terms</a>). Questions: <a href="mailto:cybermax.tools@gmail.com">cybermax.tools@gmail.com</a></p><div class="cmx-pro-proof"></div><div class="cmx-pro-cap"></div>' +
|
| 103 |
+
'<details><summary>Already bought Pro?</summary><form id="cmx-pro-form"><label>Unlock code <input id="cmx-pro-code" autocomplete="off" placeholder="cs_live_… or Gumroad licence key"></label> <button class="btn ghost" type="submit">Unlock</button></form></details><p id="cmx-pro-msg" class="cmx-pro-small" aria-live="polite"></p>';
|
| 104 |
Array.prototype.forEach.call(el.querySelectorAll("a.cmx-plan"), function (a) { a.addEventListener("click", function () { conv(function (K) { K.event("upgrade-click", C.id); }); }); });
|
| 105 |
conv(function (K) {
|
| 106 |
K.proof(el.querySelector(".cmx-pro-proof"), C.id);
|
| 107 |
K.capture(el.querySelector(".cmx-pro-cap"), { list: "weekly-" + C.id, src: "app-" + C.id, label: "Not ready for Pro? Email me " + C.name + " tips and new features (about once a week)" });
|
| 108 |
});
|
| 109 |
var f = document.getElementById("cmx-pro-form");
|
| 110 |
+
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_) or your Gumroad licence key."); };
|
| 111 |
}
|
| 112 |
|
| 113 |
function apply() {
|
billsprig/sw.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
/* Billsprig offline cache. © 2026 CyberMax. All rights reserved. */
|
| 2 |
-
var CACHE = "billsprig-
|
| 3 |
var FILES = ["./", "index.html", "style.css", "pro.js", "lib/calc.js", "lib/pdf.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(); }));
|
|
|
|
| 1 |
/* Billsprig offline cache. © 2026 CyberMax. All rights reserved. */
|
| 2 |
+
var CACHE = "billsprig-v2";
|
| 3 |
var FILES = ["./", "index.html", "style.css", "pro.js", "lib/calc.js", "lib/pdf.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(); }));
|