Skip to content

Instantly share code, notes, and snippets.

@simonbs

simonbs/One More Thing.js

Last active Nov 4, 2020
Embed
What would you like to do?
Countdown to Apple's "One More Thing" event on November 10th, 2020
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-purple; icon-glyph: apple-alt;
const TITLE = "One More Thing"
const DATE = "2020-11-10T17:00:00Z"
const IMG_URL = "https://i.ibb.co/f2SN2Wb/bg.png"
let widget = await createWidget()
if (config.runsInWidget) {
Script.setWidget(widget)
Script.complete()
} else {
await widget.presentMedium()
}
async function createWidget() {
let eventDate = createEventDate()
let bgImg = await loadBgImage()
let widget = new ListWidget()
widget.backgroundImage = bgImg
widget.addSpacer()
let wtitle = widget.addText(TITLE)
wtitle.font = Font.boldSystemFont(20)
wtitle.textColor = Color.white()
widget.addSpacer(2)
let wdate = widget.addDate(eventDate)
wdate.applyRelativeStyle()
wdate.font = Font.mediumSystemFont(18)
wdate.textColor = Color.white()
return widget
}
function createEventDate() {
let dateFormatter = new DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
return dateFormatter.date(DATE)
}
async function loadBgImage() {
let req = new Request(IMG_URL)
return await req.loadImage()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.