aboutsummaryrefslogtreecommitdiffstats
path: root/template.go
blob: 242d0a2c6c21cb73e538ea4c6372112d19e05d8e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package gopherproxy

var tpltext = `<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>{{ .Title }}</title>
    <link rel="preload" href="/assets/IBMPlexMono-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
    <style>
      {{ .Style | safeCss }}
    </style>
  </head>
  <body>
    <main class="wrap">
      <pre class="content">
        {{- if .Lines -}}
          {{- $content := "" -}}
          {{- range .Lines -}}
            {{- if ne $content "" -}}
              {{- $content = printf "%s\n" $content -}}
            {{- end -}}
            {{- if .Link -}}
              {{- $content = printf "%s%s" $content (printf "<span class=\"link-type\">%s </span> <a class=\"link link--%s\" href=\"%s\">%s</a>" .Type .Type .Link .Text) -}}
            {{- else -}}
              {{- $content = printf "%s%s" $content (printf "     %s" .Text) -}}
            {{- end -}}
          {{- end -}}
          {{- $content | safeHtml -}}
        {{- else -}}
          {{- .RawText -}}
        {{- end -}}
      </pre>
    </main>
    <script type="text/javascript">
      var qry=document.getElementsByClassName('link--QRY')
      var i=qry.length
      while (i--) {
        qry[i].addEventListener('click', function(e) {
          e.preventDefault();
          var resp=prompt("Please enter required input: ", "")
          if (resp !== null && resp !== "") window.location = e.target.href + "?" + resp
          return false;
        })
      }
    </script>
  </body>
</html>`