github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/tools/godoc/short/tmpl.go (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by the Apache 2.0 3 // license that can be found in the LICENSE file. 4 5 // +build appengine 6 7 package short 8 9 const templateHTML = ` 10 <!doctype HTML> 11 <html> 12 <head> 13 <title>golang.org URL shortener</title> 14 <style> 15 body { 16 background: white; 17 } 18 input { 19 border: 1px solid #ccc; 20 } 21 input[type=text] { 22 width: 400px; 23 } 24 input, td, th { 25 color: #333; 26 font-family: Georgia, Times New Roman, serif; 27 } 28 input, td { 29 font-size: 14pt; 30 } 31 th { 32 font-size: 16pt; 33 text-align: left; 34 padding-top: 10px; 35 } 36 .autoselect { 37 border: none; 38 } 39 .error { 40 color: #900; 41 } 42 table { 43 margin-left: auto; 44 margin-right: auto; 45 } 46 </style> 47 </head> 48 <body> 49 50 <table> 51 52 {{with .Error}} 53 <tr> 54 <th colspan="3">Error</th> 55 </tr> 56 <tr> 57 <td class="error" colspan="3">{{.}}</td> 58 </tr> 59 {{end}} 60 61 <tr> 62 <th>Key</th> 63 <th>Target</th> 64 <th></th> 65 </tr> 66 67 <form method="POST" action="{{.Prefix}}"> 68 <tr> 69 <td><input type="text" name="key"{{with .New}} value="{{.Key}}"{{end}}></td> 70 <td><input type="text" name="target"{{with .New}} value="{{.Target}}"{{end}}></td> 71 <td><input type="submit" name="do" value="Add"> 72 </tr> 73 </form> 74 75 {{with .Links}} 76 <tr> 77 <th>Short Link</th> 78 <th> </th> 79 <th> </th> 80 </tr> 81 {{range .}} 82 <tr> 83 <td><input class="autoselect" type="text" orig="{{$.BaseURL}}/{{.Key}}" value="{{$.BaseURL}}/{{.Key}}"></td> 84 <td><input class="autoselect" type="text" orig="{{.Target}}" value="{{.Target}}"></td> 85 <td> 86 <form method="POST" action="{{$.Prefix}}"> 87 <input type="hidden" name="key" value="{{.Key}}"> 88 <input type="submit" name="do" value="Delete" class="delete"> 89 </form> 90 </td> 91 </tr> 92 {{end}} 93 {{end}} 94 95 </table> 96 97 </body> 98 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> 99 <script type="text/javascript">window.jQuery || document.write(unescape("%3Cscript src='/doc/jquery.js' type='text/javascript'%3E%3C/script%3E"));</script> 100 <script> 101 $(document).ready(function() { 102 $('.autoselect').each(function() { 103 $(this).click(function() { 104 $(this).select(); 105 }); 106 $(this).change(function() { 107 $(this).val($(this).attr('orig')); 108 }); 109 }); 110 $('.delete').click(function(e) { 111 var link = $(this).closest('tr').find('input').first().val(); 112 var ok = confirm('Delete this link?\n' + link); 113 if (!ok) { 114 e.preventDefault(); 115 return false; 116 } 117 }); 118 }); 119 </script> 120 </html> 121 `