-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·421 lines (411 loc) · 19.9 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!doctype html>
<html>
<head runat="server">
<meta charset="utf-8">
<title>老G博客网站</title>
<meta name="keywords" content="个人博客,老G个人博客,个人博客模板,老G" />
<meta name="description" content="老G个人博客,是一个支持springboot个人原创网站。" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/myspringblog/css/base.css" rel="stylesheet"/>
<link href="/myspringblog/css/index.css" rel="stylesheet"/>
<link href="/myspringblog/css/m.css" rel="stylesheet"/>
<link href="/myspringblog/css/music.css" rel="stylesheet"/>
<script src="/myspringblog/js/jquery.min.js" ></script>
<link href="/myspringblog/css/calendar.css" rel="stylesheet" />
<script src="/myspringblog/js/calendar.js" type="text/javascript"></script>
<script src="/myspringblog/js/fest.js" type="text/javascript"></script>
<script src="/myspringblog/js/hc-sticky.js"></script>
<script src="/myspringblog/js/comm.js"></script>
<!--[if lt IE 9]>
<script src="/myspringblog/js/modernizr.js"></script>
<![endif]-->
<link rel="stylesheet" href="/myspringblog/www.wenjunjiang.win/css/gitment.css">
<script src="/myspringblog/www.wenjunjiang.win/js/gitment.js"></script>
<link rel="stylesheet" href="/myspringblog/editormd/css/editormd.preview.css" />
<script src="/myspringblog/editormd/editormd.js"></script>
<script src="/myspringblog/editormd/lib/marked.min.js"></script>
<script src="/myspringblog/editormd/lib/prettify.min.js"></script>
</head>
<body>
<div id="header"></div>
<script>
$("#header").load("/myspringblog/header.html");
</script>
<div id="wrapper" class="wrapper">
<div id="test-markdown-view" style="display: none;"></div>
<form>
<main id="main" style="width:65%;display:inline-block;vertical-align: top;">
<!-- <div style="float:right;height:100px;border:1px solid #f00;width:100px;"></div>-->
<!-- <div style="border:1px solid #0f0;height:100px;"></div>-->
<div class="bloglist" style="width:100%;overflow:hidden;">
<ul id="bloglistul">
</ul>
</div>
<div id="blogurl" style="background: #fff;width: 100%">
</div>
<div id="container"></div>
<div style="clear: both;"></div>
</main>
<div id="sidebar" style="text-align:left;width: 32%;padding-left:30px;display:inline-block;vertical-align: top;">
<iframe class="about" style="padding-bottom: 15px" width="100%" scrolling="no" height="70" frameborder="0" allowtransparency="true" src="//i.tianqi.com/index.php?c=code&id=2&icon=1&num=3&site=12"></iframe>
<div id="calendar" style="margin-bottom:15px;" onload="fest();">
</div>
<div id="aside">
</div>
</div>
</form>
<!-- </div>-->
</div>
<script>
var toload = true;
asideload();
function asideload(){
if(toload)
$("#aside").load("/myspringblog/aside.html");
toload = false;
}
function aside(blogtagslist) {
window.wblogtagslist = Array.from(blogtagslist).sort();
// $(document).ready(function () {
setTimeout(function () {
var cloud = document.getElementById("cloud");
// $("#sidebar").attr("style","display:inline-block;");
// if(!cloud) asideload();
if(!toload) {
// var tag = document.getElementById("tag");
var count = 0;
window.wblogtagslist.forEach(function (currentValue, key, array) {
count++;
cloud.innerHTML += '<a href="#" onclick="tagClick(\'' + currentValue + '\');">' + currentValue + '</a>';
if(count == array.length) {
cloud.innerHTML = '<h2 class="hometitle">标签</h2>\n' +
' <ul id="tag">'+cloud.innerHTML+ "</ul>";
}
});
$("#cloud").load();
}
},5000);
// });
}
</script>
<script>
$.ajaxSetup({
async : false
});
var realloc = location.href;
var myloc = realloc.split("&code=");
var loc = myloc[0];
// var code = myloc[1];
// if(loc[loc.length -1] != "?")
var n1 = loc.length;//地址的总长度
var n2 = loc.indexOf("=");//取得=号的位置
var dengyu = loc.substr(n2+1, n1-n2);
if(loc.indexOf("?tag=") != -1)
var tag = decodeURI(dengyu);//从=号后面的内容
else if(loc.indexOf("?url=") != -1)
var url = decodeURI(dengyu);
tagClick();
if(url){urlClick(url);}
function githubblog() {
$.ajax({
url: "https://api.github.com/repos/jsonlog/myspringblog/contents/docs/blog",
async: false,//time
data: {},
type: "get",
dataType: "json",
success: function (data) {
var blog = [];
if (data != null) {
for (var j = 0; j < data.length; j++) {
blog.push(data[j].path.toString().replace("docs/",""));
}
console.log(blog);
// blog = ["blog/sample.html"];//test
// blog = ["markdown/sample.md"];//test
// blog = ["blog/sample.html", "blog/samplecopy.html", "blog/samplecopy10.html", "blog/samplecopy11.html", "blog/samplecopy12.html", "blog/samplecopy13.html", "blog/samplecopy14.html", "blog/samplecopy2.html", "blog/samplecopy3.html", "blog/samplecopy4.html", "blog/samplecopy5.html", "blog/samplecopy6.html", "blog/samplecopy7.html", "blog/samplecopy8.html", "blog/samplecopy9.html"];
githubblogAdd(blog);
}
},
error: function () {
console.log("githubajaxerror");
}
});
}
function urlClick(url) {
// $("#sidebar").hide();//show() = display:block
var list = document.getElementsByClassName("bloglist");
list[0].style.display = "none";
var blogurl = document.getElementById("blogurl");
// if(bloglist[url])
// blogurl.innerHTML = bloglist[url];
// else
// blogurl.innerHTML =
html(url,$("#blogurl")); //markdown
tagtolist(blogurl);
blogurl.style.display = "";
mygitment(url);
}
function mygitment(url) {
var container = document.getElementById("container");
container.style.display = "";
var gitment = new Gitment({
id: url.toString(), // 可选。默认为 location.href
owner: 'jsonlog',
repo: 'myspringblog',
oauth: {
client_id: '66a595b4bcb2d43ec283',
client_secret: 'ab351cbabd4121e4626a2c85b0ba4426fd85c414',
},
})
gitment.render('container')
}
function tagClick(tag) {
var count = new Array();
var list = document.getElementsByClassName("bloglist");
var ul = document.getElementById("bloglistul");
var li = ul.getElementsByTagName("li");
if(li.length == 0){ githubblog();}
var arr = [];
for (var i = 0; i < li.length; i++) {
if(li[i].getAttribute('timer')) {//fix other li
arr.push(li[i]);
var ids = "," + li[i].getAttribute("tagslist") + ",";
if (ids.indexOf("," + tag) != -1) {//contains + "," //TODO 子集
li[i].style.display = '';
count.push(li[i]);
} else {
li[i].style.display = tag ? 'none' : "";
}
}
}
if(count.length == 1){
// urlClick(count[0].title); //只有一篇文章直接打开,不显示列表
var readmore = count[0].getElementsByClassName("read")[0];
// count[0].style.display = 'none';
readmore.click();
tagClick();
// window.location.href += "?url="+count[0].title;
return;
}
arr.sort(function(a,b){
// console.log(getDate(a.getAttribute('timer'))+getDate(b.getAttribute('timer'))+(getDate(a.getAttribute('timer')) < getDate(b.getAttribute('timer'))));
// console.log(a,b);
return getDate(a.getAttribute('timer')) < getDate(b.getAttribute('timer'))?1:-1;
});
ul.innerHTML = "";
for(var i=0;i<arr.length;i++)
{
ul.appendChild(arr[i]); //将排好序的元素,重新塞到body里面显示。
}
var main = document.getElementById("main");
var childs = main.childNodes;
for(var i = childs.length - 1; i >= 0; i--) {
if(childs[i].nodeName.toLowerCase().indexOf("div")!= -1)
childs[i].style.display = "none";
}
list[0].style.display = "";
}
function dateFormat(longTypeDate){
var dateTypeDate = "";
var date = new Date();
date.setTime(longTypeDate);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
return y + '-' + m + '-' + d;
}
function sorthref(a,b) {
// console.log(a,b);//localeCompare
// if(!a) return true;
// if(!b) return false;
return a.toLowerCase().replace('http://','https://').replace("//www.","//").localeCompare(b.toLowerCase().replace('http://','https://').replace("//www.","//"));
}
function githubblogAdd(blog) {
var bloglist = {};
var blogtagslist = new Set();
for(var i = 0,len = blog.length; i < len; i++){
var bloglistul = document.getElementById('bloglistul');
if(blog[i].toLowerCase().indexOf("bookmark") != -1){
var Div = document.createElement('div');
$(Div).load("/myspringblog/"+blog[i]+" DL");//TODO
var classname = Div.getElementsByTagName("a");
for(var j=0;j< classname.length;j++){
// console.log(classname[j].valueOf())
if(bloglist[classname[j].href]) {
// console.log("duplicatehref",classname[j].href,bloglist[classname[j].href])
continue;
}
// var a = classname[j];
bloglistli = {};
bloglist[classname[j].href] = classname[j].outerHTML;
var oDiv = document.createElement('div');
bloglistul.appendChild(oDiv);
bloglistli.news_title = classname[j].innerText;
bloglistli.news_con = classname[j].origin;
bloglistli.timer = '2010-12-11';
if(blog[i].match("[0-9]{4}-[0-9]{2}-[0-9]{2}")) bloglistli.timer = blog[i].match("[0-9]{4}-[0-9]{2}-[0-9]{2}");
if(classname[j].getAttribute("add_date")) {
var add_date = classname[j].getAttribute("add_date");
if(add_date > 0 && add_date < 10000000000){//TODO Bookmark.
bloglistli.timer = dateFormat(add_date * 1000);
}
}
if(classname[j].getAttribute("time")) bloglistli.timer = classname[j].getAttribute("time");//
index = classname[j].origin.indexOf("//");
domain = classname[j].origin.substring(index+2).split(".");
if(classname[j].outerHTML.toLowerCase().indexOf("android") != -1 || classname[j].outerHTML.indexOf("安卓") != -1) bloglistli.tagslist = "android";
else if(domain.length > 2) bloglistli.tagslist = domain[1];
else bloglistli.tagslist = domain[0];//TODO replace
if(classname[j].getAttribute("tag")) bloglistli.tagslist += ","+classname[j].getAttribute("tag");//
tagslist = bloglistli.tagslist.split(",");
bloglistli.tags = "";
for(tags in tagslist){
blogtagslist.add(tagslist[tags]);
bloglistli.tags += "<a href='#' onclick='tagClick(\""+tagslist[tags]+"\")'>"+tagslist[tags]+"</a>";
}
oDiv.innerHTML = bloglistli.news_con;
oDiv.innerHTML =
' <li timer="' + bloglistli.timer + '" title="' + blog[i] + '" tagslist="' + bloglistli.tagslist + '">\n' +
' <dl style="width:100%;overflow:hidden;">\n' +
' <dt><a>' + bloglistli.news_title + '</a></dt>\n' +//word-wrap:break-word;
' <dd>\n' +
' <span class="bloginfo">' + oDiv.innerHTML + '</span>\n' +
' <p class="timeinfo"><span class="tags">' + bloglistli.tags + '</span><span class="date">' + bloglistli.timer + '</span></p>\n' +
' <a class="read" target="_blank" href="'+classname[j].href+'">阅读更多</a> \n' +
' </dd>\n' +
' </dl>\n' +
' </li>'
}
}else if(!bloglist[blog[i]]){
bloglistli = {};bloglist[blog[i]] = blog[i];
var oDiv = document.createElement('div');
bloglistul.appendChild(oDiv);
html(blog[i], $(oDiv))
// console.log(oDiv.innerHTML);
var classname = oDiv.getElementsByClassName("news_title");
bloglistli.news_title = classname[0].innerHTML;
classname = oDiv.getElementsByClassName("timer");
bloglistli.timer = classname[0].innerHTML;
classname = oDiv.getElementsByClassName("news_con");
bloglistli.news_con = classname[0].innerText;
tagtolist(oDiv, bloglistli, blogtagslist);
oDiv.innerHTML = bloglistli.news_con;//.replace('<a extends="" annotation="">','');//FIXME
oDiv.innerHTML =
' <li timer="' + bloglistli.timer + '" title="' + blog[i] + '" tagslist="' + bloglistli.tagslist + '"> <i style="display: none;" class="blogpic"><a><img src="/myspringblog/images/9.jpg" alt=""> </a></i>\n' +
' <dl style="width:100%;overflow:hidden;">\n' +
' <dt><a>' + bloglistli.news_title + '</a></dt>\n' +
' <dd>\n' +
' <span class="bloginfo">' + oDiv.innerHTML + '</span>\n' +
' <p class="timeinfo"><span class="tags">' + bloglistli.tags + '</span><span class="date">' + bloglistli.timer + '</span></p>\n' +
// ' <p class="timeinfo"><span class="date">'+bloglistli.timer +'</span><span class="tags">'+ bloglistli.tags+'</span></p>\n' +
' <a class="read" href="?url=' + blog[i] + '">阅读更多</a> \n' +
' </dd>\n' +
' </dl>\n' +
' </li>'
}else{
// console.log("duplicatelink",blog[i],bloglist[blog[i]])
}
if(i == blog.length - 1) {//.md; *.txt; *.rst; *.adoc
aside(blogtagslist);
// tagClick();
console.log("total:"+Object.keys(bloglist).length);
// console.log(Object.values(bloglist).sort());//sort(compareFn?: (a: T, b: T) => number): this;
// Object.values(bloglist).sort(sorthref).forEach(function(item,index){
// if(item.toLowerCase().indexOf('href="http') != -1)
// console.log((item));
// })
}
}
}
function markdown(file,div) {
$.ajaxSettings.async = false;
$.get("/myspringblog/"+file, function(response, status, xhr){
var start = response.indexOf("<!--{");
var end = response.indexOf("}-->");
if(start == -1 || end == -1) console.error("markdownstart"+start+"makrdownend"+end);
var json = response.substring(start+4,end+1);
response = response.substr(end+4);
var testmarkdownview = document.getElementById("test-markdown-view");
testmarkdownview.innerHTML = "";
var testView = editormd.markdownToHTML("test-markdown-view", {
markdown : response, // Also, you can dynamic set Markdown text
// htmlDecode : true, // Enable / disable HTML tag encode.
// htmlDecode : "style,script,iframe", // Note: If enabled, you should filter some dangerous HTML tags for website security.
});
var li = JSON.parse(json);
var tags = li.tagslist.replace(new RegExp(',',"g"),"</a><a>");
// response = response.replace("/<!--.*-->/gm","");
// alert(response);
var id = file.replace(new RegExp('/',"g"),"");
div.html('<h3 class="news_title">'+li.news_title+'</h3>\n' +
'<div class="bloginfo">\n' +
' <ul>\n' +
' <li class="timer">'+li.timer+'</li>\n' +
' </ul>\n' +
'</div>\n' +
'<div class="tags"><a>'+tags+'</a></div>\n' +
'<div class="news_con"><div class="markdown-body editormd-html-preview">'+testmarkdownview.innerHTML+'</div></div>');//marked(response)
});
}
function html2(file,div) {
$.ajax({
url: "./"+file+" #main",
async: false,
type: "get",
dataType: "html",
success: function (data) {
div.html(data);
},
error: function () {
console.log("githubajaxerror");
}
});
}
function html(file,div) {
$.ajaxSettings.async = false;
if(file.indexOf(".md") != -1) markdown(file,div);
else div.load("/myspringblog/"+file+" #main");
}
function tagtolist(oDiv, bloglistli, blogtagslist) {
var classname = oDiv.getElementsByClassName("tags");
var a=classname[0].getElementsByTagName("a");
var tagslist = "";
for(var j=0;j<a.length;j++){
tagslist += ","+a[j].innerHTML;
classname[0].innerHTML= classname[0].innerHTML.replace("<a>"+a[j].innerHTML+"</a>","<a href='#' onclick='tagClick(\""+a[j].innerHTML+"\");'>"+a[j].innerHTML+"</a>");
if(blogtagslist) blogtagslist.add(a[j].innerHTML);
}
if(bloglistli)
{
bloglistli.tags = classname[0].innerHTML;
bloglistli.tagslist = tagslist.substr(1);
}
}
function getDate(strDate){
// console.log(strDate)
var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
function (d) { return parseInt(d, 10) - 1; }).match(/\d+/g) + ')');
// console.log(date)
return date;
}
</script>
<div id="footer"></div>
<script>
$("#footer").load("/myspringblog/footer.html");
</script>
<script>
$(function(){
/* 单机li进行页面跳转 */
$("ul li").click(function(){
/*当前标签下的a标签*/
var obj = $(this).children("a");
/*获取第一个a标签,进行跳转*/
window.location.href=$(obj[0]).attr("href");
});
})
</script>
<a href="#" class="cd-top">Top</a>
</body>
</html>