Here is a first draft of a timer concept I came up with, similar to what we had with Classic Apps. This uses some USC columns, javascript columns, HTML, and a Web Embed component to function without having to worry about the 10 second limit that we experience within Glide currently. It’s a little bit of setup, but not too terrible.
The old timer in classic apps used start time, current time, duration, and some javascript math to work. This follows very similar logic.
The buttons set various values in a table, which are used to build a small HTML page that shows the timer. To keep the times as accurate as possible and make it easy to calculate durations, I ended up using unix time. This made durations a whole lot easier to calculate.
The custom actions for the buttons may be a little overkill with a handful of Set Column actions strung together and some Wait conditions in between, but I wanted to make sure there weren’t any surprises with values getting set before they were calculated on the back end.
Let me know if anything doesn’t work correctly, or if you have any ideas to improve or simplify my logic. Also feel free to fork it and make improvements. Just be sure to share in this same thread if you do.
I guess it depends on how its used. Clicking a button would give you to-the-millisecond accuracy, but no, I’m pretty sure it wouldn’t work to control visibility since the timer itself is contained in the web embed sandbox.
I will definitely be bookmarking this app for when I need to display a timer, but until Glide gives us faster refresh in the data editor, I can’t use it for the QA app I’m currently building.
The setInterval is not running in a normal javascript column. It’s running on a small html page that contains the javascript inside of the web embed component. Every time a button is pressed, it rebuilds the html and the web embed reloads to run the javascript inside of that html page.
I’m thinking the same. It becomes impractical to use the delay method.
I do remember a couple of years ago, there was a little bit of a hack where you could use a location component to continuously update your location, and as a side effect, it would cause computed columns in the same table to compute every 2 to 5 seconds instead of every 10 seconds. Not a very good solution and I’m not sure if it works like that anymore, but it was interesting to observe. But it does prove that it is possible if Glide allowed it. However, I imagine that it could start to use a lot of device resources, especially if a large table is continually updated and running code.
For now, I think the web embed method is the best option we have because it allows you to continuously run javascript in a loop and still see results as it runs.
I should mention though, that since I posted this, we now have the ability to create custom components, which is probably a better way to achieve this. I’ve seen a couple demonstrations of this by others already.
Exactly, I need to set 30 minutes and countdown to 0 showing seconds. I followed @Jeff_Hager Custom Component implementation and it’s incredible, but unstable, if the App loses focus it stops.
How were you able to reduce the space below the countdown? I made a slight adjustment to the script and got rid of the space above. But I can’t seem to find how to edit the space below:
Oh yes, the cause is the smallest height size of the web embed component, not the javascript code. To make it smaller, I added a container to set it with custom CSS (class name: iframeSize).
Hi. I replaced the code as you suggested, but I cannot make it work properly. It displays “Deadline: not set”. Probably it’s just a minor adjustment but I just can’t.