eqsOne
October 21, 2020, 6:59pm
441
Hmm, your reference uses a rest api, no need to scratch the data from html if you just want to display the cases entry for Mainz i.e.
It loads much quicker by using a simple json request. Change the url into something like this and then just grab the ‘cases’ entry from the response.
eqsOne
October 21, 2020, 7:38pm
442
@schm_and Here’s a quick snippet to show what I mean, this loads in just a second:
//* Mainz - Cases *//
let widget = new ListWidget()
widget.setPadding(16, 16, 16, 16)
const spc = 3
let time = new Date().getHours()
var night = (time >= 19 || time < 7)
//Title Text
let titleTxt = widget.addText("Mainz")
titleTxt.font= Font.boldSystemFont(17)
titleTxt.leftAlignText()
widget.addSpacer()
//Value Text
let vlFnt = Font.semiboldSystemFont(27)
//Untertitel Textstyle
let ptFnt = Font.systemFont(18)
let ptCol
//Hintergrund
if (night) {
titleTxt.textColor = Color.lightGray()
ptCol = Color.gray()
const gradient = new LinearGradient()
gradient.locations = [0, 1]
gradient.colors = [
new Color("192331"),
new Color("222222")
]
widget.backgroundGradient = gradient
}
else {
titleTxt.textColor = Color.darkGray()
ptCol = Color.darkGray()
}
await loadSite()
if (!config.runsInWidget) widget.presentSmall()
Script.setWidget(widget)
Script.complete()
async function loadSite() {
//Source: Robert Koch-Institut, dl-de/by-2-0
let url='https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=&objectIds=163&outFields=GEN,cases&geometry=&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json'
let req = new Request(url)
let dta = await req.loadJSON()
let res = dta.features[0].attributes
let cases = res.cases+""
//**************************
//Fälle Text
if (res != null) {
let tx2 = widget.addText(cases)
tx2.leftAlignText()
tx2.font = vlFnt
tx2.textColor = Color.red()
}
//Fälle Untertitel
let tx1 = widget.addText("Fälle")
tx1.textColor = ptCol
tx1.font= ptFnt
tx1.leftAlignText()
widget.addSpacer(spc)
}
1 Like
I tried this with the weather widget, but my log says ‘image does not exists’ but the files are there. Do you have any idea whats wrong?
thanks!
eqsOne
October 21, 2020, 8:11pm
444
Post #412 shows @egamez ’s fixed original. The one in #414 is the same with a revised version of @mzeryck ’s FSymbol tweak added.
faye
October 22, 2020, 12:39am
445
Could u help me again?it doesn’t work…
It is about #406 version。。。
Please share your code instead and I’ll put in the updates.
Fixed it. Get the latest version .
1 Like
Here you go. Make sure you download all of these.
2 Likes
faye
October 22, 2020, 3:50am
451
soooo cool,i like it very much···THANKS.
1 Like
mzeryck
October 22, 2020, 4:09am
453
Sorry it took me forever to reply… yes! @pdizin created a reminders integration here .
mzeryck
October 22, 2020, 4:11am
454
Okay, wow, this is super cool!!
1116
October 22, 2020, 4:20am
455
Do you mind share your code? love the text~that’s cool~
Now we’ve got to 448 contributions (with this one) can we start a second post?
I also think anyone who could summarise the technical contributions here would be doing the community a big favour.
3 Likes
There’s now a widget tag, I would suggest that each widget example from now on be posted as it’s own post here in the Scriptable category with the widget tag. If I get a chance I’ll try to split this thread into multiple posts, but it might be a challenge!
7 Likes
sylumer
October 22, 2020, 8:06am
458
I think that would be like an attempt to untie the Gordian knot. Several of the discussions cross back and forth suggesting you might then need to merge or duplicate them to have comprehensive chronological topics.
I’m sure as Scriptable widget code authors get the hang of posting a new topic rather than cross threading a single one, it will all sort itself out. Pretty much every widget posted seems to evolve over several iterations, so just start the new topic on the next iteration.
What might be worth considering is locking this thread to avoid further conversation knotting.
3 Likes
I’d like to keep this thread open for people who want to ask about the currently posted widgets - I have managed to extract some posts which seem relatively well organised thanks to the reply feature though. I’ll keep an eye on the thread and move any newly posted widgets into their own posts though.
7 Likes
mzeryck
October 22, 2020, 2:33pm
460
Thank you for doing this!!
1 Like
faye
October 22, 2020, 2:41pm
461
hi,may i ask why the code set up the pixels for 4inch display?
And can u fix it Adaptive to the phone? or it looks not so clear…
faye
October 22, 2020, 2:42pm
462
The code is not adaptive ,it needs to updates…