Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
iOS widget powered by the Scriptable app that shows the current capacity of FitX Gyms
/**
* Script for scriptable to get the current capacity of FitX Gyms
*/
let gymId = 19
let param = args.widgetParameter
if (param != null && param.length > 0) {
gymId = param
}
const gymDetails = await fetchGymDetails(gymId)
const currentGymCapacity = gymDetails.workload.percentage
const gymName = gymDetails.name || 'Your FitX'
const widget = new ListWidget()
await createWidget()
if (!config.runsInWidget) {
await widget.presentSmall()
}
Script.setWidget(widget)
Script.complete()
//Create the widget
async function createWidget() {
const headlineText = widget.addText("🏋️ Capacity")
headlineText.font = Font.mediumRoundedSystemFont(19)
widget.addSpacer()
const widgetStack = widget.addStack()
widgetStack.layoutVertically()
widgetStack.bottomAlignContent()
const capacityText = widgetStack.addText(currentGymCapacity.toString() + "%")
capacityText.font = Font.mediumRoundedSystemFont(50)
if (currentGymCapacity < 20) {
capacityText.textColor = new Color("#33cc33")
} else if (currentGymCapacity < 30){
capacityText.textColor = new Color("#ff9900")
}else{
capacityText.textColor = new Color("#ff3300")
}
widgetStack.addSpacer(1)
const gymNameText = widgetStack.addText(gymName)
gymNameText.font = Font.regularSystemFont(12)
}
//Fetches the current capacity of the FitX gym
async function fetchGymDetails(id) {
const url = 'https://www.fitx.de/fitnessstudio/' + id + '/workload'
const req = new Request(url)
const result_json = await req.loadJSON()
return JSON.parse(result_json)
}
@eopo

This comment has been minimized.

Copy link
Owner Author

@eopo eopo commented Oct 23, 2020

Fork of https://gist.github.com/masselmello/6d4f4c533b98b2550ee23a7a5e6c6cff
Made with help of @BitWire - Huge thanks

image

How to use:

  1. You need to have Scriptable on your iOS 14 device and open it
  2. Tap on the plus in the upper right corner
  3. Tap on "Untitled Script" and give the script a name, for example "Gym Capacity"
  4. Copy the source code from above and paste it in the blank field
  5. Save it.
  6. Go to your home screen and enter wiggle mode. Then tap on the plus in the upper left corner.
  7. Select Scriptable from the promoted widgets, the app list or search for scriptable.
  8. Select your widget size.
  9. Tap on "Add widget"
  10. Tap on the newly added widget.
  11. Select the John Reed script. On "When Interacting", you can select "Run Script", but it'll work just fine with "Open App"
  12. Paste your studio ID as parameter. You can see it in the table below.
    image
  13. Finished! 😍
Studio ID
Aachen-Europaplatz 38
Arnsberg 106
Augsburg-Lechhausen 98
Berlin-Alexanderplatz 37
Berlin-Biesdorf 100
Berlin-East Side Mall 82
Berlin-Hellersdorf 61
Berlin-Landsberger Allee 89
Berlin-Moabit 91
Berlin-Schöneberg 57
Berlin-Südkreuz 48
Berlin-Tempelhof 56
Berlin-Waidmannslust 29
Berlin-Wilmersdorf 24
Bielefeld-Mitte 102
Bielefeld-Sieker 26
Bochum-Harpen 66
Bochum-Innenstadt 34
Bochum-Riemke 32
Bochum-Wattenscheid 17
Bonn-Duisdorf 94
Bottrop-Stadtmitte 78
Bremen-Mitte 51
Bremen-Oslebshausen 54
Bremen-Walle 74
Bremerhaven-Geestemünde 75
Chemnitz-Kaßberg 69
Dortmund-Kley 40
Dortmund-Nordstadt 13
Dortmund-Phoenix See 25
Dresden-Freiberger Straße 101
Duisburg-Hamborn 84
Duisburg-Rheinhausen 60
Düren-Birkesdorf 39
Düsseldorf-Derendorf 15
Düsseldorf-Flingern 16
Düsseldorf-Holthausen 47
Düsseldorf-Lörick 33
Erfurt-Daberstedt 116
Essen-Bergerhausen 19
Essen-Limbecker Platz 70
Essen-Nordviertel 11
Fürth-Hardhöhe 76
Gelsenkirchen-Erle 111
Gelsenkirchen-Heßler 27
Gelsenkirchen-Mitte 105
Gießen-Innenstadt 90
Gladbeck-Mitte 88
Grevenbroich 118
Gütersloh-Innenstadt 71
Hagen-Mitte 62
Hamburg-Airport 46
Hamburg-Bahrenfeld 80
Hamburg-Steilshoop 45
Hamm-Mitte 14
Hannover-Vahrenheide 22
Hilden 123
Iserlohn-Seilersee 42
Jena-Burgau 81
Kiel Gaarden-Süd 31
Koblenz-Lützel 124
Krefeld-Inrath 112
Krefeld-Oppum 30
Leipzig Mockau-Süd 41
Leipzig-Neulindenau 103
Lübeck-St. Lorenz Nord 43
Ludwigshafen-Nord 44
Magdeburg-Sudenburg 49
Mainz-Hechtsheim 99
Minden-Innenstadt 97
Mönchengladbach-Rheydt 67
Mönchengladbach-Waldhausen 21
Mülheim-Stadtmitte 77
München-Lenbachplatz 108
München-Neuperlach 65
München Schwabing-Freimann 35
München Sendling-Westpark 53
Münster-Berg Fidel 12
Münster-Kinderhaus 64
Neuss-Innenstadt 110
Nürnberg-Zabo 55
Oberhausen-Marienviertel 20
Osnabrück-Fledder 18
Ratingen-West 50
Remscheid-Süd 104
Rostock-Südstadt 58
Saarbrücken-St. Johann 87
Siegen-Mitte 28
Troisdorf-Mitte 96
Unna 117
Viersen 121
Wetzlar 107
Witten-Mitte 86
Worms-Innenstadt Süd 52
Wuppertal-Barmen 36
Wuppertal-Langerfeld 23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment