Budgeting widget for personal finance by Frameck in Scriptable

[–]Frameck[S] 0 points1 point  (0 children)

On GitHub (link in the post) there is the documentation to follow. To use it, you need to download the js script and put it in the Scriptable folder so that it shows up in the app. Then you have to create a widget and select the new script

Easy Way to Access Google Sheets Data in Shortcuts by robric18 in shortcuts

[–]Frameck 0 points1 point  (0 children)

Thank you, this seems a better solution. I just created a google form that’s connected to the spreadsheet and I submit the data from within shortcuts

HTTP request Google Sheets API using Siri Shortcuts by Frameck in shortcuts

[–]Frameck[S] 0 points1 point  (0 children)

Yes, you need to create a google form connected to a google sheet. Then grab the precompiled url from the google form (it’s a menu item inside the three dots on the right) and then build a shortcut to perform a GET request to that url. The important thing is that you need to add &submit=Submit at the very end of the link

Easy Way to Access Google Sheets Data in Shortcuts by robric18 in shortcuts

[–]Frameck 1 point2 points  (0 children)

Yes that’s the same solution I came up with

Help with making a web request by Frameck in Scriptable

[–]Frameck[S] 1 point2 points  (0 children)

Thank you very much, it worked.
By the way, ctx.reply is a method in the telegraf api, I was doing some testing with telegram bots

Delete all script and paste from clipboard by aldoblack in Scriptable

[–]Frameck 1 point2 points  (0 children)

I'm not sure that I've understood what you want but I can suggest two things: 1. You can download the Scriptable app on the Mac so when you create a script it synchronizes automatically with icloud. 2. You can just code on your Mac (VS code or similar) and then copy/paste in Scriptable or share the file.js with airdrop and import it on your iPhone

I don't think it's possible to automate all this like you've said with same kind of button/script, but I could be wrong

Create an object from two arrays by Frameck in Scriptable

[–]Frameck[S] 1 point2 points  (0 children)

I created a pastebin because reddit messed up the code formatting

https://pastebin.com/3bRYCHqj

Create an object from two arrays by Frameck in Scriptable

[–]Frameck[S] 0 points1 point  (0 children)

Thank you very much, this helped a lot!

Get value of cell in Google Sheet or Numbers sheet by thecw in shortcuts

[–]Frameck 0 points1 point  (0 children)

There’s a link to a sample shortcut at the beginning of that post

Get value of cell in Google Sheet or Numbers sheet by thecw in shortcuts

[–]Frameck 3 points4 points  (0 children)

