-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleMemory.js
More file actions
486 lines (451 loc) · 18.3 KB
/
simpleMemory.js
File metadata and controls
486 lines (451 loc) · 18.3 KB
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
/*!
* UPDATES AND DOCS AT: https://github.com/BNDong
* https://www.cnblogs.com/bndong/
* @author: BNDong, dbnuo@foxmail.com
**/
if (initCheck()) {
var sidebarHtml =
'<div class="container">' +
' <div class="menu-wrap optiscroll" id="menuWrap" style="display:none">' +
' <nav class="menu">' +
' <!-- 个人简介 -->' +
' <div class="introduce-box">' +
' <div class="introduce-head">' +
' <div class="introduce-via" id="menuBlogAvatar"></div>' +
' </div>' +
' <div id="introduce"></div>' +
' </div>' +
' <!-- 导航 -->' +
' <div class="nav-title"></div>' +
' <div class="icon-list">' +
' <ul id="m-nav-list">' +
' </ul>' +
' </div>' +
' <!-- 日历 -->' +
' <span id="calendar-box"></span>' +
' <!-- 找找看 -->' +
' <div class="m-list-title"><span>找找看</span></div>' +
' <div class="m-icon-list" id="sb-sidebarSearchBox"></div>' +
' <!-- 积分与排名 -->' +
' <div class="m-list-title"><span>积分排名<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-sidebarScorerank"></div>' +
' <!-- 最新随笔 -->' +
' <div class="m-list-title"><span>最新随笔<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-sidebarRecentposts"></div>' +
' <!-- 我的标签 -->' +
' <div class="m-list-title"><span>我的标签<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-toptags"></div>' +
' <!-- 随笔分类 -->' +
' <div class="m-list-title"><span>随笔分类<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-classify"></div>' +
' <!-- 文章分类 -->' +
' <div class="m-list-title"><span>文章分类<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-ArticleCategory"></div>' +
' <!-- 阅读排行 -->' +
' <div class="m-list-title"><span>阅读排行<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-topview"></div>' +
' <!-- 推荐排行 -->' +
' <div class="m-list-title"><span>推荐排行<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-topDiggPosts"></div>' +
' <!-- 最新评论 -->' +
' <div class="m-list-title"><span>最新评论<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-recentComments"></div>' +
' <!-- 文章档案 -->' +
' <div class="m-list-title"><span>文章档案<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-articlearchive"></div>' +
' <!-- 随笔档案 -->' +
' <div class="m-list-title"><span>随笔档案<span class="iconfont icon-sorting m-list-title-sorting"></span></span></div>' +
' <div class="m-icon-list" id="sb-record"></div>' +
' <!-- 自定义列表 -->' +
' <span id="menuCustomList"></span>' +
' </nav>' +
' <button class="close-button" id="close-button">Close Menu</button>' +
' <div class="morph-shape" id="morph-shape" data-morph-open="M-7.312,0H15c0,0,66,113.339,66,399.5C81,664.006,15,800,15,800H-7.312V0z;M-7.312,0H100c0,0,0,113.839,0,400c0,264.506,0,400,0,400H-7.312V0z">' +
' <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 100 800" preserveAspectRatio="none">' +
' <path d="M-7.312,0H0c0,0,0,113.839,0,400c0,264.506,0,400,0,400h-7.312V0z"/>' +
' </svg>' +
' </div>' +
' </div>' +
' <button class="menu-button" id="open-button">MENU</button>' +
' <div class="content-wrap" id="content-wrap"></div><!-- /content-wrap -->' +
'</div>' +
'<div class="main-header">' +
' <div class="main-header-background"></div>' +
' <canvas id="notHomeTopCanvas"></canvas>' +
' <div class="vertical">' +
' <div class="main-header-content inner">' +
' <h1 class="page-title" id="homeTopTitle"></h1>' +
' <h2 class="page-description" id="hitokoto"></h2>' +
' <h3 class="page-author" id="hitokotoAuthor"></h3>' +
' <h1 class="sb-title" id="sbTitle"></h1>' +
' <p class="article-info" id="articleInfo"></p>' +
' </div>' +
' </div>' +
' <a class="scroll-down" href="javascript:void(0);" data-offset="-45">' +
' <span class="hidden">Scroll Down</span>' +
' <i class="scroll-down-icon iconfont icon-arrow-down-bold"></i>' +
' </a>' +
'</div>' +
'<div id="loading"></div>' +
'<div id="bottomProgressBar"></div>' +
'<div id="rightMenu"></div>';
window.cnblogsConfigDefault = {
GhUserName: 'Ercilan',
GhRepositories: 'Cnblogs-Theme-SimpleMemory',
GhVersions: 'dev',
CnVersions: "",
blogUser: "二次蓝",
blogAvatar: "https://pic.cnblogs.com/avatar/2224860/20201204114200.png",
blogStartDate: "2020-11-24",
menuCustomList: { // 左侧下面导航
"书签组": { // 标题
"data": [ // 列表数据 ['列表', '链接']
['我的博客1', 'https://www.cnblogs.com/ercilan/'],
['我的博客2', 'https://www.cnblogs.com/ercilan/'],
],
"icon": "icon-qianbi-fill" // 配置图标,参考文档:定制化/字体图标库
}
},
menuNavList: [ // 左侧导航
['GitHub', 'https://github.com/Ercilan/', 'icon-github'],
],
menuUserInfoBgImg: 'https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/me_left_top_3.webp', // 280 * 225
webpageTitleOnblur: '(o゚v゚)ノ Hi 快看这个神奇的标签',
webpageTitleOnblurTimeOut: 500,
webpageTitleFocus: "(*´∇`*) 欢迎回来!",
webpageTitleFocusTimeOut: 1000,
webpageIcon: "https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/favicon.ico",
fontIconExtend: "//at.alicdn.com/t/font_2234916_c9szdhlnbid.css", // 品牌字体图标
progressBar: {
id: 'top-progress-bar',
color: '#77b6ff',
height: '4px',
duration: 0.2
},
loading: {
rebound: {
tension: 50,
friction: 8
},
spinner: {
id: 'spinner',
radius: 80,
sides: 4,
depth: 3,
colors: {
background: '#f0f0f0',
stroke: '#272633',
base: null,
child: '#4195EC'
},
alwaysForward: true, // When false the spring will reverse normally.
restAt: 0.5, // A number from 0.1 to 0.9 || null for full rotation
renderBase: false // Optionally render basePolygon
}
},
homeTopAnimationRendered: true,
homeTopAnimation: {
radius: 15,
density: 0.2,
color: 'rgba(255,255,255, .2)',
clearOffset: 0.3
},
essayTopAnimationRendered: true,
essayTopAnimation: {
triW: 14,
triH: 20,
neighbours: ["side", "top", "bottom"],
speedTrailAppear: .1,
speedTrailDisappear: .1,
speedTriOpen: 1,
trailMaxLength: 30,
trailIntervalCreation: 100,
delayBeforeDisappear: 2,
colorsRandom: false,
colors: [
'#96EDA6', '#5BC6A9',
'#38668C', '#374D84',
'#BED5CB', '#62ADC6',
'#8EE5DE', '#304E7B'
]
},
bgAnimationRendered: true,
backgroundAnimation: {
colorSaturation: "60%",
colorBrightness: "50%",
colorAlpha: 0.5,
colorCycleSpeed: 5,
verticalPosition: "random",
horizontalSpeed: 200,
ribbonCount: 3,
strokeSize: 0,
parallaxAmount: -0.2,
animateSections: true
},
homeTopImg: [ // 首页顶部
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_1.webp",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_2.webp",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_3.jpg",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_4.webp",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_5.webp",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_6.jpg",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_7.jpg",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_8.jpg",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/home_top_bg_9.jpg",
],
homeBannerText: "",
homeBannerTextType: "jinrishici",
essayTopImg: [ // 文章顶部图片,推荐尺寸>= 1920*600
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/article_top_bg_1.webp",
"https://cdn.jsdelivr.net/gh/Ercilan/MyBlog@master/img/article_top_bg_2.webp",
],
essayCodeHighlightingType: 'cnblogs',
essayCodeHighlighting: '',
essayCodeLanguages: [],
essayCode: {
fontFamily: "'Ubuntu Mono',monospace",
fontSize: "14px",
},
codeMaxHeight: false,
codeLineNumber: false, // 渲染行号
essayTitleStyle: false,
essaySuffix: {
codeImgUrl: '',
copyrightHtml: '',
aboutHtml: "我是二次蓝,我是一个正在学习中的好孩子",
supportHtml: ''
},
bottomBlogroll: [],
bottomText: {
iconFont: {
icon: "icon-xl", // iconfont 图标名称
color: "red", // 图标颜色
fontSize: "16px" // 图标大小
},
left: "",
right: ""
},
footerStyle: 2,
consoleList: [
['欢迎来到我的博客~~', 'https://www.cnblogs.com/ercilan'],
['二次蓝 GitHub', 'https://github.com/Ercilan/'],
['二次蓝 Email', 'ercilan@163.com'],
],
bookList: [],
themeAuthor: false,
isVersionMapping: false,
switchDayNight: {
enable: true,
auto: {
enable: true,
dayHour: 5,
nightHour: 23
}
},
reward: {
enable: false,
wechatpay: '',
alipay: ''
},
weChatOfficialAccounts: '',
advertising: false, // 是否显示博客园广告
};
window.cnblogsConfigDefault.hook = {
// loading 开始前
beforeLoading: function (loading) {
// console.log('beforeLoading');
},
// loading 结束后
afterLoading: function (e, loading) {
// console.log('afterLoading');
},
// 页面标签变化
pageLabelChanges: function (e, text) {
// console.log('pageLabelChanges');
},
// 渲染代码开始前
beforeCodeHighlighting: function (e) {
// console.log('beforeCodeHighlighting');
},
// 渲染代码结束后
afterCodeHighlighting: function (e) {
// console.log('afterCodeHighlighting');
},
// 日夜间模式设置
dayNightControl: function (e, type) {
// console.log('dayNightControl');
},
// 页面初始化结束
pageInitEnd: function (e) {
// console.log('pageInitEnd');
},
};
window.cnblogsConfig = $.extend(true, window.cnblogsConfigDefault, window.cnblogsConfig);
getVersionConfig();
} else {
$('a[name="top"]').text("SimpleMemory:基础配置有误,请阅读文档,检查配置!").css({
'display': 'block', 'text-align': 'center', 'padding-top': '45vh', 'font-size': '20px', 'color': '#333'
});
}
// init check
function initCheck() {
// check base theme
var baseStyle = $('#mobile-style').attr('href');
if (typeof baseStyle != 'undefined') {
var bt = baseStyle.split('/');
if($.inArray('SimpleMemory', bt) !== -1) {
return true;
}
}
return false;
}
// get version config
function getVersionConfig() {
window.cnblogsConfig.CnVersions = window.cnblogsConfig.GhVersions;
if (window.cnblogsConfig.isVersionMapping) {
var url = 'https://raw.githubusercontent.com/' + window.cnblogsConfig.GhUserName + '/' + window.cnblogsConfig.GhRepositories + '/master/version.conf';
$.ajax({
type: "get",
url: url,
dataType: "text",
async: false,
success: function (conf) {
window.themeVersion = conf ? JSON.parse(conf) : false;
window.themeVersion && setConfVersion();
}
});
} else if (window.cnblogsConfig.GhUserName === 'BNDong') {
window.themeVersion = [
[
"v1.1.6",
"d8adfb50252062f658350bda29d7145f5eff0b80"
]
,
[
"v1.1.8",
"461aab69de17a84f0af9ff0c326bfcb94438b06c"
]
,
[
"v1.2.2",
"08eab99303d7c463a495adabd8feccc784a8507d"
]
,
[
"v1.2.3",
"36901bf16e2aa3656d4e6f78d44486273b0b8972"
]
,
[
"v1.2.4",
"9354db2147c11fc56cfe02a502f1f8229332fc2f"
]
,
[
"v1.2.5",
"4d744f980758500078df349520472e3b360fb841"
]
];
setConfVersion();
} else {
init();
}
function setConfVersion() {
var confVersion = getEndConfVal(window.cnblogsConfig.GhVersions);
if (confVersion) {
window.cnblogsConfig.GhVersions = confVersion;
}
init();
}
function getEndConfVal(thisGhVersion) {
var endVal = '';
window.themeVersion && $.each(window.themeVersion, function (i) {
if (window.themeVersion[i][0] === thisGhVersion) {
endVal = window.themeVersion[i][1]; return false;
}
});
if (endVal === '') {
return thisGhVersion;
} else {
return getEndConfVal(endVal);
}
}
}
// init
function init() {
// set sidebar html
var url = window.location.href, tmp = [];
tmp = url.split("/");
var user = tmp[3];
var navListHtml = '<li><a href="https://www.cnblogs.com/' + user + '/" target="_self"><i class="iconfont icon-home"></i>首页</a></li>' +
'<li><a href="https://msg.cnblogs.com/send/' + user + '" target="_blank"><i class="iconfont icon-contact"></i>联系</a></li>' +
'<li><a href="javascript:void(0)" onclick="$(\'#blog_nav_rss\').trigger(\'click\');" data-rss="https://www.cnblogs.com/' + user + '/rss/"><i class="iconfont icon-subscribe"></i>订阅</a></li>' +
'<li><a href="https://i.cnblogs.com/" target="_blank"><i class="iconfont icon-admin"></i>管理</a></li>';
var menuNavList = window.cnblogsConfig.menuNavList;
if (menuNavList.length > 0) {
$.each(menuNavList, function (i) {
let iconClass = menuNavList[i].length > 2 ? menuNavList[i][2] : "icon-quill";
navListHtml += '<li><a href="' + (menuNavList[i][1]) + '" target="_blank"><i class="iconfont ' + iconClass + '"></i>' + (menuNavList[i][0]) + '</a></li>';
});
}
$('#blog-news').prepend(sidebarHtml);
$('#m-nav-list').append(navListHtml);
// set userName
if (window.cnblogsConfig.blogUser === "") window.cnblogsConfig.blogUser = user;
// start cache
$.ajaxSetup({ cache: true });
// load loadingJs
$.getScript(getJsDelivrUrl('loading.js'), function () {
// Loading start
window.cnblogsConfig.hook.beforeLoading(pageLoading);
pageLoading.initRebound();
pageLoading.initSpinner();
pageLoading.spinner.init(pageLoading.spring, true);
$.getScript(getJsDelivrUrl('lib/jquery.mCustomScrollbar.min.js'), function () {
$.getScript(getJsDelivrUrl('lib/require.min.js'), function () {
$.getScript(getJsDelivrUrl('config.js'), function () {
var staticResource = [
// 'optiscroll', 'ToProgress', 'rotate',
'optiscroll_ToProgress_rotate',
'snapSvg', 'classie', 'main4', 'tools'];
require(staticResource, function () {
require(['base'], function () {
(new Base).init();
});
});
});
});
});
});
}
// get file url
function getJsDelivrUrl(file, directory) {
file = setFileNameMin(file, directory);
//console.log(file, directory);
// switch(file){
// case 'src/script/lib/require.min.js':
// return "http://js.ercilan.cn/require.min.js";
// }
return 'https://cdn.jsdelivr.net/gh/' + (window.cnblogsConfig.GhUserName) + '/' + (window.cnblogsConfig.GhRepositories) + '@' + (window.cnblogsConfig.GhVersions) + '/' + (file ? file : '');
}
// optimization file name
function setFileNameMin(file, directory) {
if (typeof file == 'undefined') return '';
var suffix = null, fileArr = file.split('.');
if (fileArr.length > 0 && $.inArray(fileArr[(fileArr.length - 1)], ['js', 'css']) !== -1) {
suffix = fileArr.pop();
switch (suffix) {
case 'js': directory = 'script'; break;
case 'css': directory = 'style'; break;
}
} else {
if (typeof directory == 'undefined') return '';
switch (directory) {
case 'js': directory = 'script'; break;
case 'css': directory = 'style'; break;
}
}
file.search('.min') === -1 && fileArr.push('min');
suffix != null && fileArr.push(suffix);
return (typeof directory !== 'undefined' ? ('src/' + directory + '/' + fileArr.join('.')) : (fileArr.join('.')));
}