diff options
Diffstat (limited to 'template.go')
| -rw-r--r-- | template.go | 71 |
1 files changed, 43 insertions, 28 deletions
diff --git a/template.go b/template.go index 81730a6..242d0a2 100644 --- a/template.go +++ b/template.go | |||
| @@ -2,32 +2,47 @@ package gopherproxy | |||
| 2 | 2 | ||
| 3 | var tpltext = `<!doctype html> | 3 | var tpltext = `<!doctype html> |
| 4 | <html> | 4 | <html> |
| 5 | <head> | 5 | <head> |
| 6 | <meta charset="utf-8"> | 6 | <meta charset="utf-8"> |
| 7 | <meta name="viewport" content="width=device-width, initial-scale=1" /> | 7 | <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 8 | <title>{{.Title}}</title> | 8 | <title>{{ .Title }}</title> |
| 9 | <link rel="preload" href="/assets/IBMPlexMono-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous" /> | 9 | <link rel="preload" href="/assets/IBMPlexMono-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous" /> |
| 10 | <style> | 10 | <style> |
| 11 | {{.Style | safeCss}} | 11 | {{ .Style | safeCss }} |
| 12 | </style> | 12 | </style> |
| 13 | </head> | 13 | </head> |
| 14 | <body> | 14 | <body> |
| 15 | <main class="wrap"> | 15 | <main class="wrap"> |
| 16 | <pre class="content"> | 16 | <pre class="content"> |
| 17 | {{if .Lines}}{{range .Lines}} {{if .Link}}<span class="link-type"> {{.Type}} </span> <a class="link link-{{ .Type }}" href="{{.Link}}">{{.Text}}</a>{{else}} {{.Text}}{{end}} | 17 | {{- if .Lines -}} |
| 18 | {{end}}{{else}}{{.RawText}}{{end}}</pre> | 18 | {{- $content := "" -}} |
| 19 | </main> | 19 | {{- range .Lines -}} |
| 20 | <script type="text/javascript"> | 20 | {{- if ne $content "" -}} |
| 21 | var qry=document.getElementsByClassName('link-QRY') | 21 | {{- $content = printf "%s\n" $content -}} |
| 22 | var i=qry.length | 22 | {{- end -}} |
| 23 | while (i--) { | 23 | {{- if .Link -}} |
| 24 | qry[i].addEventListener('click', function(e) { | 24 | {{- $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) -}} |
| 25 | e.preventDefault(); | 25 | {{- else -}} |
| 26 | var resp=prompt("Please enter required input: ", "") | 26 | {{- $content = printf "%s%s" $content (printf " %s" .Text) -}} |
| 27 | if (resp !== null && resp !== "") window.location = e.target.href + "?" + resp | 27 | {{- end -}} |
| 28 | return false; | 28 | {{- end -}} |
| 29 | }) | 29 | {{- $content | safeHtml -}} |
| 30 | } | 30 | {{- else -}} |
| 31 | </script> | 31 | {{- .RawText -}} |
| 32 | </body> | 32 | {{- end -}} |
| 33 | </pre> | ||
| 34 | </main> | ||
| 35 | <script type="text/javascript"> | ||
| 36 | var qry=document.getElementsByClassName('link--QRY') | ||
| 37 | var i=qry.length | ||
| 38 | while (i--) { | ||
| 39 | qry[i].addEventListener('click', function(e) { | ||
| 40 | e.preventDefault(); | ||
| 41 | var resp=prompt("Please enter required input: ", "") | ||
| 42 | if (resp !== null && resp !== "") window.location = e.target.href + "?" + resp | ||
| 43 | return false; | ||
| 44 | }) | ||
| 45 | } | ||
| 46 | </script> | ||
| 47 | </body> | ||
| 33 | </html>` | 48 | </html>` |
