First thanks for scriptable it is awesome.
Is there a way to add checkboxes and drop downs in scriptable alerts? I did not find anything in the documentation. If there is, could you show a example for a checkbox, radio button, and drop down. I haven’t been able to find anything online.
You would want to build a web view to use elements like that. Scriptable’s alert is analogous to a standard JavaScript alert.
Thank you for that info. I am on the webview track now.
I am now trying to load a index.html file and a JavaScript file that has a src reference in it. I have placed both in the scriptable base folder on icloud.
I get to where it all works EXCEPT it opens a blank html page. Do I have the creation of file paths right for reading a index.html file from the iCloud Drive scriptable folder? Any ideas on why it might be a blank page? I have checked that it is valid html in the index file and it is in the root directory of scriptable on iCloud
let fm = FileManager.iCloud();
let dir = fm.documentsDirectory();
let fileName = "index.html";
let path = fm.joinPath(dir,fileName);
WebView.loadFile(path, new Size(0,100))
This worked for me when I created and ran it on my Mac using the Scriptable beta app.
let fm = FileManager.iCloud();
let dir = fm.documentsDirectory();
let strPath = fm.joinPath(dir,"example.html");
console.log(strPath);
await WebView.loadFile(strPath);
When I repeated it on my iPad, my first run gave a blank page. I navigated to the example.html
file via the Files app and it was showing as in the cloud and not on device. I tapped on it to download and preview it. Then I went back into Scriptable, ran the script again, and this time it displayed just as it did on the Mac, using an iPad valid path to the same file: /private/var/mobile/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents/example.html
Hope that helps.
Awesome! It worked. Thanks so much for helping with that. I couldn’t figure out what the issue was. I did run across this in the documentation when I was trying to figure it out.
downloadFileFromiCloud(filePath)
but I thought it was for a different reason and my file would be downloaded in a minute ( on a update schedule in iCloud) if it wasn’t—so I didn’t use it. I bet I should have added this in. I find the documentation oddly hard to understand without examples. Love Scriptable though. Thanks!!
This worked so that I didn’t have to physically locate and download the file on my phone.
let fm = FileManager.iCloud();
let dir = fm.documentsDirectory();//
let fileName = "index.html";
let path = fm.joinPath(dir,fileName);
if(fm.isFileStoredIniCloud(path))
{
fm.downloadFileFromiCloud(path);
}
Thanks again.
You do not need to check whether the file is stored in iCloud or not. Just directly call downloadFileFromiCloud
. According to the documentation, nothing bad happens when it’s stored local or already downloaded.
But you should add an await
before the function call:
await fm.downloadFileFromiCloud(file)
otherwise it might not have finished downloading when the file is read resulting in an error.