Last active
November 12, 2021 14:42
-
-
Save dcatanzaro/8833df28c485733f1723a817acbe265d to your computer and use it in GitHub Desktop.
Revisions
-
dcatanzaro revised this gist
Sep 22, 2020 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,10 +16,8 @@ if (config.runsInWidget) { const imgReqBq = await new Request("https://i.pinimg.com/originals/aa/34/e1/aa34e1c76a6569a36499ae86098759ee.jpg"); const imgBq = await imgReqBq.loadImage(); widget.backgroundImage = imgBq; const title = widget.addText("Pokemon del día"); title.textColor = Color.black(); -
dcatanzaro renamed this gist
Sep 22, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dcatanzaro created this gist
Sep 22, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ const numberDay = () => { const now = new Date(); const start = new Date(now.getFullYear(), 0, 0); const diff = now - start; const oneDay = 1000 * 60 * 60 * 24; const day = Math.floor(diff / oneDay); return day; }; const pokemonUrl = `https://pokeapi.co/api/v2/pokemon/${numberDay()}`; const req = new Request(pokemonUrl); const res = await req.loadJSON(); if (config.runsInWidget) { const widget = new ListWidget(); const imgReqBq = await new Request("https://i.pinimg.com/originals/aa/34/e1/aa34e1c76a6569a36499ae86098759ee.jpg"); const imgBq = await imgReqBq.loadImage(); const imageBq = widget.addImage(imgBq); widget.backgroundImage = imageBq; const title = widget.addText("Pokemon del día"); title.textColor = Color.black(); title.textOpacity = 0.8; title.font = new Font("Courier", 16); widget.addSpacer(5); const namePokemon = widget.addText(`#${res.id} - ${res.name}`); namePokemon.textColor = Color.black(); namePokemon.textOpacity = 0.8; namePokemon.font = new Font("Courier", 14); const imgReq = await new Request(res.sprites.front_default); const img = await imgReq.loadImage(); const image = widget.addImage(img); image.centerAlignImage(); Script.setWidget(widget); Script.complete(); }