-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
277 lines (240 loc) · 10.6 KB
/
index.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.6, maximum-scale=1.5, user-scalable=no">
<meta name="theme-color" content="#03992b">
<link href="bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" media="screen" href="style.css">
<link href="themes/default.css" rel="stylesheet" id="themecss">
<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="lodash.min.js"></script>
<head>
<title>GithuBlog</title>
</head>
<script>
var config;
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
function createxmlHttpRequest() {
if(window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else if(window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function doGetJSON(url,fun) {
createxmlHttpRequest();
xmlHttp.open("GET", url);
xmlHttp.send(null);
xmlHttp.onreadystatechange = function() {
if((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
fun&fun(JSON.parse(xmlHttp.responseText));
}
}
}
var configJSON = 'config.json'
//编写url位置
doGetJSON(configJSON,function(data){
config = data[document.domain]
loadPages()
var pageIndex = getQueryVariable("p");
if (pageIndex == false){
loadIssuses(0)
}else{
loadIssuses(pageIndex)
}
// change css
var css = document.getElementById("themecss")
css.setAttribute("href","themes/" + config.theme + ".css")
})
function loadPages(){
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var bb = JSON.parse(xmlhttp.responseText)
console.log(bb)
// parseAndRender(bb.body)
// loadMermaidOnNeed()
let img = document.getElementById("headImg")
img.setAttribute("src",bb.owner.avatar_url)
img.className = "img-title"
let name = document.getElementById("owner")
name.innerText = bb.owner.login
name.setAttribute("display","inline-block")
name.setAttribute("href","https://github.com/"+bb.owner.login)
let ghText = document.getElementById("githublogText")
ghText.setAttribute("herf","https://github.com/"+ bb.owner.login + "/githublog")
// name.setAttribute("href",bb[0].repository_url)
let issuesCount = bb.open_issues;
let pageCount = (issuesCount + 9) / 10;
var container = document.getElementById("pages")
for(i = 1;i < pageCount; i++){
var page = document.createElement("a")
page.className = "pageLink"
// iss.setAttribute("onclick","window.open('"+"https://taontech.top/issuse.html?iid="+issuse.number+"')")
// iss.setAttribute("onclick","window.open('"+"issuse.html?iid="+issuse.number+"')")
// title.herf = issuse.html_url
page.setAttribute("href","/?p="+i)
page.innerText = " 第 "+i+" 页 "
container.appendChild(page)
}
// bb.forEach(issuse => {
// var container = document.getElementById("blog")
// var iss = document.createElement("div")
// iss.className = "card row"
// // iss.setAttribute("onclick","window.open('"+"https://taontech.top/issuse.html?iid="+issuse.number+"')")
// // iss.setAttribute("onclick","window.open('"+"issuse.html?iid="+issuse.number+"')")
// var titlediv = document.createElement("div")
// titlediv.className = "header"
// var title = document.createElement("a")
// // title.herf = issuse.html_url
// title.setAttribute("href","issuse.html?iid="+issuse.number)
// title.innerText = issuse.title
// titlediv.appendChild(title)
// // titlediv.setAttribute("href",issuse.html_url)
// iss.appendChild(titlediv)
// var date = document.createElement("div")
// date.className = "container"
// var datestring = document.createElement("p")
// datestring.innerText = issuse.created_at + " 📝" + issuse.comments
// date.appendChild(datestring)
// iss.appendChild(date)
// var des = document.createElement("div")
// des.className = "preview"
// var desstring = document.createElement("p")
// if(issuse.body == null){
// issuse.body = "No description provided."
// }
// desstring.innerText = issuse.body.substr(0, 180).replace(/(\r\n|\n|\r)/gm, "")
// des.appendChild(desstring)
// iss.appendChild(des)
// container.appendChild(iss)
// });
}
}
xmlhttp.open("GET","https://api.github.com/repos/"+config.owner+"/"+ config.repo,true);
xmlhttp.send();
}
function loadIssuses(pageIndex){
// var writer = new commonmark.HtmlRenderer({ sourcepos: true });
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var bb = JSON.parse(xmlhttp.responseText)
// console.log(bb)
// // parseAndRender(bb.body)
// // loadMermaidOnNeed()
// let img = document.getElementById("headImg")
// img.setAttribute("src",bb[0].user.avatar_url)
// img.className = "img-title"
// let name = document.getElementById("owner")
// name.innerText = bb[0].user.login
// name.setAttribute("display","inline-block")
// name.setAttribute("href","https://github.com/"+bb[0].user.login)
// let ghText = document.getElementById("githublogText")
// ghText.setAttribute("herf","https://github.com/"+bb[0].user.login + "/githublog")
// name.setAttribute("href",bb[0].repository_url)
bb.forEach(issuse => {
var container = document.getElementById("blog")
var iss = document.createElement("div")
iss.className = "card row"
// iss.setAttribute("onclick","window.open('"+"https://taontech.top/issuse.html?iid="+issuse.number+"')")
// iss.setAttribute("onclick","window.open('"+"issuse.html?iid="+issuse.number+"')")
var titlediv = document.createElement("div")
titlediv.className = "header"
var title = document.createElement("a")
// title.herf = issuse.html_url
// title.setAttribute("href","issuse.html?iid="+issuse.number)
title.setAttribute("href","issuse.html#"+issuse.number)
title.innerText = issuse.title
titlediv.appendChild(title)
// titlediv.setAttribute("href",issuse.html_url)
iss.appendChild(titlediv)
var date = document.createElement("div")
date.className = "container"
var datestring = document.createElement("p")
datestring.innerText = issuse.created_at + " 📝" + issuse.comments
date.appendChild(datestring)
iss.appendChild(date)
var des = document.createElement("div")
des.className = "preview"
var desstring = document.createElement("p")
if(issuse.body == null){
issuse.body = "No description provided."
}
desstring.innerText = issuse.body.substr(0, 180).replace(/(\r\n|\n|\r)/gm, "")
// 缓存
localStorage.setItem(issuse.number,JSON.stringify(issuse))
des.appendChild(desstring)
iss.appendChild(des)
container.appendChild(iss)
});
}
}
localStorage.clear();
xmlhttp.open("GET","https://api.github.com/repos/"+config.owner+"/"+ config.repo + "/"+"issues?per_page=10&page="+pageIndex,true);
xmlhttp.send();
}
</script>
<style>
#particles-js {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
z-index: 1;
}
#ownerline {
align-items: center;
background-color: rgb(3, 153, 43);
/* opacity: 0.7; */
height: 70px;
overflow: hidden;
display: inline-flex;
width: 100%;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
/* z-index: 1; */
}
#blog {
padding-top: 40px;
}
</style>
<body class="body_issuse">
<div id="particles-js" width="50%"></div>
<div id="ownerline" >
<div>
<img id="headImg"></img>
</div>
<a class="ownerName owner-span" id="owner"></a>
<a href="javascript:location.href='https://github.com/' + config.owner + '/githublog/issues/new'" class="githublog_text" id="githublogText"> + New </a>
</div>
<div class="blogContainer" id="blog"></div>
<div class="pagesContainer" id="pages">
""
</div>
<a href="https://ipw.cn/ipv6webcheck/?site=ipw.cn" title="本站支持IPv6访问" target='_blank'><img style='display:inline-block;vertical-align:middle' alt="本站支持IPv6访问" src="https://static.ipw.cn/icon/ipv6-s1.svg"></a>
<!-- scripts -->
<script src="particles.min.js"></script>
<script src="app.js"></script>
</body>
</html>