Typeform/embed

View on GitHub
packages/demo-html/public/behavioral-html/time-html.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Open: time (via embed code)</title>
    <link rel="stylesheet" href="/lib/css/popup.css" />
  </head>
  <body>
    <h1>This popup opens in <span id="seconds">5</span> seconds (via embed code)</h1>
    <p>The popup is opened automatically after the given time has passed.</p>
    <a
      id="popup"
      class="typeform-share"
      data-tf-popup="moe6aa"
      data-tf-medium="unit-test"
      data-tf-open="time"
      data-tf-open-value="5000"
    >
      Open the popup manually instead
    </a>

    <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>
      const ms = parseInt(new URL(window.location.href).searchParams.get("ms"), 10);
      if (ms) {
        document.getElementById("popup").dataset.tfOpenValue = ms;
        document.getElementById("time").value = ms;
        document.getElementById("seconds").innerHTML = Math.round(ms / 1000);
      }
    </script>

    <script src="../lib/embed-next.js"></script>
  </body>
</html>