packages/demo-html/public/behavioral-js/time-js.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Open: time (via API)</title>
<link rel="stylesheet" href="/lib/css/popup.css" />
</head>
<body>
<h1>This popup opens in <span id="seconds">5</span> seconds (via API)</h1>
<p>The popup is opened automatically after the given time has passed.</p>
<h2>Customize the time</h2>
<p>This can be set on "Share" page as well.</p>
<form action="" method="get">
<label for="time">Milliseconds</label>
<input id="time" name="ms" type="number" value="5000" step="1000" min="1000" />
<button type="submit">Set</button>
</form>
<script src="../lib/embed-next.js"></script>
<script>
const ms = parseInt(new URL(window.location.href).searchParams.get("ms"), 10) || document.getElementById("time").value;
if (ms) {
document.getElementById("time").value = ms;
document.getElementById("seconds").innerHTML = Math.round(ms / 1000);
document.getElementById("seconds").innerHTML = Math.round(ms / 1000);
}
window.tf.createPopup("moe6aa", {
open: "time",
openValue: ms,
});
</script>
</body>
</html>