cansin-blogdata 3.0.0

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.
Files changed (373) hide show
  1. package/Emotion/Bilibili/b01.gif +0 -0
  2. package/Emotion/Bilibili/b02.gif +0 -0
  3. package/Emotion/Bilibili/b03.gif +0 -0
  4. package/Emotion/Bilibili/b04.gif +0 -0
  5. package/Emotion/Bilibili/b05.gif +0 -0
  6. package/Emotion/Bilibili/b06.gif +0 -0
  7. package/Emotion/Bilibili/b07.gif +0 -0
  8. package/Emotion/Bilibili/b08.gif +0 -0
  9. package/Emotion/Bilibili/b09.gif +0 -0
  10. package/Emotion/Bilibili/b10.gif +0 -0
  11. package/Emotion/Bilibili/b11.gif +0 -0
  12. package/Emotion/Bilibili/b12.gif +0 -0
  13. package/Emotion/Bilibili/b13.gif +0 -0
  14. package/Emotion/Bilibili/b14.gif +0 -0
  15. package/Emotion/Bilibili/b15.gif +0 -0
  16. package/Emotion/Bilibili/b16.gif +0 -0
  17. package/Emotion/Bilibili/b17.gif +0 -0
  18. package/Emotion/Bilibili/b18.gif +0 -0
  19. package/Emotion/Bilibili/b19.gif +0 -0
  20. package/Emotion/Bilibili/b20.gif +0 -0
  21. package/Emotion/Bilibili/b21.gif +0 -0
  22. package/Emotion/Bilibili/b22.gif +0 -0
  23. package/Emotion/Bilibili/b23.gif +0 -0
  24. package/Emotion/Bilibili/b24.gif +0 -0
  25. package/Emotion/Bilibili/b25.gif +0 -0
  26. package/Emotion/Bilibili/b26.gif +0 -0
  27. package/Emotion/Bilibili/b27.gif +0 -0
  28. package/Emotion/Bilibili/b28.gif +0 -0
  29. package/Emotion/Bilibili/b29.gif +0 -0
  30. package/Emotion/Bilibili/b30.gif +0 -0
  31. package/Emotion/Bilibili/b31.gif +0 -0
  32. package/Emotion/Bilibili/b32.gif +0 -0
  33. package/Emotion/Bilibili/b33.gif +0 -0
  34. package/Emotion/Bilibili/b34.gif +0 -0
  35. package/Emotion/Bilibili/b35.gif +0 -0
  36. package/Emotion/Bilibili/b36.gif +0 -0
  37. package/Emotion/Bilibili/b37.gif +0 -0
  38. package/Emotion/Bilibili/b38.gif +0 -0
  39. package/Emotion/Bilibili/b39.gif +0 -0
  40. package/Emotion/Bilibili/b40.gif +0 -0
  41. package/Emotion/Bilibili/b41.gif +0 -0
  42. package/Emotion/Bilibili/b42.gif +0 -0
  43. package/Emotion/QQ/s0.gif +0 -0
  44. package/Emotion/QQ/s1.gif +0 -0
  45. package/Emotion/QQ/s10.gif +0 -0
  46. package/Emotion/QQ/s100.gif +0 -0
  47. package/Emotion/QQ/s101.gif +0 -0
  48. package/Emotion/QQ/s102.gif +0 -0
  49. package/Emotion/QQ/s103.gif +0 -0
  50. package/Emotion/QQ/s104.gif +0 -0
  51. package/Emotion/QQ/s105.gif +0 -0
  52. package/Emotion/QQ/s106.gif +0 -0
  53. package/Emotion/QQ/s107.gif +0 -0
  54. package/Emotion/QQ/s108.gif +0 -0
  55. package/Emotion/QQ/s109.gif +0 -0
  56. package/Emotion/QQ/s11.gif +0 -0
  57. package/Emotion/QQ/s110.gif +0 -0
  58. package/Emotion/QQ/s111.gif +0 -0
  59. package/Emotion/QQ/s112.gif +0 -0
  60. package/Emotion/QQ/s113.gif +0 -0
  61. package/Emotion/QQ/s114.gif +0 -0
  62. package/Emotion/QQ/s115.gif +0 -0
  63. package/Emotion/QQ/s116.gif +0 -0
  64. package/Emotion/QQ/s117.gif +0 -0
  65. package/Emotion/QQ/s118.gif +0 -0
  66. package/Emotion/QQ/s119.gif +0 -0
  67. package/Emotion/QQ/s12.gif +0 -0
  68. package/Emotion/QQ/s120.gif +0 -0
  69. package/Emotion/QQ/s121.gif +0 -0
  70. package/Emotion/QQ/s122.gif +0 -0
  71. package/Emotion/QQ/s123.gif +0 -0
  72. package/Emotion/QQ/s124.png +0 -0
  73. package/Emotion/QQ/s125.gif +0 -0
  74. package/Emotion/QQ/s126.gif +0 -0
  75. package/Emotion/QQ/s127.gif +0 -0
  76. package/Emotion/QQ/s128.gif +0 -0
  77. package/Emotion/QQ/s129.gif +0 -0
  78. package/Emotion/QQ/s13.gif +0 -0
  79. package/Emotion/QQ/s130.gif +0 -0
  80. package/Emotion/QQ/s131.gif +0 -0
  81. package/Emotion/QQ/s132.gif +0 -0
  82. package/Emotion/QQ/s133.gif +0 -0
  83. package/Emotion/QQ/s134.gif +0 -0
  84. package/Emotion/QQ/s135.gif +0 -0
  85. package/Emotion/QQ/s136.png +0 -0
  86. package/Emotion/QQ/s137.png +0 -0
  87. package/Emotion/QQ/s138.png +0 -0
  88. package/Emotion/QQ/s14.gif +0 -0
  89. package/Emotion/QQ/s140.png +0 -0
  90. package/Emotion/QQ/s141.png +0 -0
  91. package/Emotion/QQ/s142.png +0 -0
  92. package/Emotion/QQ/s143.png +0 -0
  93. package/Emotion/QQ/s144.png +0 -0
  94. package/Emotion/QQ/s145.png +0 -0
  95. package/Emotion/QQ/s146.png +0 -0
  96. package/Emotion/QQ/s147.png +0 -0
  97. package/Emotion/QQ/s148.png +0 -0
  98. package/Emotion/QQ/s149.png +0 -0
  99. package/Emotion/QQ/s15.png +0 -0
  100. package/Emotion/QQ/s150.png +0 -0
  101. package/Emotion/QQ/s151.png +0 -0
  102. package/Emotion/QQ/s152.png +0 -0
  103. package/Emotion/QQ/s153.png +0 -0
  104. package/Emotion/QQ/s154.png +0 -0
  105. package/Emotion/QQ/s155.png +0 -0
  106. package/Emotion/QQ/s156.png +0 -0
  107. package/Emotion/QQ/s157.png +0 -0
  108. package/Emotion/QQ/s158.png +0 -0
  109. package/Emotion/QQ/s159.png +0 -0
  110. package/Emotion/QQ/s16.gif +0 -0
  111. package/Emotion/QQ/s160.png +0 -0
  112. package/Emotion/QQ/s161.png +0 -0
  113. package/Emotion/QQ/s162.png +0 -0
  114. package/Emotion/QQ/s163.png +0 -0
  115. package/Emotion/QQ/s164.png +0 -0
  116. package/Emotion/QQ/s165.png +0 -0
  117. package/Emotion/QQ/s166.png +0 -0
  118. package/Emotion/QQ/s167.png +0 -0
  119. package/Emotion/QQ/s168.png +0 -0
  120. package/Emotion/QQ/s169.png +0 -0
  121. package/Emotion/QQ/s170.png +0 -0
  122. package/Emotion/QQ/s171.gif +0 -0
  123. package/Emotion/QQ/s172.gif +0 -0
  124. package/Emotion/QQ/s173.gif +0 -0
  125. package/Emotion/QQ/s174.gif +0 -0
  126. package/Emotion/QQ/s175.gif +0 -0
  127. package/Emotion/QQ/s176.gif +0 -0
  128. package/Emotion/QQ/s177.gif +0 -0
  129. package/Emotion/QQ/s178.gif +0 -0
  130. package/Emotion/QQ/s179.gif +0 -0
  131. package/Emotion/QQ/s18.gif +0 -0
  132. package/Emotion/QQ/s180.gif +0 -0
  133. package/Emotion/QQ/s181.gif +0 -0
  134. package/Emotion/QQ/s182.gif +0 -0
  135. package/Emotion/QQ/s183.gif +0 -0
  136. package/Emotion/QQ/s184.gif +0 -0
  137. package/Emotion/QQ/s185.gif +0 -0
  138. package/Emotion/QQ/s186.gif +0 -0
  139. package/Emotion/QQ/s187.gif +0 -0
  140. package/Emotion/QQ/s188.gif +0 -0
  141. package/Emotion/QQ/s189.gif +0 -0
  142. package/Emotion/QQ/s19.gif +0 -0
  143. package/Emotion/QQ/s190.gif +0 -0
  144. package/Emotion/QQ/s191.gif +0 -0
  145. package/Emotion/QQ/s192.gif +0 -0
  146. package/Emotion/QQ/s193.png +0 -0
  147. package/Emotion/QQ/s194.gif +0 -0
  148. package/Emotion/QQ/s195.gif +0 -0
  149. package/Emotion/QQ/s196.gif +0 -0
  150. package/Emotion/QQ/s197.gif +0 -0
  151. package/Emotion/QQ/s198.gif +0 -0
  152. package/Emotion/QQ/s199.gif +0 -0
  153. package/Emotion/QQ/s2.gif +0 -0
  154. package/Emotion/QQ/s20.gif +0 -0
  155. package/Emotion/QQ/s200.gif +0 -0
  156. package/Emotion/QQ/s201.gif +0 -0
  157. package/Emotion/QQ/s202.gif +0 -0
  158. package/Emotion/QQ/s203.gif +0 -0
  159. package/Emotion/QQ/s204.gif +0 -0
  160. package/Emotion/QQ/s205.gif +0 -0
  161. package/Emotion/QQ/s206.gif +0 -0
  162. package/Emotion/QQ/s207.gif +0 -0
  163. package/Emotion/QQ/s208.gif +0 -0
  164. package/Emotion/QQ/s209.gif +0 -0
  165. package/Emotion/QQ/s21.gif +0 -0
  166. package/Emotion/QQ/s210.gif +0 -0
  167. package/Emotion/QQ/s211.gif +0 -0
  168. package/Emotion/QQ/s212.gif +0 -0
  169. package/Emotion/QQ/s213.gif +0 -0
  170. package/Emotion/QQ/s214.gif +0 -0
  171. package/Emotion/QQ/s215.gif +0 -0
  172. package/Emotion/QQ/s216.gif +0 -0
  173. package/Emotion/QQ/s217.gif +0 -0
  174. package/Emotion/QQ/s218.gif +0 -0
  175. package/Emotion/QQ/s219.gif +0 -0
  176. package/Emotion/QQ/s22.gif +0 -0
  177. package/Emotion/QQ/s220.gif +0 -0
  178. package/Emotion/QQ/s221.gif +0 -0
  179. package/Emotion/QQ/s222.gif +0 -0
  180. package/Emotion/QQ/s223.gif +0 -0
  181. package/Emotion/QQ/s224.gif +0 -0
  182. package/Emotion/QQ/s225.gif +0 -0
  183. package/Emotion/QQ/s226.gif +0 -0
  184. package/Emotion/QQ/s227.gif +0 -0
  185. package/Emotion/QQ/s228.gif +0 -0
  186. package/Emotion/QQ/s229.gif +0 -0
  187. package/Emotion/QQ/s23.gif +0 -0
  188. package/Emotion/QQ/s230.gif +0 -0
  189. package/Emotion/QQ/s231.gif +0 -0
  190. package/Emotion/QQ/s232.gif +0 -0
  191. package/Emotion/QQ/s233.gif +0 -0
  192. package/Emotion/QQ/s234.gif +0 -0
  193. package/Emotion/QQ/s235.gif +0 -0
  194. package/Emotion/QQ/s236.gif +0 -0
  195. package/Emotion/QQ/s237.gif +0 -0
  196. package/Emotion/QQ/s238.gif +0 -0
  197. package/Emotion/QQ/s239.gif +0 -0
  198. package/Emotion/QQ/s24.gif +0 -0
  199. package/Emotion/QQ/s240.gif +0 -0
  200. package/Emotion/QQ/s241.gif +0 -0
  201. package/Emotion/QQ/s242.gif +0 -0
  202. package/Emotion/QQ/s243.gif +0 -0
  203. package/Emotion/QQ/s244.gif +0 -0
  204. package/Emotion/QQ/s245.gif +0 -0
  205. package/Emotion/QQ/s246.gif +0 -0
  206. package/Emotion/QQ/s247.gif +0 -0
  207. package/Emotion/QQ/s25.gif +0 -0
  208. package/Emotion/QQ/s26.gif +0 -0
  209. package/Emotion/QQ/s260.png +0 -0
  210. package/Emotion/QQ/s261.gif +0 -0
  211. package/Emotion/QQ/s262.gif +0 -0
  212. package/Emotion/QQ/s263.gif +0 -0
  213. package/Emotion/QQ/s264.gif +0 -0
  214. package/Emotion/QQ/s265.gif +0 -0
  215. package/Emotion/QQ/s266.gif +0 -0
  216. package/Emotion/QQ/s267.gif +0 -0
  217. package/Emotion/QQ/s268.gif +0 -0
  218. package/Emotion/QQ/s269.gif +0 -0
  219. package/Emotion/QQ/s27.gif +0 -0
  220. package/Emotion/QQ/s270.gif +0 -0
  221. package/Emotion/QQ/s271.gif +0 -0
  222. package/Emotion/QQ/s272.gif +0 -0
  223. package/Emotion/QQ/s273.png +0 -0
  224. package/Emotion/QQ/s274.png +0 -0
  225. package/Emotion/QQ/s276.png +0 -0
  226. package/Emotion/QQ/s277.png +0 -0
  227. package/Emotion/QQ/s278.gif +0 -0
  228. package/Emotion/QQ/s279.gif +0 -0
  229. package/Emotion/QQ/s28.gif +0 -0
  230. package/Emotion/QQ/s280.gif +0 -0
  231. package/Emotion/QQ/s281.gif +0 -0
  232. package/Emotion/QQ/s282.gif +0 -0
  233. package/Emotion/QQ/s283.gif +0 -0
  234. package/Emotion/QQ/s284.gif +0 -0
  235. package/Emotion/QQ/s285.gif +0 -0
  236. package/Emotion/QQ/s286.gif +0 -0
  237. package/Emotion/QQ/s287.gif +0 -0
  238. package/Emotion/QQ/s288.gif +0 -0
  239. package/Emotion/QQ/s289.gif +0 -0
  240. package/Emotion/QQ/s29.gif +0 -0
  241. package/Emotion/QQ/s290.gif +0 -0
  242. package/Emotion/QQ/s291.gif +0 -0
  243. package/Emotion/QQ/s292.gif +0 -0
  244. package/Emotion/QQ/s293.gif +0 -0
  245. package/Emotion/QQ/s294.gif +0 -0
  246. package/Emotion/QQ/s295.gif +0 -0
  247. package/Emotion/QQ/s296.gif +0 -0
  248. package/Emotion/QQ/s297.gif +0 -0
  249. package/Emotion/QQ/s298.gif +0 -0
  250. package/Emotion/QQ/s299.gif +0 -0
  251. package/Emotion/QQ/s3.gif +0 -0
  252. package/Emotion/QQ/s30.gif +0 -0
  253. package/Emotion/QQ/s300.gif +0 -0
  254. package/Emotion/QQ/s301.gif +0 -0
  255. package/Emotion/QQ/s302.gif +0 -0
  256. package/Emotion/QQ/s303.gif +0 -0
  257. package/Emotion/QQ/s304.gif +0 -0
  258. package/Emotion/QQ/s305.gif +0 -0
  259. package/Emotion/QQ/s306.png +0 -0
  260. package/Emotion/QQ/s307.png +0 -0
  261. package/Emotion/QQ/s308.gif +0 -0
  262. package/Emotion/QQ/s309.gif +0 -0
  263. package/Emotion/QQ/s31.gif +0 -0
  264. package/Emotion/QQ/s310.gif +0 -0
  265. package/Emotion/QQ/s311.gif +0 -0
  266. package/Emotion/QQ/s312.gif +0 -0
  267. package/Emotion/QQ/s313.gif +0 -0
  268. package/Emotion/QQ/s314.gif +0 -0
  269. package/Emotion/QQ/s315.gif +0 -0
  270. package/Emotion/QQ/s316.gif +0 -0
  271. package/Emotion/QQ/s317.gif +0 -0
  272. package/Emotion/QQ/s318.gif +0 -0
  273. package/Emotion/QQ/s319.gif +0 -0
  274. package/Emotion/QQ/s32.gif +0 -0
  275. package/Emotion/QQ/s320.gif +0 -0
  276. package/Emotion/QQ/s321.gif +0 -0
  277. package/Emotion/QQ/s322.gif +0 -0
  278. package/Emotion/QQ/s323.gif +0 -0
  279. package/Emotion/QQ/s324.gif +0 -0
  280. package/Emotion/QQ/s325.gif +0 -0
  281. package/Emotion/QQ/s326.gif +0 -0
  282. package/Emotion/QQ/s327.png +0 -0
  283. package/Emotion/QQ/s328.png +0 -0
  284. package/Emotion/QQ/s329.png +0 -0
  285. package/Emotion/QQ/s33.gif +0 -0
  286. package/Emotion/QQ/s330.png +0 -0
  287. package/Emotion/QQ/s331.png +0 -0
  288. package/Emotion/QQ/s332.gif +0 -0
  289. package/Emotion/QQ/s333.png +0 -0
  290. package/Emotion/QQ/s334.png +0 -0
  291. package/Emotion/QQ/s335.png +0 -0
  292. package/Emotion/QQ/s336.png +0 -0
  293. package/Emotion/QQ/s337.gif +0 -0
  294. package/Emotion/QQ/s338.gif +0 -0
  295. package/Emotion/QQ/s339.gif +0 -0
  296. package/Emotion/QQ/s34.gif +0 -0
  297. package/Emotion/QQ/s340.gif +0 -0
  298. package/Emotion/QQ/s341.gif +0 -0
  299. package/Emotion/QQ/s342.gif +0 -0
  300. package/Emotion/QQ/s343.gif +0 -0
  301. package/Emotion/QQ/s344.gif +0 -0
  302. package/Emotion/QQ/s345.gif +0 -0
  303. package/Emotion/QQ/s346.gif +0 -0
  304. package/Emotion/QQ/s347.png +0 -0
  305. package/Emotion/QQ/s348.png +0 -0
  306. package/Emotion/QQ/s35.gif +0 -0
  307. package/Emotion/QQ/s36.png +0 -0
  308. package/Emotion/QQ/s37.png +0 -0
  309. package/Emotion/QQ/s38.gif +0 -0
  310. package/Emotion/QQ/s39.gif +0 -0
  311. package/Emotion/QQ/s4.gif +0 -0
  312. package/Emotion/QQ/s41.png +0 -0
  313. package/Emotion/QQ/s42.gif +0 -0
  314. package/Emotion/QQ/s43.gif +0 -0
  315. package/Emotion/QQ/s46.png +0 -0
  316. package/Emotion/QQ/s49.gif +0 -0
  317. package/Emotion/QQ/s5.gif +0 -0
  318. package/Emotion/QQ/s53.gif +0 -0
  319. package/Emotion/QQ/s54.png +0 -0
  320. package/Emotion/QQ/s55.png +0 -0
  321. package/Emotion/QQ/s56.gif +0 -0
  322. package/Emotion/QQ/s57.gif +0 -0
  323. package/Emotion/QQ/s59.gif +0 -0
  324. package/Emotion/QQ/s6.gif +0 -0
  325. package/Emotion/QQ/s60.gif +0 -0
  326. package/Emotion/QQ/s61.png +0 -0
  327. package/Emotion/QQ/s63.png +0 -0
  328. package/Emotion/QQ/s64.png +0 -0
  329. package/Emotion/QQ/s66.png +0 -0
  330. package/Emotion/QQ/s67.gif +0 -0
  331. package/Emotion/QQ/s69.png +0 -0
  332. package/Emotion/QQ/s7.gif +0 -0
  333. package/Emotion/QQ/s74.png +0 -0
  334. package/Emotion/QQ/s75.png +0 -0
  335. package/Emotion/QQ/s76.gif +0 -0
  336. package/Emotion/QQ/s77.gif +0 -0
  337. package/Emotion/QQ/s78.gif +0 -0
  338. package/Emotion/QQ/s79.gif +0 -0
  339. package/Emotion/QQ/s8.gif +0 -0
  340. package/Emotion/QQ/s85.png +0 -0
  341. package/Emotion/QQ/s86.gif +0 -0
  342. package/Emotion/QQ/s89.png +0 -0
  343. package/Emotion/QQ/s9.gif +0 -0
  344. package/Emotion/QQ/s96.gif +0 -0
  345. package/Emotion/QQ/s97.gif +0 -0
  346. package/Emotion/QQ/s98.gif +0 -0
  347. package/Emotion/QQ/s99.gif +0 -0
  348. package/README.md +9 -0
  349. package/css/APlayer.min.css +3 -0
  350. package/css/app-mplayer.css +1 -0
  351. package/css/fcircle.css +337 -0
  352. package/css/font.min.css +1 -0
  353. package/css/gavin.min.css +1 -0
  354. package/css/index.css +7688 -0
  355. package/font//345/217/202/346/230/237/351/230/201.woff2 +0 -0
  356. package/js/APlayer.min.js +2 -0
  357. package/js/Meting.min.js +1 -0
  358. package/js/Meting2.min.js +110 -0
  359. package/js/app-mplayer.js +1 -0
  360. package/js/countup.min.js +1 -0
  361. package/js/datasheet.min.js +1 -0
  362. package/js/encryption.js +162 -0
  363. package/js/fcircle.js +393 -0
  364. package/js/gavin.min.js +1 -0
  365. package/js/lunar.min.js +1 -0
  366. package/js/main.js +784 -0
  367. package/js/paint.min.js +1 -0
  368. package/js/runtime.min.js +1 -0
  369. package/js/tw_cn.js +124 -0
  370. package/js/universe.js +2 -0
  371. package/js/utils.js +278 -0
  372. package/json/emoji.json +2144 -0
  373. package/package.json +22 -0
