<!DOCTYPE html>
<html>
  <head>
    <title>agbrs crash backtrace</title>
    <style>
      body {
        margin: 1em auto;
        max-width: 40em;
        padding: 0 0.62em 3.24em;
        font: 1.2em/1.62 sans-serif;
      }
      h1,
      h2,
      h3 {
        line-height: 1.2;
      }
      .backtrace {
        display: flex;
        gap: 10px;
        justify-content: center;
      }
    </style>
  </head>
  <body>
    <h1>agbrs crash backtrace viewer</h1>
    <p>This page will eventually let you view backtraces in the browser.</p>
    <p>
      For now you can copy the backtrace code here and use it with
      <code>agb-addr2line</code>
    </p>
    <p class="backtrace">
      <label for="backtrace">Backtrace:</label>
      <input id="backtrace" type="text" />
      <button id="backtraceCopy">Copy</button>
    </p>

    <script>
      const updateBacktrace = () => {
        if (window.location.hash.length > 1) {
          backtrace.value = window.location.hash.slice(1);
        }
      };

      updateBacktrace();

      window.addEventListener("hashchange", updateBacktrace);

      backtraceCopy.addEventListener("click", (evt) => {
        evt.preventDefault();
        navigator.clipboard.writeText(backtrace.value);
      });
    </script>
  </body>
</html>