github.com/pojntfx/hydrapp/hydrapp@v0.0.0-20240516002902-d08759d6ca9f/pkg/generators/index_vanillajs_rest.html.tpl (about)

     1  <!DOCTYPE html>
     2  <html lang="en">
     3    <head>
     4      <meta charset="UTF-8" />
     5      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
     6      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     7      <meta name="color-scheme" content="light dark">
     8      <title>{{ .AppName }}</title>
     9    </head>
    10    <body>
    11      <h1>{{ .AppName }}</h1>
    12  
    13      <ul>
    14        <li>
    15          <a id="server-time-link">Get server time</a>
    16        </li>
    17  
    18        <li>
    19          <a id="ifconfig-io-link"
    20            >Get results of ifconfig.io/all.json proxied through backend</a
    21          >
    22        </li>
    23  
    24        <li>
    25          <a id="envs-link">List all system environment variables</a>
    26        </li>
    27      </ul>
    28  
    29      <script>
    30        function getUrlParameter(location, name) {
    31          name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    32          var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
    33          var results = regex.exec(location);
    34          return results === null
    35            ? ""
    36            : decodeURIComponent(results[1].replace(/\+/g, " "));
    37        }
    38  
    39        document.getElementById("server-time-link").href =
    40          getUrlParameter(window.location.href, "socketURL") + "/servertime";
    41  
    42        document.getElementById("ifconfig-io-link").href =
    43          getUrlParameter(window.location.href, "socketURL") + "/ifconfigio";
    44  
    45        document.getElementById("envs-link").href =
    46          getUrlParameter(window.location.href, "socketURL") + "/envs";
    47      </script>
    48    </body>
    49  </html>