Last active
July 10, 2026 07:58
-
-
Save Jensderond/813a6184f3a912b1bb4af1386db1b3d0 to your computer and use it in GitHub Desktop.
Scriptable parking places slinge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let url = "https://kaartlaag.rotterdam.nl/api/layers/15249.json" | |
| let r = new Request(url) | |
| let data = await r.loadJSON() | |
| let totalSpaces = 0 | |
| for (let feature of data.features) { | |
| let title = feature.properties.title | |
| if (title && title.includes("P+R Slinge")) { | |
| for (let m of feature.properties.meta) { | |
| if (m.key === "vacant-spaces") { | |
| totalSpaces += parseInt(m.value) | |
| } | |
| } | |
| } | |
| } | |
| let widget = createWidget(totalSpaces) | |
| if (config.runsInWidget) { | |
| Script.setWidget(widget) | |
| Script.complete() | |
| } else { | |
| widget.presentSmall() | |
| } | |
| function createWidget(spaces) { | |
| let w = new ListWidget() | |
| w.backgroundColor = new Color("#1A1A1A") | |
| let icon = w.addText("🅿️") | |
| icon.font = Font.boldSystemFont(38) | |
| icon.centerAlignText() | |
| w.addSpacer(8) | |
| let staticText = w.addText("P+R Slinge beschikbaar:") | |
| staticText.textColor = Color.white() | |
| staticText.font = Font.boldSystemFont(12) | |
| staticText.centerAlignText() | |
| w.addSpacer(8) | |
| let spaceText = w.addText(spaces.toString()) | |
| spaceText.textColor = new Color("#2ecc71") | |
| spaceText.font = Font.systemFont(16) | |
| spaceText.centerAlignText() | |
| w.addSpacer(8) | |
| let currentDate = new Date() | |
| let dateText = w.addDate(currentDate) | |
| dateText.textColor = Color.gray() | |
| dateText.font = Font.mediumSystemFont(10) | |
| dateText.centerAlignText() | |
| w.setPadding(0, 0, 0, 0) | |
| return w | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment