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