Timer Concept

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.

This should be a copyable template.
@Himaladin @Robert_Petitto

8 Likes

Visually, STUNNING!

This still doesn’t solve for to-the-second accuracy in the data editor though for visibility conditions, etc. correct?

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.

1 Like

Ya…that’s the rub :frowning:

Regardless, as always, you are the MAN.

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.

1 Like

You’re using setInterval, and I don’t see the use of delay. Do you mean they are the same? I’ve tested setInterval doesn’t work in Glide tables.

Thank you for sharing.

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.

1 Like

It seems like a dead-end to work in the data editor unless accepting a delay time at the beginning.

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.

It’s very interesting. I searched many posts here and saw @Uzo posts about timers and delays, but there is no way to contact or message him. Why?

@Jeff_Hager, I use the same technique for both the clock display and the countdown, all within the web embed component.

ScreenRecording2024-06-16at22.21.01-ezgif.com-video-to-webp-converter

1 Like