-
Notifications
You must be signed in to change notification settings - Fork 148
/
页尾.html
298 lines (280 loc) · 11.8 KB
/
页尾.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
<!-- ............自定义尾部代码开始............ -->
<div id="post-bottom-bar" class="post-bottom-bar" style="bottom: 0px;">
<div class="bottom-bar-inner">
<!-- 左边 -->
<div class="bottom-bar-items social-share" style="float: left;">
<span class="bottom-bar-item bottom-bar-facebook">
<a id="bottom-d" href="javascript:void(0)" target="_blank">好文要赞</a>
</span>
<span class="bottom-bar-item bottom-bar-twitter">
<a id="bottom-g" href="javascript:void(0)" target="_blank">关注我</a>
</span>
<span class="bottom-bar-item bottom-bar-qrcode">
<a id="bottom-s" href="javascript:void(0)" target="_blank">收藏该文</a>
</span>
</div>
<!-- 右边 -->
<div class="bottom-bar-items right" style="float: right;">
<span class="bottom-bar-item"><a id="mbottom-left" href="javascript:void(0);">←</a></span>
<span class="bottom-bar-item"><a id="mbottom-right" href="javascript:void(0);">→</a></span>
<span class="bottom-bar-item"><a href="#mfooter">↓</a></span>
<span class="bottom-bar-item"><a href="#mtop">↑</a></span>
</div>
</div>
</div>
<a name="mfooter"></a>
<!-- ............自定义尾部代码结束............ -->
<script type="text/javascript" src="https://blog-static.cnblogs.com/files/summertime-wu/nprogress.js"></script>
<script type="text/javascript">
//博主名称 可不改,默认取博客园提供的
var nickName = null;
//slogan
var slogan = '立德立言,无闻西东';
//icon
var icon = "https://ae01.alicdn.com/kf/H445e0280b88f4f34a848238a848a687fw.png";
//默认博客背景图片
var defaultPic="https://img2018.cnblogs.com/blog/1138447/201904/1138447-20190426121949417-1115592219.jpg";
//icon(浏览器标题栏上的)
var iconB="https://img2018.cnblogs.com/blog/1138447/201909/1138447-20190911161817172-1737762696.png";
//友情链接地址
var friendLink="https://www.cnblogs.com/summertime-wu/p/9350833.html";
//关于地址
var aboutMe="https://www.cnblogs.com/summertime-wu/p/9350808.html";
//Github地址,假如博客username与Github username相同,不用改。
//如 cnblogs.com/username github.com/username 这样就不用改
var myGayhubUrl = null;
</script>
<script type="text/javascript">
/**
用来设置初始时需要执行的js
*/
$(document).ready(function(){
//获取博主名字
if (nickName == null){
var footerOverTestArray = $($("#footer")[0].childNodes[2]).text().trim().split(" ");
nickName = footerOverTestArray[footerOverTestArray.length - 1];
}
//加载顶部进度条
NProgress.start();
NProgress.done();
$("#myProgressBar").hide();
//设置背景图片地址
if ($("#head_bg_img").val()!=null && $("#head_bg_img").val()!="") {
$("#myheader_bg").css("background-image","url("+$("#head_bg_img").val()+")");
}else{
$("#myheader_bg").css("background-image","url("+defaultPic+")");
}
//设置标题
if($("#cb_post_title_url").html()){
$("#mypost_title_h").html($("#cb_post_title_url").html());
}else{
$("#mypost_title_h").html(nickName);
}
//正文和标题淡入
$("#mainContent").css("opacity","1");
$("#mainContent").css("margin-top","0");
$("#mypost_title").css("opacity","1");
$("#mypost_title").css("top","75pt");
/* --根据个人配置修改页面 start-- */
//修改a链接
var ccList = $(".c-c");
for(var cc of ccList){
$(cc).attr("href", $(cc).attr("href").replace("summertime-wu",currentBlogApp));
}
//设置Github链接
if (myGayhubUrl != null ){$("#myGayhubUrl").attr("href",myGayhubUrl)}
//设置友链的链接
$("#friendLink").attr("href",friendLink);
//设置关于的链接
$("#aboutMe").attr("href",aboutMe);
//设置两个iocn图标
$("#nv-icon").attr("src",icon);
var linkObject = document.createElement("link");
linkObject.rel = "shortcut icon";
linkObject.href = iconB;
document.getElementsByTagName("head")[0].appendChild(linkObject);
//设置底部栏按钮
if (window.location.href == "https://www.cnblogs.com/"+currentBlogApp||
window.location.href == "https://www.cnblogs.com/"+currentBlogApp+"/"||
window.location.href == "http://www.cnblogs.com/"+currentBlogApp||
window.location.href == "http://www.cnblogs.com/"+currentBlogApp+"/") {
$("#bottom-d").html("友情链接");
$("#bottom-d").attr("href",friendLink);
}else{
var url = window.location.href;
var lastUrl = url.substring(url.lastIndexOf("/")+1);
var mpageId = lastUrl.substring(0,lastUrl.indexOf("."));
$("#bottom-d").click(function(){
DiggIt(mpageId,cb_blogId,1);
green_channel_success(this,'谢谢推荐!');
})
}
/* --根据个人配置修改页面 end-- */
})
/**
设置ajax请求加载完所有数据时执行的js
*/
setTimeout(afterAjax,1000);
function afterAjax(){
//假如是首页
if (window.location.href == "https://www.cnblogs.com/"+currentBlogApp||
window.location.href == "https://www.cnblogs.com/"+currentBlogApp+"/"||
window.location.href == "http://www.cnblogs.com/"+currentBlogApp||
window.location.href == "http://www.cnblogs.com/"+currentBlogApp+"/") {
$("#mypost_title_e").html('<a href="https://cnblogs.com/'+currentBlogApp+'">'+slogan+'</a>');
}else{
var classification = null;
if ($("#BlogPostCategory").html()!=null && $("#BlogPostCategory").html()!= "") {
classification = $("#BlogPostCategory").html();
classification = classification.substring(3,classification.length);
}else{
classification = '<a href="https://cnblogs.com/'+currentBlogApp+'">暂未分类</a>';
}
var ftitle = 'Published on '+ $("#post-date").html() + ' in ' + classification
+ ' with <a href="https://cnblogs.com/'+currentBlogApp+'">' + nickName + '</a>';
//设置副标题标题
$("#mypost_title_f").html(ftitle);
//设置标题分类按钮
$("#mypost_title_e").html(classification);
//设置底部导航条上一篇下一篇文章
var pnp = $("#post_next_prev a");
$("#mbottom-left").attr("href",pnp[1].href);
if (pnp.length>2) {
$("#mbottom-right").attr("href",pnp[3].href);
}
}
$("#myheader_bg").css("filter","blur(0px)");
//优化评论区样式
$("#comment_form_container p:last").hide();
$("#commentbox_opt a:last").hide();
$("#tbCommentBody").attr('placeholder','Your comment here. Be cool. ');
}
/**
自定义的js方法
*/
//设置底部导航条点击关注按钮事件
$("#bottom-g").click(function(){
$('#green_channel_follow').click()
return false
})
$("#bottom-s").click(function(){
AddToWz(cb_entryId);
return false;
})
//通过滚动条控制导航条的展现隐藏
var oldScrollNum = 0;
window.onscroll = function(){
var t = document.documentElement.scrollTop || document.body.scrollTop;
//下滑
if (t>oldScrollNum) {
if (t>120) {
$("#mynavbar").css("margin-top","-70px");//顶部导航
$("#post-bottom-bar").css("bottom","-3pc");//底部导航
}
if (t>300) {
$("#right_meun").css("display","inline-block");//右侧导航
}
//上拉
}else{
//防止用a链接跳转也触发效果
if (oldScrollNum-t<20) {
$("#mynavbar").css("margin-top","0px");//顶部导航
$("#post-bottom-bar").css("bottom","0");//底部导航
}
if (t<=300) {
$("#right_meun").css("display","none");//右侧导航
}
}
oldScrollNum = t;
}
//背景大图点击模糊||清晰
$("#myheader_cover").click(function(){
if ($("#myheader_bg").css("filter") == "blur(3px)") {
$("#myheader_bg").css("filter","blur(0px)");
}else{
$("#myheader_bg").css("filter","blur(3px)");
}
})
</script>
<script type="text/javascript">
var setMyBlog = {
setCopyright: function() {
//设置版权信息,转载出处自动根据页面url生成
var info_str = '<p>作者:<a target="_blank">@gzdaijie</a><br>'+
'本文为作者原创,转载请注明出处:<a class="uri"></a></p><hr></hr>',
info = $(info_str),
info_a = info.find("a"),
url = window.location.href;
$(info_a[0]).attr("href","https://github.com/gzdaijie");
$(info_a[1]).attr("href",url).text(url);
$("#cnblogs_post_body").prepend(info);
},
setCodeRow: function(){
// 代码行号显示
var pre = $("pre.sourceCode"); //选中需要更改的部分
if(pre && pre.length){
pre.each(function() {
var item = $(this);
var lang = item.attr("class").split(" ")[1]; //判断高亮的语言
item.html(item.html().replace(/<[^>]+>/g,"")); //将<pre>标签中的html标签去掉
item.removeClass().addClass("brush: " + lang +";"); //根据语言添加笔刷
SyntaxHighlighter.all();
})
}
},
setAtarget: function() {
// 博客内的链接在新窗口打开
$("#cnblogs_post_body a").each(function(){
if (this.href.indexOf(window.location.href === 0)) {
// 如果 url 指向当前博客
// 不要在新窗口打开
} else {
this.target = "_blank";
}
})
},
setContent: function() {
// 根据h2、h3标签自动生成目录
var captions_ori = $("#cnblogs_post_body h2"),
captions_ori2 = $("#cnblogs_post_body h3"),
captions = $("#cnblogs_post_body h2,#cnblogs_post_body h3").clone(),
content = $("<ul id='right_meun'></ul>");
$("#cnblogs_post_body").prepend(content.append(captions));
var index = -1,index2 = -1;
captions.replaceWith(function(){
var self = this;
if(self.tagName == "H2" || self.tagName == "h2"){
// 设置点击目录跳转
index += 1;
$('<a name="' + '_caption_' + index + '"></a>').insertBefore(captions_ori[index]);
return '<li id="'+index+'li"><a href="#_caption_' + index + '">' + self.innerHTML + '</a><ul></ul></li>';
} else {
// add by summertime-wu 增加h3链接跳转
index2 += 1;
$('<a name="' + '_caption' + index2 + '"></a>').insertBefore(captions_ori2[index2]);
$("#"+index+"li ul").append('<li><a href="#_caption' + index2 + '" style="color:#5f5f5f;">' +self.innerHTML+"</a></li>");
return ;
}
});
},
runAll: function() {
/* 运行所有方法
* setAtarget() 博客园内标签新窗口打开
* setContent() 设置目录
* setCopyright() 设置版权信息
* setCodeRow() 代码行号显示
*/
this.setAtarget();
//假如为手机端不显示目录
if(document.body.clientWidth>=1000){
this.setContent();
}
// this.setCopyright();
this.setCodeRow();
}
}
setMyBlog.runAll();
</script>
<!-- 代码行号 -->
<script src="//cdn.bootcss.com/highlightjs-line-numbers.js/1.1.0/highlightjs-line-numbers.min.js"></script>
<script>hljs.initLineNumbersOnLoad();</script>