This is a Scriptable Widget Script for iOS. A „Corona-🚦-Berlin“ Icon for your Homescreen.
This file contains 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
// "Corona-Ampel-Berlin" iOS Scriptable Widget | |
// | |
// Original Quelle: https://gist.github.com/m4p/20cc77b6d9f1f422b75bc3ab6eed0ff3 | |
// | |
// Editing: https://gist.github.com/Leibinger015 | |
// | |
// Skript: Angepasst am 19.11.2021 von www.anb030.de/ | |
// | |
// What's new: Hospitalisierungsrate, Inzidenz, ITS-Betten, Geimpft! | |
let widget = new ListWidget(); | |
let padding = 22; | |
widget.setPadding(padding, padding, padding, padding); | |
widget.url = "https://www.berlin.de/corona/lagebericht/desktop/corona.html"; | |
let apiResponse = await loadItems(); | |
let header = widget.addText("Corona🚦Berlin".toUpperCase()); | |
header.font = Font.mediumSystemFont(10); | |
widget.addSpacer(16); | |
let vStack = widget.addStack(); | |
vStack.layoutHorizontally(); | |
addDataView(vStack, apiResponse.indicators.incidence_hospitalisation); | |
vStack.addSpacer(); | |
addDataView(vStack, apiResponse.indicators.incidence_new_infections); | |
widget.addSpacer(); | |
let vStack2 = widget.addStack(); | |
vStack2.layoutHorizontally(); | |
addDataView(vStack2, apiResponse.indicators.icu_occupancy_rate); | |
vStack2.addSpacer(); | |
addDataView(vStack2, apiResponse.vaccination.percentage_two_doses_display); | |
Script.setWidget(widget); | |
Script.complete(); | |
widget.presentSmall(); | |
function addDataView(widget, data) { | |
let viewStack = widget.addStack(); | |
viewStack.layoutVertically(); | |
let label = viewStack.addText(data.shortDescription); | |
label.font = Font.mediumSystemFont(12); | |
if (data.footnote != "") { | |
let footnote = viewStack.addText(data.footnote); | |
footnote.font = Font.mediumSystemFont(6); | |
} | |
let value = viewStack.addText(data.stringValue); | |
value.font = Font.mediumSystemFont(20); | |
value.textColor = colorForString(data.color); | |
} | |
async function loadItems() { | |
let url = | |
"https://raw.githubusercontent.com/knudmoeller/berlin_corona_cases/master/data/target/berlin_corona_traffic_light.latest.json"; | |
let req = new Request(url); | |
let json = await req.loadJSON(); | |
json.indicators.incidence_hospitalisation.shortDescription = "Hospital."; | |
json.indicators.incidence_new_infections.shortDescription = "Inzidenz"; | |
json.indicators.icu_occupancy_rate.shortDescription = "ITS"; | |
json.indicators.incidence_hospitalisation.footnote = "(7 Tage)"; | |
json.indicators.incidence_new_infections.footnote = "(7 Tage)"; | |
json.indicators.icu_occupancy_rate.footnote = "(in %)"; | |
json.indicators.incidence_hospitalisation.stringValue = json.indicators.incidence_hospitalisation.value.toString(); | |
json.indicators.incidence_new_infections.stringValue = json.indicators.incidence_new_infections.value.toString(); | |
json.indicators.icu_occupancy_rate.stringValue = | |
json.indicators.icu_occupancy_rate.value.toString(); | |
json.vaccination["percentage_two_doses_display"] = {} | |
json.vaccination.percentage_two_doses_display.shortDescription = "Geimpft"; | |
json.vaccination.percentage_two_doses_display.footnote = "(in %)"; | |
json.vaccination.percentage_two_doses_display.stringValue = json.vaccination.percentage_two_doses.toString(); | |
json.vaccination.percentage_two_doses_display.color = "blue"; | |
return json; | |
} | |
function colorForString(colorString) { | |
if (colorString == "red") { | |
return Color.red(); | |
} | |
if (colorString == "yellow") { | |
return Color.yellow(); | |
} | |
if (colorString == "blue") { | |
return Color.blue(); | |
} | |
return Color.green(); | |
} |
Hat da jemand sowas auch für Baden Württemberg?
Hat da jemand sowas auch für Baden Württemberg?
Ich leider nicht!
schade. du greifst die Daten ja auch nicht vom RKI ab wenn ich das richtig sehe oder?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wie funktioniert dieses „Corona-Ampel-Berlin“ Widget und was zeigt diese an?
••••••
In der neusten Version des Code’s vom 19. November 2021 werden nun die vier relevanten Werte dargestellt. Diese hat die deutsche Bundesregierung als neuen Standard gesetzt.
••••••
Voraussetzung:
iOS 14 oder höher
Die aktuelle Scriptable App
••••••
Unterstützung des Normal- und Dunkelmodus.
••••••
Installation:
1.) Kopiere den Skript Code von oben
2.) Öffne die Scriptable App
3.) Klick auf das "+" Symbol oben rechts und füge das kopierte Skript ein
4.) Klick auf den Titel des Skripts ganz oben und vergebe einen Namen (z.B. Corona-Ampel-Berlin)
5.) Speicher das Skript durch Klick auf "Done" oben links
6.) Gehe auf deinen iOS Homescreen und drücke irgendwo lang, um in den "wiggle mode" zu kommen (mit dem man auch die App Symbole anordnen kann)
7.) Drück das "+" Symbol oben links, blättere dann nach unten zu "Scriptable" (Liste ist alphabetisch), wähle die erste Widget Größe (small) und drück unten auf "Widget hinzugügen"
8.) Drück auf das Widget, um seine Einstellungen zu bearbeiten (optional lang drücken, wenn der Wiggle Modus schon beendet wurde)
9.) Wähle unter "Script" das oben erstellte aus (Corona-Ampel-Berlin)
10.) Fertig !!!