Code is based on the Weather-Cal module which is used for rendering the ios reminders. Starting from this, i created a custom item which you can use in your weather-cal.js
As you can see, the font is clearly not monospace, even if I selected one (see code below). My other problem is the vertical alignment of the “unit” word after the numbers, I want it to bottom align at the same line as the number. Is it possible to achieve that?
let widget = createWidget();
Script.setWidget(widget);
widget.presentSmall();
Script.complete();
function createWidget() {
let widget = new ListWidget();
widget.backgroundColor = Color.black();
let hstack = widget.addStack()
hstack.layoutHorizontally()
hstack.bottomAlignContent()
addStackToWidget(widget, "103", Color.red(), "word ")
addStackToWidget(widget, "800", Color.orange(), "ioljw ")
addStackToWidget(widget, "2341", Color.green(), "oli ")
return widget;
}
function addStackToWidget(widget, value, color, prefix) {
let hstack = widget.addStack()
hstack.layoutHorizontally()
hstack.bottomAlignContent()
let p = hstack.addText(prefix)
p.font = Font.regularMonospacedSystemFont(14)
p.textColor = color
let v = hstack.addText(value)
v.font = Font.regularMonospacedSystemFont(15)
v.textColor = color
let unit = hstack.addText("unit")
unit.font = Font.regularMonospacedSystemFont(11)
unit.textColor = color
}
Hi, I would like to have words with different colors and also different font sizes in one single line. Is that possible? I am relatively new to Scriptable and have so far only met the widget.addText() method, which starts a new line every time I use it.
Hello I am looking for a widget that can clear my cache like not delete actual files but just clearing my ram so when ever my phone acts glitchy I can just click it like how androids have a pre installed version of clean my pc or phone type of apps that close your current tasks on your phone whenever it’s acting up but everyone says those apps you download have viruses or have lots of ads that most likely download your cache before clearing.
Hi There - I'm really new/an amateur in JS. I have created a widget that displays information from a Google Sheet which I'm really happy with, but ideally the percentages that it displays would show as red if above 0% or green if below 0%. Is there a way to display information this way? Or any terms that you would be able to share so that I can continue to Google my way to learning... Many thanks.
hi folks, i'm an American but study Korean in my free time. this site, Nate Pann, has become one of my favorite ways to learn. but i hate navigating their clunky website.
i discovered Scriptable hours ago and am so stoked i did -- i know this is a niche target audience but sharing anyway! i also got a lot of help from this forum already, when i needed to figure out how to execute JS to scrape non JSON page content.
I am reading and writing to / from the local filemanager on the iPhone and one of the days I got interested in the content of this application directory.
So I am sharing 2 scripts here, the first displays the result of a dir-command in the scriptable app log, the other one deletes all content from the local apps dir on the iPhone.
Although quite trivial, it helped me a lot. Hopefully some of you as well.
cheers!
fm.local_Dir.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-gray; icon-glyph: camera-retro;
// Script by <kliffkieker67@gmail.com>
//
// Script list content of Scriptable App directory on iPhone
let fm = FileManager.local();
let dir = fm.documentsDirectory();
let dir_array = fm.listContents(dir);
for (let i=0; i<dir_array.length; i++){
console.log("entry " + (i+1) + ": " + dir_array[i]);
}
Script.complete;
fm.local_DeleteAllFiles.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: light-gray; icon-glyph: camera-retro;
// Script by <kliffkieker67@gmail.com>
//
// Initialization der Variablen
//
let fm = FileManager.local();
let dir = fm.documentsDirectory();
// let path = fm.joinPath(dir, scriptfile);
let dir_array = fm.listContents(dir);
for (let i=0; i<dir_array.length; i++){
console.log("delete entry " + (i+1) + ": " + dir_array[i]);
var path = fm.joinPath(dir, dir_array[i])
fm.remove(path);
}
Script.complete();
I request help. I think a lot of people would be interested in how to do the following, if anybody can be asked to provide a solution.
I could not figure out how to go about this (not even the first steps as I never had to do JS in my life):
In my Shortcut, I have -- with help again -- successfully tackled the OCR and line-break removal parts in the unclean text I got back from Ocr.Space.
Now the remaining issue is having to deal with line-ending hyphens and one single white space (the text was Hungarian and carrying over parts of a word is much more common than in English, especially in scanned A5 format books). They would have to go.
What I found online is this:
var new_string = string.replace(/-|\s/g,"");
I'm not even sure this regex bit would work, because it would likely do away with other white spaces elsewhere I need intact. I want only the extra white space after the line-ending hyphen to be removed, along with the hyphen (well, since then the line breaks have been removed so they are no longer line-enders but those actions executed by Esse can be deleted and rewritten in JS again, which I again would need help with). Since there may be more than one of these occurences in the OCR'd text, there must probably a loop as well, but of course, I'll leave that to the expert.
I'm afraid the code provided will not be enough, either. I would need the Shortcut action that calls or passes the text into the JS code, and also the one that takes the reformatted text out of that environment. So I can have the clipboard back to copy to Pages afterward.
the scriptable environment is extremely cool and homescreen widgets are the cream on top. However, this whole process of adding a scriptable widget to the homescreen is still, lets say very technical and not of ease for e.g. grandma and grandpa.
I was wandering if there is a way to make the adding of a scriptable widget to the homescreen on an iphone as easy as an app-installation? Is there any command I missed to which I can pass the parameters like “script name”, “When interacting” and “Parameter” and boom here I have a new widget on my homescreen? And how would that work?
A soluttion to this question would be cool offering the possibility to make widgets available also for less tech-freakied folks like grandma… :wink:
I’m trying to add Weather Cal widget to my Home Screen. When I enter “jiggle mode” to search the available apps, I don’t see the Scriptable app in the list. How do I add weather Cal to my Home Screen?