Formatting countdown timer

25 views
Skip to first unread message

Paul Vanags

unread,
Nov 7, 2024, 3:53:00 AM11/7/24
to LIONESS Lab help and discussion
Hi forum - is there a way to format the countdown timer for pages that have a timout?

I want to set the countdown timer to a non-integer and if I do that it counts down in whole seconds e.g. 3.5, 2.5, 1.5 etc which I want to avoid, e.g. by rounding the numbers

When I look at the source html the countdown timer appears (and changes second by second) in the html itsel so I can't work out how to change it

Any ideas?

Paul.

in...@lioness-lab.org

unread,
Nov 15, 2024, 11:05:24 AM11/15/24
to Paul Vanags, LIONESS Lab help and discussion

Hi Paul,

 

You could define a timer yourself with a bit of HTML and JavaScript and use the (hack) function “toNextPage3()” to move on to the next pre-programmed page.

 

So in a text element: <div id="timer">10</div>

 

And then in a JS element:

 

// Set the countdown duration in seconds

const countdownDuration = 10; // Change this to your desired duration

let remainingTime = countdownDuration;

 

// Select the timer element

const timerElement = document.getElementById('timer');

 

// Function to trigger when countdown ends

function onTimeout() {

  timerElement.textContent = "Time's up!";

  toNextPage3()

  // Add your custom action here

}

 

// Update the countdown every second

const interval = setInterval(() => {

  if (remainingTime > 0) {

    timerElement.textContent = remainingTime;

    remainingTime--;

  } else {

    clearInterval(interval); // Stop the countdown

    onTimeout(); // Trigger the action

  }

}, 1000);

 

 

 

Which should give you full control over the timer.

 

Hope this helps!

 

Cheers, Lucas

--
You received this message because you are subscribed to the Google Groups "LIONESS Lab help and discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lioness-lab...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/lioness-lab/d4a71042-9b71-40b9-a48f-daf8a8af273en%40googlegroups.com.

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages