How can I modify the below js code for a 45 seconds timer or 1 minute and 20-second timer?
// Display countdown
var date0 = new Date();
var timeout = date0.getTime() + %remain% * 1000;
console.log(timeout);
function updateCountdown() {
// Calculate time
var date = new Date();
console.log(date)
var time = Math.ceil((timeout - date.getTime() - 50) / 1000); // remaining time in seconds
// Display time
var out = document.getElementById("remain");
if (!out) {
return;
}
while (out.lastChild) {
out.removeChild(out.lastChild);
}
var minutes = Math.floor(time / 60);
var seconds = String(time - 60 * minutes);
if (seconds.length < 2) seconds = "0" + seconds;
var display = String(minutes) + ":" + seconds;
var displayNode = document.createTextNode(display);
out.appendChild(displayNode);
}
// Hide Next button (optional)
SoSciTools.submitButtonsHide();
// Initialize forwarding
SoSciTools.attachEvent(window, "load", function(evt) {
// Additional timer to update the countdown
window.setInterval(updateCountdown, 1000);
updateCountdown();
// Start timer to forward automatically
window.setTimeout(goNext, %remain% * 1000);
});