Skip to content

Instantly share code, notes, and snippets.

@mslepko
Last active May 16, 2021 12:53
Show Gist options
  • Save mslepko/e06c99b199735b5c3b414ebde5943dfb to your computer and use it in GitHub Desktop.
Save mslepko/e06c99b199735b5c3b414ebde5943dfb to your computer and use it in GitHub Desktop.
iOS Scriptable uptown.io Widget
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()
@mslepko
Copy link
Author

mslepko commented Dec 30, 2020

site_up
site_down

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment