Last active
May 16, 2021 12:53
-
-
Save mslepko/e06c99b199735b5c3b414ebde5943dfb to your computer and use it in GitHub Desktop.
iOS Scriptable uptown.io Widget
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
const api_domain = "https://updown.io/api/" | |
const api_key = "INSERT_YOUR_API_KEY_HERE" | |
let w = new ListWidget() // Create the widget | |
w.backgroundColor = Color.clear() // add transparent background | |
//w.url= "https://url.com" // an url to open on click | |
async function getChecks() { | |
const response = new Request(api_domain + '/checks?api-key=' + api_key); | |
const checks = await response.loadJSON(); | |
for(let item in checks){ | |
let status = 'UP 😍' | |
let text_colour = Color.dynamic(Color.black(), Color.white()) | |
if (checks[item].down) { | |
status = 'DOWN 😢' | |
text_colour = Color.red() | |
} | |
let page = checks[item].alias ? checks[item].alias : checks[item].url | |
let text = `${page} is ${status}` | |
t = w.addText(text) // Add the value to the widget | |
t.textColor = text_colour | |
t.font = new Font("SanFranciscoDisplay-Regular ", 24) | |
t.centerAlignText() | |
s = w.addSpacer(8) | |
} | |
return true | |
} | |
await getChecks() | |
Script.setWidget(w) | |
Script.complete() |
Author
mslepko
commented
Dec 30, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment