Skip to content

Instantly share code, notes, and snippets.

@donfelipo
Created November 10, 2020 15:26
Show Gist options
  • Save donfelipo/c0bdd3f6b3779f28367b68bc4bc1203e to your computer and use it in GitHub Desktop.
Save donfelipo/c0bdd3f6b3779f28367b68bc4bc1203e to your computer and use it in GitHub Desktop.
Scriptable weight UITable
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: teal; icon-glyph: table;
let fm = FileManager.iCloud()
let bookmarks = fm.allFileBookmarks()
let file = fm.bookmarkedPath("weight-log.json")
let content = fm.readString(file)
let json = JSON.parse(content)
let table = new UITable()
table.showSeparators = true
json.weightLog.forEach(entry => {
let row = new UITableRow()
let wcell = UITableCell.text(String(entry.weight.toFixed(1)))
row.addCell(wcell)
let dcell = UITableCell.text(entry.date.toLocaleString())
row.addCell(dcell)
table.addRow(row)
}
)
table.present(true)
function prettyPrint(json) {
let str = JSON.stringify(json, null, 2)
QuickLook.present(str)
}
function browse(json) {
QuickLook.present(json)
}
// QuickLook.present(content.toRawString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment