Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save beelarr/a6b2283f994fc1cc2e7f37985bbd7e5d to your computer and use it in GitHub Desktop.

Select an option

Save beelarr/a6b2283f994fc1cc2e7f37985bbd7e5d to your computer and use it in GitHub Desktop.

Revisions

  1. @levelsio levelsio renamed this gist Nov 22, 2020. 1 changed file with 0 additions and 0 deletions.
  2. @levelsio levelsio revised this gist Nov 22, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion showFirstCellInGogoleSheetAsiOSWidget.js
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ let w = new ListWidget()
    // Add the value of the stock to the widget
    t = w.addText(stockValue)
    t.textColor = Color.black()
    t.font = new Font("Avenir-Heavy",10)
    t.font = new Font("Avenir-Heavy",24)

    Script.setWidget(w)
    Script.complete()
  3. @levelsio levelsio revised this gist Nov 22, 2020. No changes.
  4. @levelsio levelsio revised this gist Nov 22, 2020. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions showFirstCellInGogoleSheetAsiOSWidget.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,13 @@
    // Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
    // by @levelsio

    // Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188

    // Add the URL of your JSON endpoint (this should be a published Google Sheet, click File -> Publish to Web)
    // HOW TO
    // 1) Make a Google Sheet, we'll pull the first cell e.g. A1
    // 2) Publish your Google Sheet, File -> Publish To Web
    // 3) Copy the SHEET_ID in the URL, put it in here below:
    const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"

    // Or if you have a page on your server with the value to display I'd modify the code below to not get JSON but just the raw value
    // 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
    // 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)

    // Function that performs the request to the JSON endpoint
    async function loadItems() {
  5. @levelsio levelsio revised this gist Nov 22, 2020. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion showFirstCellInGogoleSheetAsiOSWidget.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,12 @@
    // Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e

    // The URL of your JSON endpoint (this should be a published Google Sheet, click File -> Publish to Web)
    // Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188

    // Add the URL of your JSON endpoint (this should be a published Google Sheet, click File -> Publish to Web)
    const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"

    // Or if you have a page on your server with the value to display I'd modify the code below to not get JSON but just the raw value

    // Function that performs the request to the JSON endpoint
    async function loadItems() {
    let at = endpoint
  6. @levelsio levelsio revised this gist Nov 22, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion showFirstCellInGogoleSheetAsiOSWidget.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e

    // The URL of your JSON endpoint
    // The URL of your JSON endpoint (this should be a published Google Sheet, click File -> Publish to Web)
    const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"

    // Function that performs the request to the JSON endpoint
  7. @levelsio levelsio created this gist Nov 22, 2020.
    30 changes: 30 additions & 0 deletions showFirstCellInGogoleSheetAsiOSWidget.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    // Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e

    // The URL of your JSON endpoint
    const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"

    // Function that performs the request to the JSON endpoint
    async function loadItems() {
    let at = endpoint
    let req = new Request(at)
    let corpo = await req.loadJSON()
    // We return just the cells
    return corpo.feed.entry
    }
    // Request the spreadsheet data
    let json = await loadItems()

    // Obtaining the content of the exact cell we are looking for
    stockValue = json[0].content["$t"]

    // Create the widget
    let w = new ListWidget()
    // w.backgroundColor = new Color("#000080")

    // Add the value of the stock to the widget
    t = w.addText(stockValue)
    t.textColor = Color.black()
    t.font = new Font("Avenir-Heavy",10)

    Script.setWidget(w)
    Script.complete()