Created
November 10, 2020 15:26
-
-
Save donfelipo/c0bdd3f6b3779f28367b68bc4bc1203e to your computer and use it in GitHub Desktop.
Scriptable weight UITable
This file contains 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 characters
// 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