From 9e543bec1a1ebee76c24df6b459963110ade8449 Mon Sep 17 00:00:00 2001 From: shaebali Date: Sat, 19 Sep 2026 00:29:43 +0000 Subject: [PATCH] Period totals footer, category reorder, mobile fixes, PWA with update prompt --- Dockerfile | 2 +- README.md | 10 ++- app.js | 109 ++++++++++++++++++++++--- expo-app/App.js | 65 ++++++++++++--- expo-app/README.md | 2 +- expo-app/src/categories.js | 9 ++ expo-app/src/components/ExpenseForm.js | 4 +- expo-app/src/storage.js | 19 +++++ expo-app/src/styles.js | 3 + icon-192.png | Bin 0 -> 1403 bytes icon-512.png | Bin 0 -> 3822 bytes index.html | 65 ++++++++++++--- manifest.json | 15 ++++ styles.css | 31 +++++++ sw.js | 49 +++++++++++ 15 files changed, 339 insertions(+), 44 deletions(-) create mode 100644 icon-192.png create mode 100644 icon-512.png create mode 100644 manifest.json create mode 100644 sw.js diff --git a/Dockerfile b/Dockerfile index 9e42103..f2b005d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ FROM nginx:alpine -COPY index.html styles.css app.js /usr/share/nginx/html/ +COPY index.html styles.css app.js manifest.json sw.js icon-192.png icon-512.png /usr/share/nginx/html/ EXPOSE 80 diff --git a/README.md b/README.md index 09e97a1..0b89d9d 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,12 @@ To use another port: `PORT=8080 python3 server.py`. ## Features - **Sidebar views** — Daily, Weekly, Monthly and All expenses with live counts, each group with its own total. -- **Categories** — Food, Transport, Household, Utilities, Shopping, Health, Beauty, Entertainment, Other. +- **Categories** — Food, Transport, Household, Utilities, Shopping, Health, Beauty, Entertainment, Other. Drag them up or down to rearrange; the order is remembered. +- **Period totals** — the sidebar footer shows total spending for today, this week or this month at a tap. - **Repeats** — mark an expense Daily, Weekly or Monthly. Repeating entries appear under “Repeating expenses” with the next due date and a one-click **Log next occurrence** button. - **Summary** — totals plus a per-category spending breakdown for whatever is shown. - **INR amounts** — everything is shown in rupees (₹) with Indian digit grouping. -- **Search and filters** — by text, category and repeat type. +- **Search and filters** — by text and category. - **Edit / delete** — every entry can be changed or removed. - **Sample data** — realistic entries are loaded on first run so each view has content. Use **Clear all** to start empty and **Load sample data** to add them back. @@ -38,6 +39,11 @@ Cloudflare caches `app.js`/`styles.css` at the edge, so every deploy that changes them must bump the `?v=` query in `index.html` or visitors keep getting the old files until the edge entry expires. +The app is also a PWA: `sw.js` caches the shell for offline use and shows an +"Update to latest version" button when a deploy ships. Every deploy that +changes the app must bump the `CACHE` name in `sw.js` (`tally-v3`, `tally-v4`, +…) or installed clients never see the update. + ## Files - `index.html` — page structure diff --git a/app.js b/app.js index 034ea45..dfa6cd1 100644 --- a/app.js +++ b/app.js @@ -18,8 +18,37 @@ var CATS = { var FREQ_LABEL = { once: "One-time", daily: "Daily", weekly: "Weekly", monthly: "Monthly" }; var STORE_KEY = "expense-tracker.expenses.v1"; +var ORDER_KEY = "expense-tracker.catorder.v1"; -var state = { tab: "daily", q: "", cat: "all", freq: "all", editingId: null, screen: "add", selMonth: null, selYear: null, selWeek: null, selDate: null }; +/* Category order, persisted so drag-reorder survives reloads. Unknown saved + names are dropped; new categories append in their default position. */ +function getCatOrder() { + var names = Object.keys(CATS); + try { + var saved = JSON.parse(localStorage.getItem(ORDER_KEY) || "[]"); + if (!Array.isArray(saved)) return names; + var known = saved.filter(function (n) { return CATS[n] !== undefined; }); + names.forEach(function (n) { if (known.indexOf(n) === -1) known.push(n); }); + return known; + } catch (e) { + return names; + } +} + +function saveCatOrder(names) { + try { localStorage.setItem(ORDER_KEY, JSON.stringify(names)); } catch (e) { /* session-only order */ } +} + +function refillCatOptions() { + var sel = $("fCat"); + var cur = sel.value; + sel.innerHTML = getCatOrder().map(function (c) { + return '"; + }).join(""); + sel.value = cur; +} + +var state = { tab: "daily", q: "", cat: "all", period: "month", editingId: null, screen: "add", selMonth: null, selYear: null, selWeek: null, selDate: null }; var MONTHS_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; /* All amounts display in INR. */ @@ -170,7 +199,6 @@ function filtered(list) { if (mondayOf(e.date) !== state.selWeek) return false; } if (state.cat !== "all" && e.category !== state.cat) return false; - if (state.freq !== "all" && e.frequency !== state.freq) return false; if (q && (e.description + " " + e.category).toLowerCase().indexOf(q) === -1) return false; return true; }); @@ -335,23 +363,77 @@ function renderNav(list) { $("countWeekly").textContent = c.weekly; $("countMonthly").textContent = c.monthly; $("countAll").textContent = c.all; - var names = Object.keys(CATS); + var names = getCatOrder(); var html = '
  • "; html += names.map(function (n) { - return '
  • "; }).join(""); $("catList").innerHTML = html; - var m = 0; - list.forEach(function (e) { if (e.date.slice(0, 7) === mo) m += e.amount; }); - $("sideMonth").textContent = money.format(m); + var d = 0, w = 0, m = 0; + list.forEach(function (e) { + if (e.date === t) d += e.amount; + if (mondayOf(e.date) === wk) w += e.amount; + if (e.date.slice(0, 7) === mo) m += e.amount; + }); + var labels = { day: "Today", week: "This week", month: "This month" }; + var totals = { day: d, week: w, month: m }; + $("periodLabel").textContent = labels[state.period] || labels.month; + $("sideMonth").textContent = money.format(totals[state.period] === undefined ? m : totals[state.period]); + Array.prototype.forEach.call(document.querySelectorAll("[data-period]"), function (b) { + b.classList.toggle("active", b.getAttribute("data-period") === state.period); + }); $("topMonth").textContent = money.format(m); } +/* Drag-to-reorder for the sidebar categories. Only the named categories move; + "All categories" stays pinned at the top. */ +var dragName = null; +function wireCatDnD() { + var list = $("catList"); + list.addEventListener("dragstart", function (e) { + var li = e.target.closest("li[data-order]"); + if (!li) { e.preventDefault(); return; } + dragName = li.getAttribute("data-order"); + e.dataTransfer.effectAllowed = "move"; + try { e.dataTransfer.setData("text/plain", dragName); } catch (err) { /* some browsers need the try */ } + li.classList.add("dragging"); + }); + list.addEventListener("dragend", function () { + dragName = null; + Array.prototype.forEach.call(list.querySelectorAll(".dragging, .drag-over"), function (el) { + el.classList.remove("dragging", "drag-over"); + }); + }); + list.addEventListener("dragover", function (e) { + var li = e.target.closest("li[data-order]"); + if (!li || !dragName) return; + e.preventDefault(); + e.dataTransfer.dropEffect = "move"; + Array.prototype.forEach.call(list.querySelectorAll(".drag-over"), function (el) { + if (el !== li) el.classList.remove("drag-over"); + }); + li.classList.add("drag-over"); + }); + list.addEventListener("drop", function (e) { + var li = e.target.closest("li[data-order]"); + if (!li || !dragName) return; + e.preventDefault(); + var target = li.getAttribute("data-order"); + if (target === dragName) return; + var names = getCatOrder(); + names.splice(names.indexOf(dragName), 1); + names.splice(names.indexOf(target), 0, dragName); + saveCatOrder(names); + refillCatOptions(); + renderAll(); + }); +} + /* Landing shows only the add form; records live behind the menu drawer. */ var RECORD_SECTIONS = ["viewHead", "statsSection", "sumCard", "listSection", "templatesCard"]; @@ -489,10 +571,7 @@ function showErr(msg) { } function init() { - var catSel = $("fCat"); - catSel.innerHTML = Object.keys(CATS).map(function (c) { - return '"; - }).join(""); + refillCatOptions(); $("fDate").value = todayStr(); document.querySelectorAll(".nav-item[data-tab]").forEach(function (btn) { @@ -591,7 +670,13 @@ function init() { } $("datePicker").addEventListener("change", function (e) { pickDateInput(e.target.closest("[data-dinput]")); }); $("datePicker").addEventListener("input", function (e) { pickDateInput(e.target.closest("[data-dinput]")); }); - $("fFreqFilter").addEventListener("change", function (e) { state.freq = e.target.value; renderAll(); }); + document.querySelector(".period-pick").addEventListener("click", function (e) { + var b = e.target.closest("[data-period]"); + if (!b) return; + state.period = b.getAttribute("data-period"); + renderAll(); + }); + wireCatDnD(); $("expForm").addEventListener("submit", function (e) { e.preventDefault(); diff --git a/expo-app/App.js b/expo-app/App.js index e5a6276..1bf4bd3 100644 --- a/expo-app/App.js +++ b/expo-app/App.js @@ -9,7 +9,7 @@ import ExpenseForm from "./src/components/ExpenseForm"; import ExpenseGroups from "./src/components/ExpenseGroups"; import RepeatTemplates from "./src/components/RepeatTemplates"; import SummaryBars from "./src/components/SummaryBars"; -import { CATEGORIES } from "./src/categories"; +import { CATEGORIES, applyCatOrder } from "./src/categories"; import { addDaysStr, groupKey, @@ -21,7 +21,7 @@ import { todayStr, uid, } from "./src/logic"; -import { loadExpenses, saveExpenses } from "./src/storage"; +import { loadExpenses, saveExpenses, loadCatOrder, saveCatOrder } from "./src/storage"; import s from "./src/styles"; const TABS = ["daily", "weekly", "monthly"]; @@ -37,7 +37,9 @@ export default function App() { const [tab, setTab] = useState("daily"); const [query, setQuery] = useState(""); const [catFilter, setCatFilter] = useState("all"); - const [freqFilter, setFreqFilter] = useState("all"); + const [period, setPeriod] = useState("month"); + const [catOrder, setCatOrder] = useState(null); + const [arranging, setArranging] = useState(false); const [editingId, setEditingId] = useState(null); const [pendingDeleteId, setPendingDeleteId] = useState(null); const currency = "INR"; @@ -52,6 +54,7 @@ export default function App() { setExpenses(list); setReady(true); }); + loadCatOrder().then(setCatOrder); }, []); function update(list) { @@ -103,11 +106,10 @@ export default function App() { const q = query.trim().toLowerCase(); return expenses.filter((e) => { if (catFilter !== "all" && e.category !== catFilter) return false; - if (freqFilter !== "all" && e.frequency !== freqFilter) return false; if (q && (e.description + " " + e.category).toLowerCase().indexOf(q) === -1) return false; return true; }); - }, [expenses, query, catFilter, freqFilter]); + }, [expenses, query, catFilter]); const groups = useMemo(() => { const map = {}; @@ -144,6 +146,21 @@ export default function App() { return { d, w, m, counts: { daily: dc, weekly: wc, monthly: mc }, catCounts: cats }; }, [expenses]); + const orderedCats = useMemo(() => applyCatOrder(CATEGORIES, catOrder), [catOrder]); + const periodTotal = period === "day" ? stats.d : period === "week" ? stats.w : stats.m; + const periodNoun = period === "day" ? "today" : period === "week" ? "this week" : "this month"; + + function moveCat(index, dir) { + const names = orderedCats.map((c) => c.name); + const j = index + dir; + if (j < 0 || j >= names.length) return; + const t = names[index]; + names[index] = names[j]; + names[j] = t; + setCatOrder(names); + saveCatOrder(names); + } + function editExpense(id) { setEditingId(id); setPendingDeleteId(null); @@ -161,7 +178,7 @@ export default function App() { {menuOpen ? "\u2715" : "\u2630"} - {money(stats.m, currency)} this month + {money(periodTotal, currency)} {periodNoun} @@ -183,6 +200,7 @@ export default function App() { : blankForm() } submitLabel={editing ? "Save changes" : "Add expense"} + categories={orderedCats} onSubmit={submitForm} onCancel={editing ? () => setEditingId(null) : null} currency={currency} @@ -226,20 +244,41 @@ export default function App() { setCatFilter("all")} style={[s.chip, catFilter === "all" && s.chipActive]}> All - {CATEGORIES.map((c) => ( + {orderedCats.map((c) => ( setCatFilter(c.name)} style={[s.chip, catFilter === c.name && s.chipActive]}> {"\u25cf"} {c.name} {"\u00b7"} {stats.catCounts[c.name] || 0} ))} - Repeats + setArranging(!arranging)} style={[s.btn, s.btnSubtle, s.btnSmall, { alignSelf: "flex-start", marginTop: 8 }]}> + {arranging ? "Done" : "Arrange"} + + {arranging ? ( + + {orderedCats.map((c, i) => ( + + + {"\u25cf "} + {c.name} + + + moveCat(i, -1)} disabled={i === 0} style={[s.btn, s.btnSubtle, s.btnSmall]}> + {"\u2191"} + + moveCat(i, 1)} disabled={i === orderedCats.length - 1} style={[s.btn, s.btnSubtle, s.btnSmall]}> + {"\u2193"} + + + + ))} + + ) : null} + Total for - {["all", "once", "daily", "weekly", "monthly"].map((f) => ( - setFreqFilter(f)} style={[s.chip, freqFilter === f && s.chipActive]}> - - {f === "all" ? "All" : f === "once" ? "One-time" : f.charAt(0).toUpperCase() + f.slice(1)} - + {[["day", "Today"], ["week", "Week"], ["month", "Month"]].map(([p, label]) => ( + setPeriod(p)} style={[s.chip, period === p && s.chipActive]}> + {label} ))} diff --git a/expo-app/README.md b/expo-app/README.md index 8bcecc0..3516f49 100644 --- a/expo-app/README.md +++ b/expo-app/README.md @@ -12,7 +12,7 @@ working as before; this folder is the future-proof rewrite. - **Daily / Weekly / Monthly tabs** — the same expenses regrouped by day, by week (Monday–Sunday) or by month, each group with its own total. - **Categories** — Food, Transport, Household, Utilities, Shopping, Health, - Beauty, Entertainment, Other. + Beauty, Entertainment, Other. Tap Arrange to reorder them with ↑ ↓. - **Repeats** — mark an expense Daily, Weekly or Monthly. They appear under “Repeating expenses” with the next due date and a **Log next occurrence** button. - **Summary** — totals plus a per-category spending breakdown of whatever is shown. diff --git a/expo-app/src/categories.js b/expo-app/src/categories.js index 72a99ac..2d5d982 100644 --- a/expo-app/src/categories.js +++ b/expo-app/src/categories.js @@ -16,3 +16,12 @@ export function colorFor(category) { const found = CATEGORIES.find((c) => c.name === category); return found ? found.color : "#c9c9c9"; } + +export function applyCatOrder(list, saved) { + if (!Array.isArray(saved)) return list; + const byName = {}; + list.forEach((c) => { byName[c.name] = c; }); + const ordered = saved.filter((n) => byName[n]).map((n) => byName[n]); + list.forEach((c) => { if (ordered.indexOf(c) === -1) ordered.push(c); }); + return ordered; +} diff --git a/expo-app/src/components/ExpenseForm.js b/expo-app/src/components/ExpenseForm.js index 1f9ce38..a6bc353 100644 --- a/expo-app/src/components/ExpenseForm.js +++ b/expo-app/src/components/ExpenseForm.js @@ -15,7 +15,7 @@ function Chip({ label, active, onPress, dot }) { ); } -export default function ExpenseForm({ initial, submitLabel, onSubmit, onCancel, currency }) { +export default function ExpenseForm({ initial, submitLabel, onSubmit, onCancel, currency, categories = CATEGORIES }) { const [desc, setDesc] = useState(initial.description); const [amount, setAmount] = useState(initial.amount); const [cat, setCat] = useState(initial.category); @@ -61,7 +61,7 @@ export default function ExpenseForm({ initial, submitLabel, onSubmit, onCancel, Category - {CATEGORIES.map((c) => ( + {categories.map((c) => ( setCat(c.name)} /> ))} diff --git a/expo-app/src/storage.js b/expo-app/src/storage.js index d8e8f83..474c8a1 100644 --- a/expo-app/src/storage.js +++ b/expo-app/src/storage.js @@ -4,6 +4,25 @@ import AsyncStorage from "@react-native-async-storage/async-storage"; import { seedSamples } from "./logic"; const KEY = "expense-tracker.expenses.v1"; +const ORDER_KEY = "expense-tracker.catorder.v1"; + +export async function loadCatOrder() { + try { + const raw = await AsyncStorage.getItem(ORDER_KEY); + const arr = JSON.parse(raw || "[]"); + return Array.isArray(arr) ? arr : null; + } catch (e) { + return null; + } +} + +export async function saveCatOrder(names) { + try { + await AsyncStorage.setItem(ORDER_KEY, JSON.stringify(names)); + } catch (e) { + // Storage unavailable; the in-memory order still works this session. + } +} export async function loadExpenses() { try { diff --git a/expo-app/src/styles.js b/expo-app/src/styles.js index 1cbd17e..e500edb 100644 --- a/expo-app/src/styles.js +++ b/expo-app/src/styles.js @@ -64,6 +64,9 @@ export default StyleSheet.create({ chipText: { color: palette.muted, fontWeight: "400", fontSize: 13, fontFamily: SUB }, chipCount: { fontSize: 13, fontFamily: BODY }, chipTextActive: { color: "#fff" }, + arrangeRow: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingVertical: 6, borderTopWidth: 1, borderTopColor: palette.line }, + arrangeName: { fontSize: 15, color: palette.ink, fontFamily: SUB }, + arrangeBtns: { flexDirection: "row", gap: 6 }, chipRow: { marginBottom: 4 }, btnRow: { flexDirection: "row", gap: 8, marginTop: 14 }, diff --git a/icon-192.png b/icon-192.png new file mode 100644 index 0000000000000000000000000000000000000000..b2637b32f2b7ea2da331f05632a223b8efd517f4 GIT binary patch literal 1403 zcmaJ>X;4#F6uvKn7{drwEVd>>+#oXrL`5S@LQoV?z*j*cD5!uM5m7SGkVxojF_s2! z(8Piw5D>IwDOHLXmY^900a>&x5(o?sus|aaWr>8)7yGleKkm76zWL_PIp==o`w{l@ zTtQe%006A;_VPG{-j59jk3pkSwg3ZQyxZHuJs@78Rt_Ba{4DA5pgw%PTwuT9@`+Pp zyOUW@QceX?R(403m%r!>^cS;R;!6Ac^+h!+0}E1Wv-oE`Bfn+k+6x@)0rs|HHwii}8{tV_~PI zuel+*X<5{T;`oQbeYfm*p1xO|oZJ~14Z@5vQ|5S`prU%VU4<9@fqmck^nS|BoGdYd z?TMzbi3P8tDk>tDxjgG!u%_O=Z7Z>|Pz0A1{r1S3nuTVZ3z4=#6w;t?w1bl`gIPaO z%4D%xRSJ>F*wOX)rN$grs&rNr0d+c$Fzs|r4nh_Z>ZJTaB zSJ90pBTYDKmqH_0hVVR7lq(PrspvRFqJ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KL9Y__W%F@ literal 0 HcmV?d00001 diff --git a/index.html b/index.html index 4f466b5..251827e 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,15 @@ - + + + + + + + + +
    @@ -56,18 +64,13 @@
      - +
      + + + +
      - This month + This month $0.00
      @@ -164,6 +167,42 @@
      - + + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..f65aef1 --- /dev/null +++ b/manifest.json @@ -0,0 +1,15 @@ +{ + "name": "Tally", + "short_name": "Tally", + "description": "Daily, weekly and monthly expense tracking. Private by design.", + "start_url": "/", + "scope": "/", + "display": "standalone", + "orientation": "portrait", + "background_color": "#ffe3ee", + "theme_color": "#ff6fae", + "icons": [ + { "src": "icon-192.png", "sizes": "192x192", "type": "image/png" }, + { "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" } + ] +} diff --git a/styles.css b/styles.css index 9cf5679..76b6014 100644 --- a/styles.css +++ b/styles.css @@ -202,6 +202,9 @@ body.nav-open .side { transform: none; } padding: 1px 9px; } .cat-item.active .count { background: rgba(255, 255, 255, 0.24); color: #fff; } +.cats li[draggable="true"] { cursor: grab; } +.cats li.dragging { opacity: 0.45; } +.cats li.drag-over { box-shadow: 0 -3px 0 var(--accent); } /* Sidebar footer card */ .side-foot { @@ -222,6 +225,8 @@ body.nav-open .side { transform: none; } } .month-total strong { font-family: var(--font-display); font-weight: 400; font-size: 19px; color: var(--ink); } .side-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } +.period-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; } +.period-pick .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); } /* Main view header: big title + date subline, like the Tasks Today view. */ .view-head h2 { margin: 0; font-size: 35px; } @@ -315,6 +320,8 @@ body.nav-open .side { transform: none; } .field { display: grid; gap: 5px; margin-bottom: 12px; font-size: 13px; color: var(--muted); } .field input, .field select { font: inherit; + min-width: 0; + font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--line); @@ -330,6 +337,15 @@ body.nav-open .side { transform: none; } .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .form-err { color: var(--danger); font-size: 13px; margin: 0 0 10px; } .form-btns { display: flex; gap: 8px; } +.update-pill { + position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; + font-family: var(--font-btn); font-size: 19px; + background: var(--accent); color: #fff; border: none; border-radius: 999px; + padding: 10px 22px; cursor: pointer; + box-shadow: 0 6px 20px rgba(214, 51, 132, 0.35); +} +.update-pill:hover { background: var(--accent-dark); } +.update-pill:disabled { opacity: 0.75; cursor: default; } /* Buttons */ .btn { @@ -408,6 +424,21 @@ body.nav-open .side { transform: none; } /* Footer */ .foot { margin: 0; } +/* Small phones: single-column form, tighter rhythm, no overflow. */ +@media (max-width: 520px) { + .wrap { padding: 0 12px; } + .topbar-mini { padding: 10px 12px 16px; } + .topbar-month { font-size: 14px; } + .card { padding: 14px; } + .row2 { grid-template-columns: 1fr; } + .row2 > * { min-width: 0; } + .view-head h2 { font-size: 28px; } + .bar-row { grid-template-columns: 96px 1fr 64px; gap: 8px; font-size: 12.5px; } + .stats { gap: 12px; } + .group-head { flex-wrap: wrap; row-gap: 2px; } + .form-btns { flex-wrap: wrap; } +} + @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } } diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..33ad294 --- /dev/null +++ b/sw.js @@ -0,0 +1,49 @@ +/* Tally service worker: offline shell + update prompts. + Bump CACHE on every deploy that changes the app. */ +var CACHE = "tally-v3"; +var SHELL = [ + "/", + "/index.html", + "/styles.css", + "/app.js", + "/manifest.json", + "/icon-192.png", + "/icon-512.png" +]; + +self.addEventListener("install", function (e) { + // {cache:"reload"} bypasses the browser HTTP cache so a fresh deploy + // precaches new bytes instead of the stale responses it may hold. + e.waitUntil(caches.open(CACHE).then(function (c) { + return c.addAll(SHELL.map(function (u) { return new Request(u, { cache: "reload" }); })); + })); +}); + +self.addEventListener("activate", function (e) { + e.waitUntil(caches.keys().then(function (keys) { + return Promise.all(keys.filter(function (k) { return k !== CACHE; }).map(function (k) { + return caches.delete(k); + })); + }).then(function () { return self.clients.claim(); })); +}); + +self.addEventListener("message", function (e) { + if (e.data && e.data.type === "SKIP_WAITING") self.skipWaiting(); +}); + +self.addEventListener("fetch", function (e) { + var url = new URL(e.request.url); + if (e.request.method !== "GET" || url.origin !== self.location.origin) return; + // Shell URLs ignore the query string (?v= cache-buster): one entry per file. + var key = SHELL.indexOf(url.pathname) !== -1 ? url.pathname : e.request; + e.respondWith(caches.match(key, { cacheName: CACHE }).then(function (hit) { + if (hit) return hit; + return fetch(e.request).then(function (res) { + if (res && res.ok) { + var copy = res.clone(); + caches.open(CACHE).then(function (c) { c.put(key, copy); }); + } + return res; + }); + })); +});