Hi,
Took and example of pharsing a JSON form a url and create a webview with links that open up and safari. Seems to work great but im trying to add a update/refresh timer and have it just show the items that have been added since last refresh? Can this be done via scriptable app?
Code added below
let url = "https://launches-api.endclothing.com/api/products/offset/0"
let req = new Request(url)
let json = await req.loadJSON()
let allItems = json.products
items = json.products
var insert = ""
for (item of items) {
var title = item.name
var imageURL = item.thumbnailUrl
var releaseDate = item.releaseDate
var quote = item.productPullQuote
var link = item.url
var price = item.productWebsites[0].price
var soldout = item.soldOut
var raffleURL = item.urlKey
// for (pw of item.productWebsites) {
// var price = pw[0].price
// }
var ts = new Date(releaseDate);
// console.log(ts.toDateString());
rdate = ts.toLocaleString()
if (soldout == false) {
var status = "raffle open"
}
else {
var status = "raffle over"
}
insert += `${title}`
insert += `<img src="${imageURL}" width="95%"><br>`
insert += `£${price}<p>`
insert += `${rdate}<p>`
insert += `${status}<p>`
insert += `<a href="https://launches.endclothing.com/product/${raffleURL}">Raffle Link</a>`
insert += `<p>`
insert += `<hr>`
// insert += `${link}<p>`
// insert += `<h3>${quote}</h3><p>`
// insert += `${releaseDate}<p>`
// console.log(ts)
// console.log(title)
}
let baseHTML = `
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style>
body { white-space: pre; font-family: monospace; background-color: #fff;}
span { background-color: #fff; }
th { color: #000}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<th><h1>END Raffles</h1></th>
</tr>
<tr>
<td><center>${insert}</center></td>
</tr>
</table>
</body>
</html>
`
// load the view
let view = new WebView();
// view.loadHTML(baseHTML);
// await view.present();
WebView.loadHTML(baseHTML, null, new Size(0, 1800))