-
-
Save postavarul/a18a804ab5ea92ed25f7a362c1337b34 to your computer and use it in GitHub Desktop.
An iPhone widget, that shows you a live webcam image from Ruxy-world xpander tampa view on your homescreen
This file contains hidden or 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: blue; icon-glyph: camera-retro; | |
// Script by Andreas Redeker <[email protected]> | |
// Updated to work with Brasov webcam by Postavarul | |
// Live tampa view: https://www.roxy-world.ro/webcam-varful-tampa-brasov | |
// Url of NV webcam: https://www.xpander.ro/live/bv_nv_raw.jpg | |
// Url of SE webcam: https://www.xpander.ro/live/bv_se_raw.jpg | |
let param = args.widgetParameter | |
let url | |
if (param != null && param.length > 0) { | |
url = param | |
} else { | |
url = "https://www.xpander.ro/live/bv_nv_raw.jpg" | |
} | |
const imgUrl = url | |
const imgReq = await new Request(imgUrl) | |
const img = await imgReq.loadImage() | |
if (config.runsInWidget) { | |
let widget = createWidget(img) | |
Script.setWidget(widget) | |
Script.complete() | |
} else { | |
let widget = createWidget(img) | |
await widget.presentMedium() | |
} | |
function createWidget(img) { | |
const widget = new ListWidget() | |
widget.backgroundColor = Color.black() | |
widget.url = url | |
widget.backgroundImage = img | |
widget.addSpacer() | |
const titleText = widget.addText(getWcNameFromUrl()) | |
titleText.font = Font.boldSystemFont(12) | |
titleText.textColor = Color.white() | |
titleText.shadowRadius = 3 | |
titleText.shadowColor = Color.black() | |
widget.addSpacer(2) | |
const subtitleText = widget.addText('Tampa') | |
subtitleText.font = Font.systemFont(8) | |
subtitleText.textColor = Color.white() | |
subtitleText.textOpacity = 0.8 | |
subtitleText.shadowRadius = 3 | |
subtitleText.shadowColor = Color.black() | |
return widget | |
} | |
function getWcNameFromUrl() { | |
let wcName = url.split('/') | |
wcName = wcName[wcName.length - 2].replace('-', ' ').replace(/\b\w/g, function(c) { | |
return c.toUpperCase(); | |
}) | |
return wcName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment