cansin-blogdata 3.0.6 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/encryption.js DELETED
@@ -1,162 +0,0 @@
1
- var _type = document.querySelector(".encryption .select-item.type"),
2
- _code = document.querySelector(".encryption .select-item.code"),
3
- _case = document.querySelector(".encryption .select-item.case"),
4
- _mode = document.querySelector(".encryption .select-item.mode"),
5
- _pad = document.querySelector(".encryption .select-item.pad"),
6
- _key = document.querySelector(".encryption .select-item.key"),
7
- _iv = document.querySelector(".encryption .select-item.iv"),
8
- textIn = document.querySelector('.encryption .inner'),
9
- textOut = document.querySelector('.encryption .outer');
10
- textOut.addEventListener("input", ()=>{
11
- if (textOut.value == '') {
12
- textOut.disabled = true;
13
- textOut.classList.add('lock');
14
- } else {
15
- textOut.disabled = false;
16
- textOut.classList.remove('lock');
17
- }
18
- })
19
- _type.addEventListener('change', ()=>{
20
- if (_type.value == 'AESEncode') {
21
- _case.classList.contains('hide') ? null : _case.classList.add('hide'); // 隐藏 大小写
22
- _code.classList.contains('hide') ? _code.classList.remove('hide') : null; // 显示
23
- _mode.classList.contains('hide') ? _mode.classList.remove('hide') : null;
24
- _pad.classList.contains('hide') ? _pad.classList.remove('hide') : null;
25
- _key.classList.contains('hide') ? _key.classList.remove('hide') : null;
26
- _iv.classList.contains('hide') ? _iv.classList.remove('hide') : null;
27
- } else if (_type.value == 'AESDecode') {
28
- _code.classList.contains('hide') ? null : _code.classList.add('hide'); // 隐藏 编码、大小写
29
- _case.classList.contains('hide') ? null : _case.classList.add('hide');
30
- _mode.classList.contains('hide') ? _mode.classList.remove('hide') : null; // 显示
31
- _pad.classList.contains('hide') ? _pad.classList.remove('hide') : null;
32
- _key.classList.contains('hide') ? _key.classList.remove('hide') : null;
33
- _iv.classList.contains('hide') ? _iv.classList.remove('hide') : null;
34
- } else {
35
- _code.classList.contains('hide') ? _code.classList.remove('hide') : null; // 显示
36
- _case.classList.contains('hide') ? _case.classList.remove('hide') : null;
37
- _mode.classList.contains('hide') ? null : _mode.classList.add('hide'); // 隐藏
38
- _pad.classList.contains('hide') ? null : _pad.classList.add('hide');
39
- _key.classList.contains('hide') ? null : _key.classList.add('hide');
40
- _iv.classList.contains('hide') ? null : _iv.classList.add('hide');
41
- }
42
- })
43
- _mode.addEventListener('change', ()=>{
44
- if (_mode.value != 'ECB') {
45
- if (_iv.classList.contains('lock')) {
46
- _iv.classList.remove('lock');
47
- _iv.disabled = false;
48
- };
49
- } else {
50
- if (!_iv.classList.contains('lock')) {
51
- _iv.classList.add('lock');
52
- _iv.disabled = true;
53
- };
54
- }
55
- })
56
-
57
- function copyTranscode() {
58
- textOut.select();
59
- document.execCommand('copy');
60
- }
61
-
62
- function clearTranscode() {
63
- document.querySelector('.encryption .inner').value = '';
64
- textOut.value = '';
65
- textOut.disabled = true;
66
- textOut.classList.add('lock');
67
- }
68
-
69
- function transcode() {
70
- var a = '',
71
- b = '',
72
- __mode = '',
73
- __pad = '',
74
- __text = '',
75
- __key = CryptoJS.enc.Utf8.parse(_key.value),
76
- __iv = CryptoJS.enc.Utf8.parse(_iv.value);
77
- switch (_mode.value) {
78
- case "CBC": __mode = CryptoJS.mode.CBC; break;
79
- case "CFB": __mode = CryptoJS.mode.CFB; break;
80
- case "CTR": __mode = CryptoJS.mode.CTR; break;
81
- case "OFB": __mode = CryptoJS.mode.OFB; break;
82
- case "ECB": __mode = CryptoJS.mode.ECB; break;
83
- default: __mode = CryptoJS.mode.CBC;
84
- }
85
- switch (_pad.value) {
86
- case "Pkcs7": __pad = CryptoJS.pad.Pkcs7; break;
87
- case "Iso97971": __pad = CryptoJS.pad.Iso97971; break;
88
- case "Iso10126": __pad = CryptoJS.pad.Iso10126; break;
89
- case "AnsiX923": __pad = CryptoJS.pad.AnsiX923; break;
90
- case "ZeroPadding": __pad = CryptoJS.pad.ZeroPadding; break;
91
- case "NoPadding": __pad = CryptoJS.pad.NoPadding; break;
92
- default: __pad = CryptoJS.pad.Pkcs7;
93
- }
94
- switch (_type.value) {
95
- case "MD5":
96
- a = CryptoJS.MD5(textIn.value);
97
- b = _code.value == 'Hex' ? a.toString() : CryptoJS.enc.Base64.stringify(a);
98
- textOut.value = _case.value == 'Lower' ? b : b.toUpperCase();
99
- break;
100
- case "SHA1":
101
- a = CryptoJS.SHA1(textIn.value);
102
- b = _code.value == 'Hex' ? a.toString() : CryptoJS.enc.Base64.stringify(a);
103
- textOut.value = _case.value == 'Lower' ? b : b.toUpperCase();
104
- break;
105
- case "SHA3":
106
- a = CryptoJS.SHA3(textIn.value);
107
- b = _code.value == 'Hex' ? a.toString() : CryptoJS.enc.Base64.stringify(a);
108
- textOut.value = _case.value == 'Lower' ? b : b.toUpperCase();
109
- break;
110
- case "SHA224":
111
- a = CryptoJS.SHA224(textIn.value);
112
- b = _code.value == 'Hex' ? a.toString() : CryptoJS.enc.Base64.stringify(a);
113
- textOut.value = _case.value == 'Lower' ? b : b.toUpperCase();
114
- break;
115
- case "SHA256":
116
- a = CryptoJS.SHA256(textIn.value);
117
- b = _code.value == 'Hex' ? a.toString() : CryptoJS.enc.Base64.stringify(a);
118
- textOut.value = _case.value == 'Lower' ? b : b.toUpperCase();
119
- break;
120
- case "SHA384":
121
- a = CryptoJS.SHA384(textIn.value);
122
- b = _code.value == 'Hex' ? a.toString() : CryptoJS.enc.Base64.stringify(a);
123
- textOut.value = _case.value == 'Lower' ? b : b.toUpperCase();
124
- break;
125
- case "SHA512":
126
- a = CryptoJS.SHA512(textIn.value);
127
- b = _code.value == 'Hex' ? a.toString() : CryptoJS.enc.Base64.stringify(a);
128
- textOut.value = _case.value == 'Lower' ? b : b.toUpperCase();
129
- break;
130
- case "RIPEMD160":
131
- a = CryptoJS.RIPEMD160(textIn.value);
132
- b = _code.value == 'Hex' ? a.toString() : CryptoJS.enc.Base64.stringify(a);
133
- textOut.value = _case.value == 'Lower' ? b : b.toUpperCase();
134
- break;
135
- case "AESEncode":
136
- __text = CryptoJS.enc.Utf8.parse(textIn.value);
137
- a = CryptoJS.AES.encrypt(__text, __key, { iv: __iv, mode: __mode, padding: __pad });
138
- b = _code.value == 'Hex' ? CryptoJS.enc.Hex.stringify(a.ciphertext) : a.toString();
139
- textOut.value = b;
140
- break;
141
- case "AESDecode":
142
- var base64Regex = /^[A-Za-z0-9+/]*={1,2}$/,
143
- hexRegex = /^(?:[0-9a-fA-F]{4})*$/;
144
- if (base64Regex.test(textIn.value)) {
145
- console.log('base64');
146
- __text = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Base64.parse(textIn.value));
147
- textOut.value = CryptoJS.AES.decrypt(__text, __key, { iv: __iv, mode: __mode, padding: __pad }).toString(CryptoJS.enc.Utf8);
148
- break;
149
- } else if (hexRegex.test(textIn.value)) {
150
- console.log('hex');
151
- __text = CryptoJS.enc.Hex.parse(textIn.value);
152
- textOut.value = CryptoJS.AES.decrypt({ ciphertext: __text }, __key, { iv: __iv, mode: __mode, padding: __pad }).toString(CryptoJS.enc.Utf8);
153
- break;
154
- } else {
155
- console.log('数据错误');
156
- alert('数据错误');break;
157
- }
158
- default: ;
159
- }
160
- textOut.disabled = false;
161
- textOut.classList.remove('lock');
162
- }
package/js/fcircle.js DELETED
@@ -1,393 +0,0 @@
1
- /*
2
- Last Modified time : 20220326 15:38 by https://immmmm.com
3
- 已适配 FriendCircle 公共库和主库
4
- */
5
-
6
- //默认数据
7
- var fdata = {
8
- jsonurl: '',
9
- apiurl: '',
10
- apipublieurl: 'https://fcircle-pub.rct.cool/', //默认公共库
11
- initnumber: 24, //首次加载文章数
12
- stepnumber: 12, //更多加载文章数
13
- article_sort: 'created', //文章排序 updated or created
14
- error_img: 'https://blog-hexo-img.oss-cn-shanghai.aliyuncs.com/error-img.webp'
15
- }
16
- //可通过 var fdataUser 替换默认值
17
- if (typeof (fdataUser) !== "undefined") {
18
- for (var key in fdataUser) {
19
- if (fdataUser[key]) {
20
- fdata[key] = fdataUser[key];
21
- }
22
- }
23
- }
24
- var article_num = '', sortNow = '', UrlNow = '', friends_num = ''
25
- var container = document.getElementById('cf-container') || document.getElementById('fcircleContainer');
26
- // 获取本地 排序值、加载apiUrl,实现记忆效果
27
- var localSortNow = localStorage.getItem("sortNow")
28
- var localUrlNow = localStorage.getItem("urlNow")
29
- if (localSortNow && localUrlNow) {
30
- sortNow = localSortNow
31
- UrlNow = localUrlNow
32
- } else {
33
- sortNow = fdata.article_sort
34
- if (fdata.jsonurl) {
35
- UrlNow = fdata.apipublieurl + 'postjson?jsonlink=' + fdata.jsonurl + "&"
36
- } else if (fdata.apiurl) {
37
- UrlNow = fdata.apiurl + 'all?'
38
- } else {
39
- UrlNow = fdata.apipublieurl + 'all?'
40
- }
41
- console.log("当前模式:" + UrlNow)
42
- localStorage.setItem("urlNow", UrlNow)
43
- localStorage.setItem("sortNow", sortNow)
44
- }
45
- // 打印基本信息
46
- function loadStatistical(sdata) {
47
- article_num = sdata.article_num
48
- friends_num = sdata.friends_num
49
- var messageBoard = `
50
- <div id="cf-state" class="cf-new-add">
51
- <div class="cf-state-data">
52
- <div class="cf-data-friends" onclick="openToShow()">
53
- <span class="cf-label">订阅</span>
54
- <span class="cf-message">${sdata.friends_num}</span>
55
- </div>
56
- <div class="cf-data-active" onclick="changeEgg()">
57
- <span class="cf-label">活跃</span>
58
- <span class="cf-message">${sdata.active_num}</span>
59
- </div>
60
- <div class="cf-data-article" onclick="clearLocal()">
61
- <span class="cf-label">日志</span>
62
- <span class="cf-message">${sdata.article_num}</span>
63
- </div>
64
- </div>
65
- <div id="cf-change">
66
- <span id="cf-change-created" data-sort="created" onclick="changeSort(event)" class="${sortNow == 'created' ? 'cf-change-now' : ''}">Created</span> | <span id="cf-change-updated" data-sort="updated" onclick="changeSort(event)" class="${sortNow == 'updated' ? 'cf-change-now' : ''}" >Updated</span>
67
- </div>
68
- </div>
69
- `;
70
- var loadMoreBtn = `
71
- <div id="cf-more" class="cf-new-add" onclick="loadNextArticle()"><i class="fas fa-angle-double-down"></i></div>
72
- <div id="cf-footer" class="cf-new-add">
73
- <span id="cf-version-up" onclick="checkVersion()"></span>
74
- <span class="cf-data-lastupdated">更新于:${sdata.last_updated_time}</span>
75
- Powered by <a target="_blank" href="https://github.com/Rock-Candy-Tea/hexo-circle-of-friends" target="_blank">FriendCircle</a>
76
- <br>
77
- Designed by <a target="_blank" href="https://immmmm.com" target="_blank">林木木</a>
78
- <br>
79
- Adapted by <a target="_blank" href="https://gavin-chen.top" target="_blank">南方嘉木</a>
80
- </div>
81
- <div id="cf-overlay" class="cf-new-add" onclick="closeShow()"></div>
82
- <div id="cf-overshow" class="cf-new-add"></div>
83
- `;
84
- if (container) {
85
- container.insertAdjacentHTML('beforebegin', messageBoard);
86
- container.insertAdjacentHTML('afterend', loadMoreBtn);
87
- }
88
- }
89
- // 打印文章内容 cf-article <span class="cf-article-floor">${item.floor}</span>
90
- function loadArticleItem(datalist, start, end) {
91
- var articleItem = '';
92
- var articleNum = article_num;
93
- var endFor = end
94
- if (end > articleNum) { endFor = articleNum }
95
- if (start < articleNum) {
96
- for (var i = start; i < endFor; i++) {
97
- var item = datalist[i];
98
- var id = "cf-" + CryptoJS.MD5(item.link).toString();
99
- articleItem += `
100
- <div class="cf-article ${id}">
101
- <a class="cf-article-title" href="${item.link}" target="_blank" rel="noopener nofollow" data-title="${item.title}">${item.title}</a>
102
- <a class="cf-star" onclick="switchSecretInput(event)"><i class="fa-regular fa-star"></i></a>
103
- <div class="cf-article-avatar no-lightbox flink-item-icon">
104
- <img class="cf-img-avatar avatar" src="${item.avatar}" alt="avatar" onerror="this.src='${fdata.error_img}'; this.onerror = null;">
105
- <a onclick="openMeShow(event)" data-link="${item.link}" class="" target="_blank" rel="noopener nofollow" href="javascript:;"><span class="cf-article-author">${item.author}</span></a>
106
- </div>
107
- <span class="cf-article-time">
108
- <span class="cf-time-created" style="${sortNow == 'created' ? '' : 'display:none'}">${item.created}</span>
109
- <span class="cf-time-updated" style="${sortNow == 'updated' ? '' : 'display:none'}">${item.updated}</span>
110
- </span>
111
- </div>
112
- `;
113
- }
114
- container.insertAdjacentHTML('beforeend', articleItem);
115
- if (savedArticlesIndex != null) {checkStared(savedArticlesIndex);}
116
- // 预载下一页文章
117
- fetchNextArticle()
118
- } else {
119
- // 文章加载到底
120
- document.getElementById('cf-more').outerHTML = `<div id="cf-more" class="cf-new-add" onclick="loadNoArticle()"><small>一切皆有尽头!</small></div>`
121
- }
122
- }
123
- // 打印个人卡片 cf-overshow
124
- function loadFcircleShow(userinfo, articledata) {
125
- var showHtml = `
126
- <div class="cf-overshow">
127
- <div class="cf-overshow-head">
128
- <img class="cf-img-avatar avatar" src="${userinfo.avatar}" alt="avatar" onerror="this.src='${fdata.error_img}'; this.onerror = null;">
129
- <a class="" target="_blank" rel="noopener nofollow" href="${userinfo.link}">${userinfo.name}</a>
130
- </div>
131
- <div class="cf-overshow-content">
132
- `
133
- for (var i = 0; i < userinfo.article_num; i++) {
134
- var item = articledata[i];
135
- showHtml += `
136
- <p><a class="cf-article-title" href="${item.link}" target="_blank" rel="noopener nofollow" data-title="${item.title}">${item.title}</a><span>${item.created}</span></p>
137
- `
138
- }
139
- showHtml += '</div></div>'
140
- document.getElementById('cf-overshow').insertAdjacentHTML('beforeend', showHtml);
141
- document.getElementById('cf-overshow').className = 'cf-show-now';
142
- }
143
-
144
- // 预载下一页文章,存为本地数据 nextArticle
145
- function fetchNextArticle() {
146
- var start = document.querySelectorAll('#cf-container .cf-article').length
147
- var end = start + fdata.stepnumber
148
- var articleNum = article_num;
149
- if (end > articleNum) {
150
- end = articleNum
151
- }
152
- if (start < articleNum) {
153
- UrlNow = localStorage.getItem("urlNow")
154
- var fetchUrl = UrlNow + "rule=" + sortNow + "&start=" + start + "&end=" + end
155
- //console.log(fetchUrl)
156
- fetch(fetchUrl)
157
- .then(res => res.json())
158
- .then(json => {
159
- var nextArticle = eval(json.article_data);
160
- console.log("已预载" + "?rule=" + sortNow + "&start=" + start + "&end=" + end)
161
- localStorage.setItem("nextArticle", JSON.stringify(nextArticle))
162
- })
163
- } else if (start = articleNum) {
164
- document.getElementById('cf-more').outerHTML = `<div id="cf-more" class="cf-new-add" onclick="loadNoArticle()"><small>一切皆有尽头!</small></div>`
165
- }
166
- }
167
- // 显示下一页文章,从本地缓存 nextArticle 中获取 <span class="cf-article-floor">${item.floor}</span>
168
-
169
- function loadNextArticle() {
170
- var nextArticle = JSON.parse(localStorage.getItem("nextArticle"));
171
- var articleItem = ""
172
- for (var i = 0; i < nextArticle.length; i++) {
173
- var item = nextArticle[i];
174
- var id = "cf-" + CryptoJS.MD5(item.link).toString();
175
- articleItem += `
176
- <div class="cf-article ${id}">
177
- <a class="cf-article-title" href="${item.link}" target="_blank" rel="noopener nofollow" data-title="${item.title}">${item.title}</a>
178
- <a class="cf-star" onclick="switchSecretInput(event)"><i class="fa-regular fa-star"></i></a>
179
- <div class="cf-article-avatar no-lightbox flink-item-icon">
180
- <img class="cf-img-avatar avatar" src="${item.avatar}" alt="avatar" onerror="this.src='${fdata.error_img}'; this.onerror = null;">
181
- <a onclick="openMeShow(event)" data-link="${item.link}" class="" target="_blank" rel="noopener nofollow" href="javascript:;"><span class="cf-article-author">${item.author}</span></a>
182
- </div>
183
- <span class="cf-article-time">
184
- <span class="cf-time-created" style="${sortNow == 'created' ? '' : 'display:none'}">${item.created}</span>
185
- <span class="cf-time-updated" style="${sortNow == 'updated' ? '' : 'display:none'}">${item.updated}</span>
186
- </span>
187
- </div>
188
- `;
189
- }
190
- container.insertAdjacentHTML('beforeend', articleItem);
191
- if (savedArticlesIndex != null) {checkStared(savedArticlesIndex);}
192
- // 同时预载下一页文章
193
- fetchNextArticle()
194
- }
195
- // 没有更多文章
196
- function loadNoArticle() {
197
- var articleSortData = sortNow + "ArticleData"
198
- localStorage.removeItem(articleSortData)
199
- localStorage.removeItem("statisticalData")
200
- //localStorage.removeItem("sortNow")
201
- document.getElementById('cf-more').remove()
202
- window.scrollTo(0, document.getElementsByClassName('cf-state').offsetTop)
203
- }
204
- // 清空本地数据
205
- function clearLocal() {
206
- localStorage.removeItem("updatedArticleData")
207
- localStorage.removeItem("createdArticleData")
208
- localStorage.removeItem("nextArticle")
209
- localStorage.removeItem("statisticalData")
210
- localStorage.removeItem("sortNow")
211
- localStorage.removeItem("urlNow")
212
- location.reload();
213
- }
214
- //
215
- function checkVersion() {
216
- var url = fdata.apiurl + "version"
217
- fetch(url)
218
- .then(res => res.json())
219
- .then(json => {
220
- console.log(json)
221
- var nowStatus = json.status, nowVersion = json.current_version, newVersion = json.latest_version
222
- var versionID = document.getElementById('cf-version-up')
223
- if (nowStatus == 0) {
224
- versionID.innerHTML = "当前版本:v" + nowVersion
225
- } else if (nowStatus == 1) {
226
- versionID.innerHTML = "发现新版本:v" + nowVersion + " ↦ " + newVersion
227
- } else {
228
- versionID.innerHTML = "网络错误,检测失败!"
229
- }
230
- })
231
- }
232
- // 切换为公共全库
233
- function changeEgg() {
234
- //有自定义json或api执行切换
235
- if (fdata.jsonurl || fdata.apiurl) {
236
- document.querySelectorAll('.cf-new-add').forEach(el => el.remove());
237
- localStorage.removeItem("updatedArticleData")
238
- localStorage.removeItem("createdArticleData")
239
- localStorage.removeItem("nextArticle")
240
- localStorage.removeItem("statisticalData")
241
- container.innerHTML = ""
242
- UrlNow = localStorage.getItem("urlNow")
243
- //console.log("新"+UrlNow)
244
- var UrlNowPublic = fdata.apipublieurl + 'all?'
245
- if (UrlNow !== UrlNowPublic) { //非完整默认公开库
246
- changeUrl = fdata.apipublieurl + 'all?'
247
- } else {
248
- if (fdata.jsonurl) {
249
- changeUrl = fdata.apipublieurl + 'postjson?jsonlink=' + fdata.jsonurl + "&"
250
- } else if (fdata.apiurl) {
251
- changeUrl = fdata.apiurl + 'all?'
252
- }
253
- }
254
- localStorage.setItem("urlNow", changeUrl)
255
- FetchFriendCircle(sortNow, changeUrl)
256
- } else {
257
- clearLocal()
258
- }
259
- }
260
- // 首次加载文章
261
- function FetchFriendCircle(sortNow, changeUrl) {
262
- var end = fdata.initnumber
263
- var fetchUrl = UrlNow + "rule=" + sortNow + "&start=0&end=" + end
264
- if (changeUrl) {
265
- fetchUrl = changeUrl + "rule=" + sortNow + "&start=0&end=" + end
266
- }
267
- //console.log(fetchUrl)
268
- fetch(fetchUrl)
269
- .then(res => res.json())
270
- .then(json => {
271
- var statisticalData = json.statistical_data;
272
- var articleData = eval(json.article_data);
273
- var articleSortData = sortNow + "ArticleData";
274
- loadStatistical(statisticalData);
275
- loadArticleItem(articleData, 0, end)
276
- localStorage.setItem("statisticalData", JSON.stringify(statisticalData))
277
- localStorage.setItem(articleSortData, JSON.stringify(articleData))
278
- })
279
- }
280
- // 点击切换排序
281
- function changeSort(event) {
282
- sortNow = event.currentTarget.dataset.sort
283
- localStorage.setItem("sortNow", sortNow)
284
- document.querySelectorAll('.cf-new-add').forEach(el => el.remove());
285
- container.innerHTML = "";
286
- changeUrl = localStorage.getItem("urlNow")
287
- //console.log(changeUrl)
288
- initFriendCircle(sortNow, changeUrl)
289
- if (fdata.apiurl) {
290
- checkVersion()
291
- }
292
- }
293
- //查询个人文章列表
294
- function openMeShow(event) {
295
- event.preventDefault()
296
- var parse_url = /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;
297
- var meLink = event.currentTarget.dataset.link.replace(parse_url, '$1:$2$3')
298
- console.log(meLink)
299
- var fetchUrl = ''
300
- if (fdata.apiurl) {
301
- fetchUrl = fdata.apiurl + "post?num=5&link=" + meLink
302
- } else {
303
- fetchUrl = fdata.apipublieurl + "post?num=5&link=" + meLink
304
- }
305
- //console.log(fetchUrl)
306
- if (noClick == 'ok') {
307
- noClick = 'no'
308
- fetchShow(fetchUrl)
309
- }
310
- }
311
- // 关闭 show
312
- function closeShow() {
313
- document.getElementById('cf-overlay').className -= 'cf-show-now';
314
- document.getElementById('cf-overshow').className -= 'cf-show-now';
315
- document.getElementById('cf-overshow').innerHTML = ''
316
- }
317
- // 点击开往
318
- var noClick = 'ok';
319
- function openToShow() {
320
- var fetchUrl = ''
321
- if (fdata.apiurl) {
322
- fetchUrl = fdata.apiurl + "post"
323
- } else {
324
- fetchUrl = fdata.apipublieurl + "post"
325
- }
326
- //console.log(fetchUrl)
327
- if (noClick == 'ok') {
328
- noClick = 'no'
329
- fetchShow(fetchUrl)
330
- }
331
- }
332
- // 展示个人文章列表
333
- function fetchShow(url) {
334
- var closeHtml = `
335
- <div class="cf-overshow-close" onclick="closeShow()"></div>
336
- `
337
- document.getElementById('cf-overlay').className = 'cf-show-now';
338
- document.getElementById('cf-overshow').insertAdjacentHTML('afterbegin', closeHtml);
339
- console.log("开往" + url)
340
- fetch(url)
341
- .then(res => res.json())
342
- .then(json => {
343
- //console.log(json)
344
- noClick = 'ok'
345
- var statisticalData = json.statistical_data;
346
- var articleData = eval(json.article_data);
347
- loadFcircleShow(statisticalData, articleData)
348
- })
349
- }
350
- // 初始化方法,如有本地数据首先调用
351
- function initFriendCircle(sortNow, changeUrl) {
352
- var articleSortData = sortNow + "ArticleData";
353
- var localStatisticalData = JSON.parse(localStorage.getItem("statisticalData"));
354
- var localArticleData = JSON.parse(localStorage.getItem(articleSortData));
355
- container.innerHTML = "";
356
- if (localStatisticalData && localArticleData) {
357
- loadStatistical(localStatisticalData);
358
- loadArticleItem(localArticleData, 0, fdata.initnumber)
359
- console.log("本地数据加载成功")
360
- var fetchUrl = UrlNow + "rule=" + sortNow + "&start=0&end=" + fdata.initnumber
361
- fetch(fetchUrl)
362
- .then(res => res.json())
363
- .then(json => {
364
- var statisticalData = json.statistical_data;
365
- var articleData = eval(json.article_data);
366
- //获取文章总数与第一篇文章标题
367
- var localSnum = localStatisticalData.article_num
368
- var newSnum = statisticalData.article_num
369
- var localAtile = localArticleData[0].title
370
- var newAtile = articleData[0].title
371
- //判断文章总数或文章标题是否一致,否则热更新
372
- if (localSnum !== newSnum || localAtile !== newAtile) {
373
- document.getElementById('cf-state').remove()
374
- document.getElementById('cf-more').remove()
375
- document.getElementById('cf-footer').remove()
376
- container.innerHTML = "";
377
- var articleSortData = sortNow + "ArticleData";
378
- loadStatistical(statisticalData);
379
- loadArticleItem(articleData, 0, fdata.initnumber)
380
- localStorage.setItem("statisticalData", JSON.stringify(statisticalData))
381
- localStorage.setItem(articleSortData, JSON.stringify(articleData))
382
- console.log("热更新完成")
383
- } else {
384
- console.log("API数据未更新")
385
- }
386
- })
387
- } else {
388
- FetchFriendCircle(sortNow, changeUrl)
389
- console.log("第一次加载完成")
390
- }
391
- }
392
- // 执行初始化
393
- initFriendCircle(sortNow)