-
-
Save pasrom/fd784a6ef23f2e62aac231392ff6bdb4 to your computer and use it in GitHub Desktop.
Coronavirus Scriptable Widget
Hallo @hxperman,
ich habe an diesem Script nichts geändert, das kommt von https://gist.github.com/planecore/e7b4c1e5db2dd28b1a023860e831355e
Bei deinem Darstellungsproblem kann ich dir helfen, verwende hierzu die Funktion toFixed()
(siehe https://www.w3schools.com/jsref/jsref_tofixed.asp). Z. B.:
table.addRow(createRow("Today", res.todayCases.toFixed(2)))
Beste Grüße
pasrom
Danke, ich habe es erfolgreich angepasst.
Am Mo., 16. Nov. 2020 um 19:21 Uhr schrieb Roman Passler <
notifications@github.com>:
… ***@***.**** commented on this gist.
------------------------------
Hallo @hxperman <https://github.com/hxperman>,
ich habe an diesem Script nichts geändert, das kommt von
https://gist.github.com/planecore/e7b4c1e5db2dd28b1a023860e831355e
Bei deinem Darstellungsproblem kann ich dir helfen, verwende hierzu die
Funktion toFixed() (siehe
https://www.w3schools.com/jsref/jsref_tofixed.asp). Z. B.:
table.addRow(createRow("Today", res.todayCases.toFixed(2)))
Beste Grüße
pasrom
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/fd784a6ef23f2e62aac231392ff6bdb4#gistcomment-3529489>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARXUJJO2RW57QYXFCBSCVNDSQFUT7ANCNFSM4TUIVHSQ>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hallo, Ich habe mir erlaubt dieses Script etwas umzuschreiben: Jetzt werden die Neuinfektionen pro 100T Einwohner und die aktuell Infizierten pro 100T Einwohner je Land angezeigt. Diese Informationen finde ich sehr interessant, um zu sehen wie wir im Verhältnis dastehen. Leider bekomme ich es nicht hin, dass die Anzeige auf 2 Nachkommastellen reduziert wird. Außerdem würde ich gerne noch evtl. noch weitere Zahlen einfügen, aber soweit gehen meine Kenntnisse noch nicht. Unter Parameter kann man direkt das Land in den Widgeteinstellungen eingeben. Gem. der Homepage https://coronavirus-19-api.herokuapp.com/countries/.
// Based on the variant: https://gist.github.com/pasrom/fd784a6ef23f2e62aac231392ff6bdb4
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-green; icon-glyph: user-md;
// change "country" to a value from https://coronavirus-19-api.herokuapp.com/countries/
const country = (args.widgetParameter)
const url =
https://coronavirus-19-api.herokuapp.com/countries/${country}
const req = new Request(url)
const res = await req.loadJSON()
if (config.runsInWidget) {
// create and show widget
Script.setWidget(widget)
Script.complete()
} else {
// make table
let table = new UITable()
// add header
let row = new UITableRow()
row.isHeader = true
row.addText(
Coronavirus Stats in ${country}
)table.addRow(row)
// fill data
table.addRow(createRow("Cases", res.cases))
table.addRow(createRow("Today", res.todayCases))
table.addRow(createRow("Deaths", res.deaths))
table.addRow(createRow("Recovered", res.recovered))
table.addRow(createRow("Critical", res.critical))
table.addRow(createRow("Cases/100T", res.casesPerOneMillion/100))
table.addRow(createRow("Tests/100T", res.testsPerOneMillion/100))
if (config.runsWithSiri)
Speech.speak(
There are ${res.cases} cases in ${country}, and ${res.todayCases} cases today.
)// present table
table.present()
}
function createRow(title, number) {
let row = new UITableRow()
row.addText(title)
row.addText(number.toString()).rightAligned()
return row
}
function createWidget(pretitle, title, subtitle, color) {
let w = new ListWidget()
w.backgroundColor = new Color(color)
let preTxt = w.addText(pretitle)
preTxt.textColor = Color.white()
preTxt.textOpacity = 0.9
preTxt.font = Font.systemFont(22)
w.addSpacer(5)
let titleTxt = w.addText(title)
titleTxt.textColor = Color.white()
titleTxt.font = Font.systemFont(16)
w.addSpacer(5)
let subTxt = w.addText(subtitle)
subTxt.textColor = Color.white()
subTxt.textOpacity = 0.9
subTxt.font = Font.systemFont(16)
return w
}