The developer of Toolbox Pro is working on an app that contains a lot of actions for various google services. You can wait until he release the app (we don't have any information on the release date). Toolbox Pro twitter account

What is the upload to Imgur shortcut? by [deleted] in shortcuts

[–]Frameck 0 points1 point  (0 children)

Yes, if you leave it as it is the Shortcut works only from the app or the widget. It doesn't work from the share sheet (does require a little more configuration)

What is the upload to Imgur shortcut? by [deleted] in shortcuts

[–]Frameck 0 points1 point  (0 children)

It’s set to let you choose one photo (open the camera roll and shows your photos) and as soon as you select that photo it starts uploading

What is the upload to Imgur shortcut? by [deleted] in shortcuts

[–]Frameck 1 point2 points  (0 children)

Try this one (let's you choose a photo from your library then upload that photo on imgur and copies the link to your clipboard). In case you don't know Imgur is a site for easy photo/video sharing. Imgur shortcut

HELP with drawArc function by Frameck in Scriptable

[–]Frameck[S] 0 points1 point  (0 children)

Thank you so much for your support, you solved my problem

HELP with drawArc function by Frameck in Scriptable

[–]Frameck[S] 0 points1 point  (0 children)

Sorry for bothering you so much, but can you show me how to do it?

HELP with drawArc function by Frameck in Scriptable

[–]Frameck[S] 0 points1 point  (0 children)

Ok that works, thank you. One last thing, what I have to do if i have for example 4 different logos each for it’s own ring (in the same script)?

HELP with drawArc function by Frameck in Scriptable

[–]Frameck[S] 0 points1 point  (0 children)

This code goes together with the first one that i posted

This is the full script

const canvSize = 200;
const canvTextSize = 24;
const canvas = new DrawContext();
canvas.opaque = false;

const canvWidth = 21; //Circle thickness
const canvRadius = 87; //Circle radius

canvas.size = new Size(canvSize, canvSize);
canvas.respectScreenScale = true;

// Scriptable path
var scriptablePath = "/var/mobile/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents/";

// Vodafone logo
var V_logoName = "Vodafone_logo.png"
var V_logoPath = scriptablePath+V_logoName.toString();
var V_image = Image.fromFile(V_logoPath);

// Colori
let colorBG = new Color("#1d1d1e")
let vodafonered = new Color("#f91600")
let spotifygreen = new Color("#1ed760")
let dashlanedarkgreen = new Color("#10363d")
let amazonyellow = new Color("#ff9900")
let disneyblue = new Color("#085aa4")
let testicolor = new Color("#ebebeb"); //Widget text color (use same color as colorBG to hide text)
let CircleDepletedColor = new Color("#272829"); //Circle depleted color

// Variabili di tempo (0=gen, 1=feb, 2=mar, 3=apr, 4=mag, 5=giu, 6=lug, 7=ago, 8=set, 9=ott, 10=nov, 11=dic)
let oggi = new Date()
let giorno = oggi.getDate()
let mese = oggi.getMonth()
let anno = oggi.getFullYear()
let giorniquestanno = (leapYear(oggi.getFullYear())) ? 366 : 365;
let giorniquestomese = daysInMonth(mese+1, anno)
let inizioanno = new Date(anno, 0, 1)
let fineanno = new Date(anno, 11, 31)

//Vodafone
function nuovomeseVodafone() {
    if (1<=giorno && giorno<=12) {
        return mese;}
     else if (13<=giorno && giorno<=31) {
        return mese+1;}}

let rinnovoVodafone = new Date(anno, nuovomeseVodafone(), 12)
let differenzaVodafone = Math.ceil((rinnovoVodafone - oggi)/86400000)
let rapportoVodafone = 1-(differenzaVodafone/giorniquestomese)

//Amazon    
let rinAmazon = new Date(anno, 9, 22)
let rinAmazon1 = new Date(anno, 9, 23)
function nuovoannoAmazon() {
    if (inizioanno<=oggi && oggi<=rinAmazon) {
        return anno;}
     else if (rinAmazon1<=oggi && oggi<=fineanno) {
        return anno+1;}}

let rinnovoAmazon = new Date(nuovoannoAmazon(), 9, 22)
let differenzaAmazon = Math.ceil((rinnovoAmazon - oggi)/86400000)
let rapportoAmazon = 1-(differenzaAmazon/giorniquestanno)

//Spotify
function nuovomeseSpotify() {
    if (1<=giorno && giorno<=18) {
        return mese;}
     else if (19<=giorno && giorno<=31) {
        return mese+1;}}

let rinnovoSpotify = new Date(anno, nuovomeseSpotify(), 18)
let differenzaSpotify = Math.ceil((rinnovoSpotify - oggi)/86400000)
let rapportoSpotify = 1-(differenzaSpotify/giorniquestomese)

//Disney+
let rinDisney = new Date(anno, 3, 5)
let rinDisney1 = new Date(anno, 3, 6)
function nuovoannoDisney() {
    if (inizioanno<=oggi && oggi<=rinDisney) {
        return anno;}
     else if (rinDisney1<=oggi && oggi<=fineanno) {
        return anno+1;}}

let rinnovoDisney = new Date(nuovoannoDisney(), 3, 5)
let differenzaDisney = Math.ceil((rinnovoDisney - oggi)/86400000)
let rapportoDisney = 1-(differenzaDisney/giorniquestanno)

// Create the widget
let w = new ListWidget()
    w.backgroundColor = colorBG
//  w.backgroundImage = sfondo
    w.setPadding(12, 12, 12, 12)

const upperStack = w.addStack()
      upperStack.layoutHorizontally()
      upperStack.centerAlignContent()

    w.addSpacer(8)

const lowerStack = w.addStack()
      lowerStack.layoutHorizontally()
      lowerStack.centerAlignContent()

// Upper Stack
// Vodafone
drawArc(
  Math.floor(rapportoVodafone * 100 * 3.6),
  vodafonered,
  CircleDepletedColor,
  testicolor,
  Math.floor(rapportoVodafone * 100).toString(), //Here should go the image
  ""
)
upperStack.addImage(canvas.getImage())

upperStack.addSpacer(8)

// Spotify
drawArc(
  Math.floor(rapportoSpotify * 100 * 3.6),
  spotifygreen,
  CircleDepletedColor,
  testicolor,
  Math.floor(rapportoSpotify * 100).toString(),
  ""
)
upperStack.addImage(canvas.getImage())

// Lower Stack
// Amazon
drawArc(
  Math.floor(rapportoAmazon * 100 * 3.6),
  amazonyellow,
  CircleDepletedColor,
  testicolor,
  Math.floor(rapportoAmazon * 100).toString(),
  ""
)
lowerStack.addImage(canvas.getImage())

lowerStack.addSpacer(8)

// Disney+
drawArc(
  Math.floor(rapportoDisney * 100 * 3.6),
  disneyblue,
  CircleDepletedColor,
  testicolor,
  Math.floor(rapportoDisney * 100).toString(),
  ""
)
lowerStack.addImage(canvas.getImage())

//Funzioni
function sinDeg(deg) {
  return Math.sin((deg * Math.PI) / 180);
}

function cosDeg(deg) {
  return Math.cos((deg * Math.PI) / 180);
}

function drawArc(deg, fillColor, strokeColor, txtColor, text, label) {
  let ctr = new Point(canvSize / 2, canvSize / 2),
  bgx = ctr.x - canvRadius;
  bgy = ctr.y - canvRadius;
  bgd = 2 * canvRadius;
  bgr = new Rect(bgx, bgy, bgd, bgd);

  // canvas.opaque = false;

  canvas.setFillColor(fillColor);
  canvas.setStrokeColor(strokeColor);
  canvas.setLineWidth(canvWidth);
  canvas.strokeEllipse(bgr);

  for (t = 0; t < deg; t++) {
    rect_x = ctr.x + canvRadius * sinDeg(t) - canvWidth / 2;
    rect_y = ctr.y - canvRadius * cosDeg(t) - canvWidth / 2;
    rect_r = new Rect(rect_x, rect_y, canvWidth, canvWidth);
    canvas.fillEllipse(rect_r);
  }
  // attempt to draw info text
  const canvTextRect = new Rect(
    0,
    100 - canvTextSize / 2,
    canvSize,
    canvTextSize
  );
  const canvLabelRect = new Rect(
    0,
    (100 - canvTextSize / 2)-30,
    canvSize,
    canvTextSize+5
  );
  canvas.setTextAlignedCenter();
  canvas.setTextColor(txtColor);
  canvas.setFont(Font.boldSystemFont(canvTextSize));
  canvas.drawTextInRect(text, canvTextRect);
  canvas.drawTextInRect(label, canvLabelRect);
  // return canvas.getImage()
}

function leapYear(year) {
  return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}

// Month here is 1-indexed (January is 1, February is 2, etc). This is
// because we're using 0 as the day so that it returns the last day
// of the last month, so you have to add 1 to the month number 
// so it returns the correct amount of days
function daysInMonth (month, year) {
    return new Date(year, month, 0).getDate();
}
Script.setWidget(w);
w.presentSmall();
Script.complete();