package/js/main.js ADDED
@@ -0,0 +1,784 @@
1
+ document.addEventListener('DOMContentLoaded', function () {
2
+ let blogNameWidth, menusWidth, searchWidth, $nav
3
+ let mobileSidebarOpen = false
4
+
5
+ const adjustMenu = (init) => {
6
+ if (init) {
7
+ blogNameWidth = document.getElementById('site-name').offsetWidth
8
+ const $menusEle = document.querySelectorAll('#menus .menus_item')
9
+ menusWidth = 0
10
+ $menusEle.length && $menusEle.forEach(i => { menusWidth += i.offsetWidth })
11
+ const $searchEle = document.querySelector('#search-button')
12
+ searchWidth = $searchEle ? $searchEle.offsetWidth : 0
13
+ $nav = document.getElementById('nav')
14
+ }
15
+
16
+ let hideMenuIndex = ''
17
+ if (window.innerWidth <= 768) hideMenuIndex = true
18
+ else hideMenuIndex = blogNameWidth + menusWidth + searchWidth > $nav.offsetWidth - 120
19
+
20
+ if (hideMenuIndex) {
21
+ $nav.classList.add('hide-menu')
22
+ } else {
23
+ $nav.classList.remove('hide-menu')
24
+ }
25
+ }
26
+
27
+ // 初始化header
28
+ const initAdjust = () => {
29
+ adjustMenu(true)
30
+ $nav.classList.add('show')
31
+ }
32
+
33
+ // sidebar menus
34
+ const sidebarFn = {
35
+ open: () => {
36
+ btf.sidebarPaddingR()
37
+ document.body.style.overflow = 'hidden'
38
+ btf.animateIn(document.getElementById('menu-mask'), 'to_show 0.5s')
39
+ document.getElementById('sidebar-menus').classList.add('open')
40
+ mobileSidebarOpen = true
41
+ },
42
+ close: () => {
43
+ const $body = document.body
44
+ $body.style.overflow = ''
45
+ $body.style.paddingRight = ''
46
+ btf.animateOut(document.getElementById('menu-mask'), 'to_hide 0.5s')
47
+ document.getElementById('sidebar-menus').classList.remove('open')
48
+ mobileSidebarOpen = false
49
+ }
50
+ }
51
+
52
+ /**
53
+ * 首頁top_img底下的箭頭
54
+ */
55
+ const scrollDownInIndex = () => {
56
+ const $scrollDownEle = document.getElementById('scroll-down')
57
+ $scrollDownEle && $scrollDownEle.addEventListener('click', function () {
58
+ btf.scrollToDest(document.getElementById('content-inner').offsetTop, 300)
59
+ })
60
+ }
61
+
62
+ /**
63
+ * 代碼
64
+ * 只適用於Hexo默認的代碼渲染
65
+ */
66
+ const addHighlightTool = function () {
67
+ const highLight = GLOBAL_CONFIG.highlight
68
+ if (!highLight) return
69
+
70
+ const isHighlightCopy = highLight.highlightCopy
71
+ const isHighlightLang = highLight.highlightLang
72
+ const isHighlightShrink = GLOBAL_CONFIG_SITE.isHighlightShrink
73
+ const highlightHeightLimit = highLight.highlightHeightLimit
74
+ const isShowTool = isHighlightCopy || isHighlightLang || isHighlightShrink !== undefined
75
+ const $figureHighlight = highLight.plugin === 'highlighjs' ? document.querySelectorAll('figure.highlight') : document.querySelectorAll('pre[class*="language-"]')
76
+
77
+ if (!((isShowTool || highlightHeightLimit) && $figureHighlight.length)) return
78
+
79
+ const isPrismjs = highLight.plugin === 'prismjs'
80
+
81
+ let highlightShrinkEle = ''
82
+ let highlightCopyEle = ''
83
+ const highlightShrinkClass = isHighlightShrink === true ? 'closed' : ''
84
+
85
+ if (isHighlightShrink !== undefined) {
86
+ highlightShrinkEle = `<i class="fas fa-angle-down expand ${highlightShrinkClass}"></i>`
87
+ }
88
+
89
+ if (isHighlightCopy) {
90
+ highlightCopyEle = '<div class="copy-notice"></div><i class="fas fa-paste copy-button"></i>'
91
+ }
92
+
93
+ const copy = (text, ctx) => {
94
+ if (document.queryCommandSupported && document.queryCommandSupported('copy')) {
95
+ document.execCommand('copy')
96
+ if (GLOBAL_CONFIG.Snackbar !== undefined) {
97
+ btf.snackbarShow(GLOBAL_CONFIG.copy.success)
98
+ } else {
99
+ const prevEle = ctx.previousElementSibling
100
+ prevEle.innerText = GLOBAL_CONFIG.copy.success
101
+ prevEle.style.opacity = 1
102
+ setTimeout(() => { prevEle.style.opacity = 0 }, 700)
103
+ }
104
+ if(set_notice.checked) tools.showMessage("复制成功!转载请注明来源!","success",2)
105
+ } else {
106
+ if (GLOBAL_CONFIG.Snackbar !== undefined) {
107
+ btf.snackbarShow(GLOBAL_CONFIG.copy.noSupport)
108
+ } else {
109
+ ctx.previousElementSibling.innerText = GLOBAL_CONFIG.copy.noSupport
110
+ }
111
+ if(set_notice.checked) tools.showMessage("Error!复制失败!","error",2)
112
+ }
113
+ }
114
+
115
+ // click events
116
+ const highlightCopyFn = (ele) => {
117
+ const $buttonParent = ele.parentNode
118
+ $buttonParent.classList.add('copy-true')
119
+ const selection = window.getSelection()
120
+ const range = document.createRange()
121
+ if (isPrismjs) range.selectNodeContents($buttonParent.querySelectorAll('pre code')[0])
122
+ else range.selectNodeContents($buttonParent.querySelectorAll('table .code pre')[0])
123
+ selection.removeAllRanges()
124
+ selection.addRange(range)
125
+ const text = selection.toString()
126
+ copy(text, ele.lastChild)
127
+ selection.removeAllRanges()
128
+ $buttonParent.classList.remove('copy-true')
129
+ }
130
+
131
+ const highlightShrinkFn = (ele) => {
132
+ const $nextEle = [...ele.parentNode.children].slice(1)
133
+ ele.firstChild.classList.toggle('closed')
134
+ if (btf.isHidden($nextEle[$nextEle.length - 1])) {
135
+ $nextEle.forEach(e => { e.style.display = 'block' })
136
+ } else {
137
+ $nextEle.forEach(e => { e.style.display = 'none' })
138
+ }
139
+ }
140
+
141
+ const highlightToolsFn = function (e) {
142
+ const $target = e.target.classList
143
+ if ($target.contains('expand')) highlightShrinkFn(this)
144
+ else if ($target.contains('copy-button')) highlightCopyFn(this)
145
+ }
146
+
147
+ const expandCode = function () {
148
+ this.classList.toggle('expand-done')
149
+ }
150
+
151
+ function createEle (lang, item, service) {
152
+ const fragment = document.createDocumentFragment()
153
+
154
+ if (isShowTool) {
155
+ const hlTools = document.createElement('div')
156
+ hlTools.className = `highlight-tools ${highlightShrinkClass}`
157
+ hlTools.innerHTML = highlightShrinkEle + lang + highlightCopyEle
158
+ hlTools.addEventListener('click', highlightToolsFn)
159
+ fragment.appendChild(hlTools)
160
+ }
161
+
162
+ if (highlightHeightLimit && item.offsetHeight > highlightHeightLimit + 30) {
163
+ const ele = document.createElement('div')
164
+ ele.className = 'code-expand-btn'
165
+ ele.innerHTML = '<i class="fas fa-angle-double-down"></i>'
166
+ ele.addEventListener('click', expandCode)
167
+ fragment.appendChild(ele)
168
+ }
169
+
170
+ if (service === 'hl') {
171
+ item.insertBefore(fragment, item.firstChild)
172
+ } else {
173
+ item.parentNode.insertBefore(fragment, item)
174
+ }
175
+ }
176
+
177
+ if (isHighlightLang) {
178
+ if (isPrismjs) {
179
+ $figureHighlight.forEach(function (item) {
180
+ const langName = item.getAttribute('data-language') ? item.getAttribute('data-language') : 'Code'
181
+ const highlightLangEle = `<div class="code-lang">${langName}</div>`
182
+ btf.wrap(item, 'figure', { class: 'highlight' })
183
+ createEle(highlightLangEle, item)
184
+ })
185
+ } else {
186
+ $figureHighlight.forEach(function (item) {
187
+ let langName = item.getAttribute('class').split(' ')[1]
188
+ if (langName === 'plain' || langName === undefined) langName = 'Code'
189
+ const highlightLangEle = `<div class="code-lang">${langName}</div>`
190
+ createEle(highlightLangEle, item, 'hl')
191
+ })
192
+ }
193
+ } else {
194
+ if (isPrismjs) {
195
+ $figureHighlight.forEach(function (item) {
196
+ btf.wrap(item, 'figure', { class: 'highlight' })
197
+ createEle('', item)
198
+ })
199
+ } else {
200
+ $figureHighlight.forEach(function (item) {
201
+ createEle('', item, 'hl')
202
+ })
203
+ }
204
+ }
205
+ }
206
+
207
+ /**
208
+ * PhotoFigcaption
209
+ */
210
+ function addPhotoFigcaption () {
211
+ document.querySelectorAll('#article-container img').forEach(function (item) {
212
+ const parentEle = item.parentNode
213
+ const altValue = item.title || item.alt
214
+ if (altValue && !parentEle.parentNode.classList.contains('justified-gallery')) {
215
+ const ele = document.createElement('div')
216
+ ele.className = 'img-alt is-center'
217
+ ele.textContent = altValue
218
+ parentEle.insertBefore(ele, item.nextSibling)
219
+ }
220
+ })
221
+ }
222
+
223
+ /**
224
+ * Lightbox
225
+ */
226
+ const runLightbox = () => {
227
+ btf.loadLightbox(document.querySelectorAll('#article-container img:not(.no-lightbox)'))
228
+ }
229
+
230
+ /**
231
+ * justified-gallery 圖庫排版
232
+ */
233
+ const runJustifiedGallery = function (ele) {
234
+ ele.forEach(item => {
235
+ const $imgList = item.querySelectorAll('img')
236
+
237
+ $imgList.forEach(i => {
238
+ const dataLazySrc = i.getAttribute('data-lazy-src')
239
+ if (dataLazySrc) i.src = dataLazySrc
240
+ btf.wrap(i, 'div', { class: 'fj-gallery-item' })
241
+ })
242
+ })
243
+
244
+ if (window.fjGallery) {
245
+ setTimeout(() => { btf.initJustifiedGallery(ele) }, 100)
246
+ return
247
+ }
248
+
249
+ const newEle = document.createElement('link')
250
+ newEle.rel = 'stylesheet'
251
+ newEle.href = GLOBAL_CONFIG.source.justifiedGallery.css
252
+ document.body.appendChild(newEle)
253
+ getScript(`${GLOBAL_CONFIG.source.justifiedGallery.js}`).then(() => { btf.initJustifiedGallery(ele) })
254
+ }
255
+
256
+ /**
257
+ * 滾動處理
258
+ */
259
+ const scrollFn = function () {
260
+ const $rightside = document.getElementById('rightside')
261
+ const innerHeight = window.innerHeight + 56
262
+ const scrollHeight = document.body.scrollHeight + 400
263
+ // console.log("document.body.scrollHeight: " + scrollHeight)
264
+ // console.log("window.innerHeight: " + (innerHeight - 56))
265
+ // 當滾動條小于 56 的時候
266
+ if (scrollHeight <= innerHeight) {
267
+ $rightside.style.cssText = 'opacity: 1; transform: translateX(-88px)'
268
+ return
269
+ }
270
+
271
+ // find the scroll direction
272
+ function scrollDirection (currentTop) {
273
+ const result = currentTop > initTop // true is down & false is up
274
+ initTop = currentTop
275
+ return result
276
+ }
277
+
278
+ let initTop = 0
279
+ let isChatShow = true
280
+ const $header = document.getElementById('page-header')
281
+ const isChatBtnHide = typeof chatBtnHide === 'function'
282
+ const isChatBtnShow = typeof chatBtnShow === 'function'
283
+
284
+ const scrollTask = btf.throttle(() => {
285
+ const currentTop = window.scrollY || document.documentElement.scrollTop
286
+ const isDown = scrollDirection(currentTop)
287
+ if (currentTop > 56) {
288
+ $header.classList.add('is-top-bar')
289
+ if (isDown) {
290
+ if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible')
291
+ if (isChatBtnShow && isChatShow === true) {
292
+ chatBtnHide()
293
+ isChatShow = false
294
+ }
295
+ } else {
296
+ if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible')
297
+ if (isChatBtnHide && isChatShow === false) {
298
+ chatBtnShow()
299
+ isChatShow = true
300
+ }
301
+ }
302
+ $header.classList.add('nav-fixed')
303
+ if (window.getComputedStyle($rightside).getPropertyValue('opacity') === '0') {
304
+ $rightside.style.cssText = 'opacity: 1; transform: translateX(-88px)'
305
+ }
306
+ } else {
307
+ if (currentTop === 0) {
308
+ // $header.classList.remove('nav-fixed', 'nav-visible')
309
+ $header.classList.remove('is-top-bar')
310
+ $header.classList.add('nav-visible')
311
+ }
312
+ $rightside.style.cssText = "opacity: ''; transform: ''"
313
+ }
314
+
315
+ if (scrollHeight <= innerHeight) {
316
+ $rightside.style.cssText = 'opacity: 1; transform: translateX(-88px)'
317
+ }
318
+ }, 200)
319
+
320
+ window.scrollCollect = scrollTask
321
+ window.addEventListener('scroll', scrollCollect)
322
+ }
323
+
324
+ /**
325
+ * toc,anchor
326
+ */
327
+ const scrollFnToDo = function () {
328
+ const isToc = GLOBAL_CONFIG_SITE.isToc
329
+ const isAnchor = GLOBAL_CONFIG.isAnchor
330
+ const $article = document.getElementById('article-container')
331
+
332
+ if (!($article && (isToc || isAnchor))) return
333
+
334
+ let $tocLink, $cardToc, scrollPercent, autoScrollToc, isExpand
335
+
336
+ if (isToc) {
337
+ const $cardTocLayout = document.getElementById('card-toc')
338
+ $cardToc = $cardTocLayout.getElementsByClassName('toc-content')[0]
339
+ $tocLink = $cardToc.querySelectorAll('.toc-link')
340
+ const $tocPercentage = $cardTocLayout.querySelector('.toc-percentage')
341
+ isExpand = $cardToc.classList.contains('is-expand')
342
+
343
+ scrollPercent = currentTop => {
344
+ const docHeight = $article.clientHeight
345
+ const winHeight = document.documentElement.clientHeight
346
+ const headerHeight = $article.offsetTop
347
+ const contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : (document.documentElement.scrollHeight - winHeight)
348
+ const scrollPercent = (currentTop - headerHeight) / (contentMath)
349
+ const scrollPercentRounded = Math.round(scrollPercent * 100)
350
+ const percentage = (scrollPercentRounded > 100) ? 100 : (scrollPercentRounded <= 0) ? 0 : scrollPercentRounded
351
+ $tocPercentage.textContent = percentage
352
+ }
353
+
354
+ window.mobileToc = {
355
+ open: () => {
356
+ $cardTocLayout.style.cssText = 'animation: toc-open .3s; opacity: 1; right: 55px'
357
+ },
358
+
359
+ close: () => {
360
+ $cardTocLayout.style.animation = 'toc-close .2s'
361
+ setTimeout(() => {
362
+ $cardTocLayout.style.cssText = "opacity:''; animation: ''; right: ''"
363
+ }, 100)
364
+ }
365
+ }
366
+
367
+ // toc元素點擊
368
+ $cardToc.addEventListener('click', e => {
369
+ e.preventDefault()
370
+ const target = e.target.classList
371
+ if (target.contains('toc-content')) return
372
+ const $target = target.contains('toc-link')
373
+ ? e.target
374
+ : e.target.parentElement
375
+ btf.scrollToDest(btf.getEleTop(document.getElementById(decodeURI($target.getAttribute('href')).replace('#', ''))), 300)
376
+ if (window.innerWidth < 900) {
377
+ window.mobileToc.close()
378
+ }
379
+ })
380
+
381
+ autoScrollToc = item => {
382
+ const activePosition = item.getBoundingClientRect().top
383
+ const sidebarScrollTop = $cardToc.scrollTop
384
+ if (activePosition > (document.documentElement.clientHeight - 100)) {
385
+ $cardToc.scrollTop = sidebarScrollTop + 150
386
+ }
387
+ if (activePosition < 100) {
388
+ $cardToc.scrollTop = sidebarScrollTop - 150
389
+ }
390
+ }
391
+ }
392
+
393
+ // find head position & add active class
394
+ const list = $article.querySelectorAll('h1,h2,h3,h4,h5,h6')
395
+ let detectItem = ''
396
+ const findHeadPosition = function (top) {
397
+ if (top === 0) {
398
+ return false
399
+ }
400
+
401
+ let currentId = ''
402
+ let currentIndex = ''
403
+
404
+ list.forEach(function (ele, index) {
405
+ if (top > btf.getEleTop(ele) - 80) {
406
+ const id = ele.id
407
+ currentId = id ? '#' + encodeURI(id) : ''
408
+ currentIndex = index
409
+ }
410
+ })
411
+
412
+ if (detectItem === currentIndex) return
413
+
414
+ if (isAnchor) btf.updateAnchor(currentId)
415
+
416
+ detectItem = currentIndex
417
+
418
+ if (isToc) {
419
+ $cardToc.querySelectorAll('.active').forEach(i => { i.classList.remove('active') })
420
+
421
+ if (currentId === '') {
422
+ return
423
+ }
424
+
425
+ const currentActive = $tocLink[currentIndex]
426
+ currentActive.classList.add('active')
427
+
428
+ setTimeout(() => {
429
+ autoScrollToc(currentActive)
430
+ }, 0)
431
+
432
+ if (isExpand) return
433
+ let parent = currentActive.parentNode
434
+
435
+ for (; !parent.matches('.toc'); parent = parent.parentNode) {
436
+ if (parent.matches('li')) parent.classList.add('active')
437
+ }
438
+ }
439
+ }
440
+
441
+ // main of scroll
442
+ window.tocScrollFn = function () {
443
+ return btf.throttle(function () {
444
+ const currentTop = window.scrollY || document.documentElement.scrollTop
445
+ isToc && scrollPercent(currentTop)
446
+ findHeadPosition(currentTop)
447
+ }, 100)()
448
+ }
449
+ window.addEventListener('scroll', tocScrollFn)
450
+ }
451
+
452
+ /**
453
+ * Rightside
454
+ */
455
+ const rightSideFn = {
456
+ switchReadMode: () => { // read-mode
457
+ const $body = document.body
458
+ $body.classList.add('read-mode')
459
+ const newEle = document.createElement('button')
460
+ newEle.type = 'button'
461
+ newEle.className = 'fas fa-sign-out-alt exit-readmode'
462
+ $body.appendChild(newEle)
463
+
464
+ function clickFn () {
465
+ $body.classList.remove('read-mode')
466
+ newEle.remove()
467
+ newEle.removeEventListener('click', clickFn)
468
+ }
469
+
470
+ newEle.addEventListener('click', clickFn)
471
+ },
472
+ switchDarkMode: () => { // Switch Between Light And Dark Mode
473
+ const nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
474
+ if (nowMode === 'light') {
475
+ activateDarkMode()
476
+ saveToLocal.set('theme', 'dark', 2)
477
+ GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night)
478
+ } else {
479
+ activateLightMode()
480
+ saveToLocal.set('theme', 'light', 2)
481
+ GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day)
482
+ }
483
+ // handle some cases
484
+ typeof utterancesTheme === 'function' && utterancesTheme()
485
+ typeof changeGiscusTheme === 'function' && changeGiscusTheme()
486
+ typeof FB === 'object' && window.loadFBComment && window.loadFBComment()
487
+ typeof runMermaid === 'function' && window.runMermaid()
488
+ },
489
+ showOrHideBtn: (e) => { // rightside 點擊設置 按鈕 展開
490
+ const rightsideHideClassList = document.getElementById('rightside-config-hide').classList
491
+ rightsideHideClassList.toggle('show')
492
+ if (e.classList.contains('show')) {
493
+ rightsideHideClassList.add('status')
494
+ setTimeout(() => {
495
+ rightsideHideClassList.remove('status')
496
+ }, 300)
497
+ }
498
+ e.classList.toggle('show')
499
+ },
500
+ scrollToTop: () => { // Back to top
501
+ btf.scrollToDest(0, 500)
502
+ },
503
+ hideAsideBtn: () => { // Hide aside
504
+ const $htmlDom = document.documentElement.classList
505
+ $htmlDom.contains('hide-aside')
506
+ ? saveToLocal.set('aside-status', 'show', 2)
507
+ : saveToLocal.set('aside-status', 'hide', 2)
508
+ $htmlDom.toggle('hide-aside')
509
+ },
510
+
511
+ runMobileToc: () => {
512
+ if (window.getComputedStyle(document.getElementById('card-toc')).getPropertyValue('opacity') === '0') window.mobileToc.open()
513
+ else window.mobileToc.close()
514
+ }
515
+ }
516
+
517
+ document.getElementById('rightside').addEventListener('click', function (e) {
518
+ const $target = e.target.id ? e.target : e.target.parentNode
519
+ switch ($target.id) {
520
+ case 'go-up':
521
+ rightSideFn.scrollToTop()
522
+ break
523
+ case 'rightside_config':
524
+ rightSideFn.showOrHideBtn($target)
525
+ break
526
+ case 'mobile-toc-button':
527
+ rightSideFn.runMobileToc()
528
+ break
529
+ case 'readmode':
530
+ rightSideFn.switchReadMode()
531
+ break
532
+ case 'darkmode':
533
+ rightSideFn.switchDarkMode()
534
+ break
535
+ case 'hide-aside-btn':
536
+ rightSideFn.hideAsideBtn()
537
+ break
538
+ default:
539
+ break
540
+ }
541
+ })
542
+
543
+ /**
544
+ * menu
545
+ * 側邊欄sub-menu 展開/收縮
546
+ */
547
+ const clickFnOfSubMenu = () => {
548
+ document.querySelectorAll('#sidebar-menus .site-page.group').forEach(function (item) {
549
+ item.addEventListener('click', function () {
550
+ this.classList.toggle('hide')
551
+ })
552
+ })
553
+ }
554
+
555
+ /**
556
+ * 複製時加上版權信息
557
+ */
558
+ const addCopyright = () => {
559
+ const copyright = GLOBAL_CONFIG.copyright
560
+ document.body.oncopy = (e) => {
561
+ e.preventDefault()
562
+ let textFont; const copyFont = window.getSelection(0).toString()
563
+ if (copyFont.length > copyright.limitCount) {
564
+ textFont = copyFont + '\n' + '\n' + '\n' +
565
+ copyright.languages.author + '\n' +
566
+ copyright.languages.link + window.location.href + '\n' +
567
+ copyright.languages.source + '\n' +
568
+ copyright.languages.info
569
+ } else {
570
+ textFont = copyFont
571
+ }
572
+ if (e.clipboardData) {
573
+ return e.clipboardData.setData('text', textFont)
574
+ } else {
575
+ return window.clipboardData.setData('text', textFont)
576
+ }
577
+ }
578
+ }
579
+
580
+ /**
581
+ * 網頁運行時間
582
+ */
583
+ const addRuntime = () => {
584
+ const $runtimeCount = document.getElementById('runtimeshow')
585
+ if ($runtimeCount) {
586
+ const publishDate = $runtimeCount.getAttribute('data-publishDate')
587
+ $runtimeCount.innerText = btf.diffDate(publishDate) + ' ' + GLOBAL_CONFIG.runtime
588
+ }
589
+ }
590
+
591
+ /**
592
+ * 最後一次更新時間
593
+ */
594
+ const addLastPushDate = () => {
595
+ const $lastPushDateItem = document.getElementById('last-push-date')
596
+ if ($lastPushDateItem) {
597
+ const lastPushDate = $lastPushDateItem.getAttribute('data-lastPushDate')
598
+ $lastPushDateItem.innerText = btf.diffDate(lastPushDate, true)
599
+ }
600
+ }
601
+
602
+ /**
603
+ * table overflow
604
+ */
605
+ const addTableWrap = () => {
606
+ const $table = document.querySelectorAll('#article-container :not(.highlight) > table, #article-container > table')
607
+ if ($table.length) {
608
+ $table.forEach(item => {
609
+ btf.wrap(item, 'div', { class: 'table-wrap' })
610
+ })
611
+ }
612
+ }
613
+
614
+ /**
615
+ * tag-hide
616
+ */
617
+ const clickFnOfTagHide = function () {
618
+ const $hideInline = document.querySelectorAll('#article-container .hide-button')
619
+ if ($hideInline.length) {
620
+ $hideInline.forEach(function (item) {
621
+ item.addEventListener('click', function (e) {
622
+ const $this = this
623
+ $this.classList.add('open')
624
+ const $fjGallery = $this.nextElementSibling.querySelectorAll('.fj-gallery')
625
+ $fjGallery.length && btf.initJustifiedGallery($fjGallery)
626
+ })
627
+ })
628
+ }
629
+ }
630
+
631
+ const tabsFn = {
632
+ clickFnOfTabs: function () {
633
+ document.querySelectorAll('#article-container .tab > button').forEach(function (item) {
634
+ item.addEventListener('click', function (e) {
635
+ const $this = this
636
+ const $tabItem = $this.parentNode
637
+
638
+ if (!$tabItem.classList.contains('active')) {
639
+ const $tabContent = $tabItem.parentNode.nextElementSibling
640
+ const $siblings = btf.siblings($tabItem, '.active')[0]
641
+ $siblings && $siblings.classList.remove('active')
642
+ $tabItem.classList.add('active')
643
+ const tabId = $this.getAttribute('data-href').replace('#', '')
644
+ const childList = [...$tabContent.children]
645
+ childList.forEach(item => {
646
+ if (item.id === tabId) item.classList.add('active')
647
+ else item.classList.remove('active')
648
+ })
649
+ const $isTabJustifiedGallery = $tabContent.querySelectorAll(`#${tabId} .fj-gallery`)
650
+ if ($isTabJustifiedGallery.length > 0) {
651
+ btf.initJustifiedGallery($isTabJustifiedGallery)
652
+ }
653
+ }
654
+ })
655
+ })
656
+ },
657
+ backToTop: () => {
658
+ document.querySelectorAll('#article-container .tabs .tab-to-top').forEach(function (item) {
659
+ item.addEventListener('click', function () {
660
+ btf.scrollToDest(btf.getEleTop(btf.getParents(this, '.tabs')), 300)
661
+ })
662
+ })
663
+ }
664
+ }
665
+
666
+ const toggleCardCategory = function () {
667
+ const $cardCategory = document.querySelectorAll('#aside-cat-list .card-category-list-item.parent i')
668
+ if ($cardCategory.length) {
669
+ $cardCategory.forEach(function (item) {
670
+ item.addEventListener('click', function (e) {
671
+ e.preventDefault()
672
+ const $this = this
673
+ $this.classList.toggle('expand')
674
+ const $parentEle = $this.parentNode.nextElementSibling
675
+ if (btf.isHidden($parentEle)) {
676
+ $parentEle.style.display = 'block'
677
+ } else {
678
+ $parentEle.style.display = 'none'
679
+ }
680
+ })
681
+ })
682
+ }
683
+ }
684
+
685
+ const switchComments = function () {
686
+ let switchDone = false
687
+ const $switchBtn = document.querySelector('#comment-switch > .switch-btn')
688
+ $switchBtn && $switchBtn.addEventListener('click', function () {
689
+ this.classList.toggle('move')
690
+ document.querySelectorAll('#post-comment > .comment-wrap > div').forEach(function (item) {
691
+ if (btf.isHidden(item)) {
692
+ item.style.cssText = 'display: block;animation: tabshow .5s'
693
+ } else {
694
+ item.style.cssText = "display: none;animation: ''"
695
+ }
696
+ })
697
+
698
+ if (!switchDone && typeof loadOtherComment === 'function') {
699
+ switchDone = true
700
+ loadOtherComment()
701
+ }
702
+ })
703
+ }
704
+
705
+ const addPostOutdateNotice = function () {
706
+ const data = GLOBAL_CONFIG.noticeOutdate
707
+ const diffDay = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate)
708
+ if (diffDay >= data.limitDay) {
709
+ const ele = document.createElement('div')
710
+ ele.className = 'post-outdate-notice'
711
+ ele.textContent = data.messagePrev + ' ' + diffDay + ' ' + data.messageNext
712
+ const $targetEle = document.getElementById('article-container')
713
+ if (data.position === 'top') {
714
+ $targetEle.insertBefore(ele, $targetEle.firstChild)
715
+ } else {
716
+ $targetEle.appendChild(ele)
717
+ }
718
+ }
719
+ }
720
+
721
+ const lazyloadImg = () => {
722
+ window.lazyLoadInstance = new LazyLoad({
723
+ elements_selector: 'img',
724
+ threshold: 0,
725
+ data_src: 'lazy-src'
726
+ })
727
+ }
728
+
729
+ const relativeDate = function (selector) {
730
+ selector.forEach(item => {
731
+ const $this = item
732
+ const timeVal = $this.getAttribute('datetime')
733
+ $this.innerText = btf.diffDate(timeVal, true)
734
+ $this.style.display = 'inline'
735
+ })
736
+ }
737
+
738
+ const unRefreshFn = function () {
739
+ window.addEventListener('resize', () => {
740
+ adjustMenu(false)
741
+ btf.isHidden(document.getElementById('toggle-menu')) && mobileSidebarOpen && sidebarFn.close()
742
+ })
743
+
744
+ document.getElementById('menu-mask').addEventListener('click', e => { sidebarFn.close() })
745
+
746
+ clickFnOfSubMenu()
747
+ GLOBAL_CONFIG.islazyload && lazyloadImg()
748
+ GLOBAL_CONFIG.copyright !== undefined && addCopyright()
749
+ }
750
+
751
+ window.refreshFn = function () {
752
+ initAdjust()
753
+
754
+ if (GLOBAL_CONFIG_SITE.isPost) {
755
+ GLOBAL_CONFIG.noticeOutdate !== undefined && addPostOutdateNotice()
756
+ GLOBAL_CONFIG.relativeDate.post && relativeDate(document.querySelectorAll('#post-meta time'))
757
+ } else {
758
+ GLOBAL_CONFIG.relativeDate.homepage && relativeDate(document.querySelectorAll('#recent-posts time'))
759
+ GLOBAL_CONFIG.runtime && addRuntime()
760
+ addLastPushDate()
761
+ toggleCardCategory()
762
+ }
763
+
764
+ scrollFnToDo()
765
+ GLOBAL_CONFIG_SITE.isHome && scrollDownInIndex()
766
+ addHighlightTool()
767
+ GLOBAL_CONFIG.isPhotoFigcaption && addPhotoFigcaption()
768
+ scrollFn()
769
+
770
+ const $jgEle = document.querySelectorAll('#article-container .fj-gallery')
771
+ $jgEle.length && runJustifiedGallery($jgEle)
772
+
773
+ runLightbox()
774
+ addTableWrap()
775
+ clickFnOfTagHide()
776
+ tabsFn.clickFnOfTabs()
777
+ tabsFn.backToTop()
778
+ switchComments()
779
+ document.getElementById('toggle-menu').addEventListener('click', () => { sidebarFn.open() })
780
+ }
781
+
782
+ refreshFn()
783
+ unRefreshFn()
784
+ })