From d25eaa93345bc0acb0749b6ed1cab319b0003283 Mon Sep 17 00:00:00 2001 From: Kevin Kub Date: Sun, 18 Oct 2020 15:58:14 +0200 Subject: [PATCH] --- incidence.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/incidence.js b/incidence.js index fe0463c..cc35544 100644 --- a/incidence.js +++ b/incidence.js @@ -8,9 +8,23 @@ Script.setWidget(widget) Script.complete() async function createWidget(items) { - Location.setAccuracyToThreeKilometers() - const location = await Location.current() + let location + if(args.widgetParameter) { + const fixedCoordinates = args.widgetParameter.split(",").map(parseFloat) + location = { + latitude: fixedCoordinates[0], + longitude: fixedCoordinates[1] + } + } else { + Location.setAccuracyToThreeKilometers() + location = await Location.current() + } const data = await new Request(apiUrl(location)).loadJSON() + if(!data || !data.features || !data.features.length) { + const errorList = new ListWidget() + errorList.addText("Keine Ergebnisse für den aktuellen Ort gefunden.") + return errorList + } const attr = data.features[0].attributes const incidence = attr.cases7_per_100k.toFixed(1) const cityName = attr.GEN