|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="zh-CN"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <title>创建 issue - github-bot</title> |
| 6 | + <meta http-equiv="X-UA-Compatible" content="IE=Edge"> |
| 7 | + <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"> |
| 8 | + <style type="text/css"> |
| 9 | + * { |
| 10 | + box-sizing: border-box; |
| 11 | + -webkit-box-sizing: border-box; |
| 12 | + } |
| 13 | + body, |
| 14 | + textarea, |
| 15 | + input { |
| 16 | + font-size: 14px; |
| 17 | + } |
| 18 | + body { |
| 19 | + margin: 0 auto; |
| 20 | + max-width: 600px; |
| 21 | + padding: 10px; |
| 22 | + } |
| 23 | + h1 { |
| 24 | + font-size: 30px; |
| 25 | + } |
| 26 | + ul { |
| 27 | + list-style: none; |
| 28 | + padding: 0; |
| 29 | + } |
| 30 | + p { |
| 31 | + color: #999; |
| 32 | + } |
| 33 | + li { |
| 34 | + padding-bottom: 30px; |
| 35 | + position: relative; |
| 36 | + padding-left: 100px; |
| 37 | + } |
| 38 | + sub { |
| 39 | + color: #999; |
| 40 | + padding-left: 5px; |
| 41 | + vertical-align: middle; |
| 42 | + } |
| 43 | + input[type=text], |
| 44 | + textarea { |
| 45 | + border: 1px solid #ccc; |
| 46 | + outline: none; |
| 47 | + width: 400px; |
| 48 | + line-height: 32px; |
| 49 | + padding: 0 5px; |
| 50 | + } |
| 51 | + label { |
| 52 | + position: absolute; |
| 53 | + top: 0; |
| 54 | + left: 0; |
| 55 | + width: 100px; |
| 56 | + line-height: 32px; |
| 57 | + text-align: right; |
| 58 | + } |
| 59 | + select { |
| 60 | + height: 32px; |
| 61 | + border: 1px solid #ccc; |
| 62 | + } |
| 63 | + button[type=submit] { |
| 64 | + border: none; |
| 65 | + background-color: #009688; |
| 66 | + height: 30px; |
| 67 | + padding: 0 20px; |
| 68 | + border-radius: 0; |
| 69 | + color: #fff; |
| 70 | + cursor: pointer; |
| 71 | + } |
| 72 | + code { |
| 73 | + background-color: rgba(27,31,35,0.05); |
| 74 | + border-radius: 3px; |
| 75 | + padding: 4px; |
| 76 | + } |
| 77 | + footer { |
| 78 | + text-align: center; |
| 79 | + font-size: 12px; |
| 80 | + } |
| 81 | + |
| 82 | + @media screen and (max-width: 600px) { |
| 83 | + h1 { |
| 84 | + font-size: 20px; |
| 85 | + } |
| 86 | + li { |
| 87 | + padding-left: 0; |
| 88 | + } |
| 89 | + label { |
| 90 | + position: static; |
| 91 | + display: block; |
| 92 | + text-align: left; |
| 93 | + width: auto; |
| 94 | + } |
| 95 | + input[type=text], |
| 96 | + textarea, |
| 97 | + select, |
| 98 | + button[type=submit] { |
| 99 | + display: block; |
| 100 | + width: 100% !important; |
| 101 | + } |
| 102 | + sub { |
| 103 | + display: block; |
| 104 | + padding-left: 0; |
| 105 | + padding-top: 6px; |
| 106 | + } |
| 107 | + } |
| 108 | + </style> |
| 109 | +</head> |
| 110 | +<body> |
| 111 | + <h1>创建 issue - <a href="https://github.com/xuexb/github-bot" target="_blank">github-bot</a></h1> |
| 112 | + <p> |
| 113 | + 接受任何建议和意见,请认真填写下面表单,感谢您的反馈! |
| 114 | + </p> |
| 115 | + <form action=""> |
| 116 | + <ul> |
| 117 | + <li> |
| 118 | + <label for="type">这是一个:</label> |
| 119 | + <select required id="type"> |
| 120 | + <option value="bug">错误反馈</option> |
| 121 | + <option value="enhancement">新的功能</option> |
| 122 | + <option value="question">咨询</option> |
| 123 | + <option value="suggestion">建议</option> |
| 124 | + </select> |
| 125 | + </li> |
| 126 | + <li> |
| 127 | + <label for="title">issue 标题:</label> |
| 128 | + <input type="text" id="title" required> |
| 129 | + </li> |
| 130 | + <li id="node-version-wrap"> |
| 131 | + <label for="node">nodejs 版本:</label> |
| 132 | + <input style="width: 100px" type="text" id="node" pattern="^[vV]?(\d\.?)+$" required> |
| 133 | + <sub>使用 <code>node -v</code> 可查看版本号。</sub> |
| 134 | + </li> |
| 135 | + <li> |
| 136 | + <label for="content">内容:</label> |
| 137 | + <textarea style="height: 160px; line-height: 25px;" id="content" required></textarea> |
| 138 | + </li> |
| 139 | + <li> |
| 140 | + <button type="submit">发布</button><sub>发布是指生成指定内容到 Github 的 <a href="https://github.com/xuexb/github-bot/issues/new" target="_blank">issue</a> 页面,然后手动提交。</sub> |
| 141 | + </li> |
| 142 | + </ul> |
| 143 | + </form> |
| 144 | + |
| 145 | + <footer>© <a href="https://xuexb.com?create-issue">前端小武</a></footer> |
| 146 | + |
| 147 | + <script> |
| 148 | + var $ = function (selector) { |
| 149 | + return document.querySelector(selector); |
| 150 | + } |
| 151 | + $('#type').addEventListener('change', function () { |
| 152 | + if (this.value === 'bug') { |
| 153 | + $('#node').setAttribute('required', true); |
| 154 | + $('#node-version-wrap').style.display = 'block'; |
| 155 | + } |
| 156 | + else { |
| 157 | + $('#node').removeAttribute('required'); |
| 158 | + $('#node-version-wrap').style.display = 'none'; |
| 159 | + } |
| 160 | + }); |
| 161 | + $('form').addEventListener('submit', function (event) { |
| 162 | + var type = $('#type').value; |
| 163 | + var title = $('#title').value; |
| 164 | + var node = type === 'bug' ? $('#node').value : ''; |
| 165 | + var content = $('#content').value; |
| 166 | + |
| 167 | + event.preventDefault(); |
| 168 | + |
| 169 | + if (!title) { |
| 170 | + return alert('请填写 "issue 标题"'); |
| 171 | + } |
| 172 | + else if (type === 'bug' && !node) { |
| 173 | + return alert('请填写 "nodejs 版本"'); |
| 174 | + } |
| 175 | + else if (!content) { |
| 176 | + return alert('请填写 "内容"'); |
| 177 | + } |
| 178 | + |
| 179 | + var body = []; |
| 180 | + |
| 181 | + if (node) { |
| 182 | + body.push('nodejs 版本号:' + node); |
| 183 | + body.push(''); |
| 184 | + body.push('---'); |
| 185 | + body.push(''); |
| 186 | + } |
| 187 | + |
| 188 | + body.push(content); |
| 189 | + |
| 190 | + body.push(''); |
| 191 | + body.push('<!-- label: ' + type + ' -->'); |
| 192 | + body.push('<!-- by create-issue -->'); |
| 193 | + body.push('<!-- 上面2个注释请不要删除,登录您的帐号提交 issue 即可 -->'); |
| 194 | + |
| 195 | + window.open('https://github.com/xuexb/github-bot/issues/new?title=' + encodeURIComponent(title) + '&body=' + encodeURIComponent(body.join('\n'))); |
| 196 | + }); |
| 197 | + </script> |
| 198 | +</body> |
| 199 | +</html> |
0 commit comments