|
1 | | -// icon-color: brown; icon-glyph: calendar-check; |
2 | 1 | // Variables used by Scriptable. |
3 | 2 | // These must be at the very top of the file. Do not edit. |
| 3 | +// icon-color: deep-green; icon-glyph: clock; |
4 | 4 |
|
5 | 5 | // === CONFIG === |
6 | | -const SHEET_API_URL = ""; // YOUR API URL here |
| 6 | +const SHEET_API_URL = "https://script.google.com/macros/s/..../exec"; // YOUR API URL here |
7 | 7 | const colorPalette = ["#CB2443", "#8e44ad", "#2980b9", "#F79F39", "#CEA834", "#7b9a50"]; |
8 | 8 |
|
9 | 9 | // === Fetch Data from Google Sheets Web App (instead of local JSON) === |
@@ -72,14 +72,19 @@ await fm.downloadFileFromiCloud(fontPath); |
72 | 72 | const roboto = (size) => new Font(fontPath, size); |
73 | 73 |
|
74 | 74 | // === Load Repeat Icon === |
75 | | -const repeatPath = fm.joinPath(fm.joinPath(fm.documentsDirectory(), ".assets"), "repeat_icon.png"); |
| 75 | +const repeatPath = fm.joinPath(fm.joinPath(fm.documentsDirectory(), ".source"), "repeat_icon.png"); |
76 | 76 | await fm.downloadFileFromiCloud(repeatPath); |
77 | 77 | const repeatIcon = fm.readImage(repeatPath); |
78 | 78 |
|
79 | 79 |
|
80 | 80 | // === Parameter Handling for Small Widget === |
81 | 81 | const param = args.widgetParameter ? args.widgetParameter.trim().toLowerCase() : null; |
82 | | -let selectedEvent = events[0]; // default: soonest event |
| 82 | +// Find the most recent upcoming event (soonest event) |
| 83 | +let selectedEvent = events.reduce((closest, event) => { |
| 84 | + const daysToEvent = daysUntil(event.date); |
| 85 | + const daysToClosest = daysUntil(closest.date); |
| 86 | + return daysToEvent < daysToClosest ? event : closest; |
| 87 | +}, events[0]); |
83 | 88 | let showAgeMode = false; // default off |
84 | 89 | let page = 1; // default page |
85 | 90 |
|
|
0 commit comments