cansin-blogdata 3.0.91 → 3.0.92
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/.github/workflows/autopublish.yml +18 -18
- package/README.md +9 -9
- package/css/APlayer.min.css +2 -2
- package/css/gavin.min.css +1 -1
- package/css/index.css +8716 -8463
- package/img/AI/346/202/246/345/210/233.svg +21 -21
- package/img/CAN-CIN-0-200.svg +29 -29
- package/img/CAN-CIN-f-200.svg +29 -29
- package/img/CANCIN-0-200.svg +29 -29
- package/img/CANCIN-f-200.svg +29 -29
- package/img/H501SE.webp +0 -0
- package/img/MX_Keys.webp +0 -0
- package/img/MX_Master2S.webp +0 -0
- package/img/Mate40Pro.webp +0 -0
- package/img/StarfishS5.webp +0 -0
- package/img/ThinkBook14.webp +0 -0
- package/img/ZHITAITiPlus7100.webp +0 -0
- package/img/star_blank.svg +1 -0
- package/img/star_fill.svg +1 -0
- package/js/APlayer.min.js +1 -1
- package/js/Meting2.min.js +109 -109
- package/js/gavin.min.js +1 -1
- package/js/main.js +785 -785
- package/js/tw_cn.js +124 -124
- package/js/utils.js +278 -278
- package/js/winbox.bundle.min.js +34 -34
- package/lrc/Blueming.lrc +45 -45
- package/lrc//344/270/200/346/240/274/346/240/274.lrc +68 -68
- package/lrc//344/270/216/345/246/206.lrc +49 -49
- package/lrc//344/270/224/347/254/221/347/272/242/345/260/230.lrc +34 -34
- package/lrc//344/272/272/351/227/264/345/237/216.lrc +45 -45
- package/lrc//344/272/272/351/227/264/350/234/211/350/235/243.lrc +31 -31
- package/lrc//344/275/234/346/233/262/345/256/266.lrc +78 -78
- package/lrc//345/200/237.lrc +44 -44
- package/lrc//345/200/276/345/260/275/345/244/251/344/270/213.lrc +61 -61
- package/lrc//345/203/217/346/210/221/350/277/231/346/240/267/347/232/204/344/272/272.lrc +67 -67
- package/lrc//345/203/217/351/261/274.lrc +34 -34
- package/lrc//345/205/270/347/213/261/345/217/270.lrc +70 -70
- package/lrc//345/207/272/345/261/261.lrc +50 -50
- package/lrc//345/214/227/345/237/216/344/273/245/345/214/227/345/215/227/345/237/216/344/273/245/345/215/227.lrc +53 -53
- package/lrc//345/215/203/345/215/203/344/270/207/344/270/207.lrc +62 -62
- package/lrc//345/215/227/345/261/261/345/215/227.lrc +47 -47
- package/lrc//345/215/227/346/226/271/345/247/221/345/250/230.lrc +26 -26
- package/lrc//345/216/213/350/275/264/346/210/217.lrc +48 -48
- package/lrc//345/217/252/350/246/201/345/271/263/345/207/241.lrc +56 -56
- package/lrc//345/220/214/346/270/241.lrc +79 -79
- package/lrc//345/226/234/345/211/247/344/271/213/347/216/213.lrc +45 -45
- package/lrc//345/233/215.lrc +79 -79
- package/lrc//345/233/275/347/216/213/344/270/216/344/271/236/344/270/220.lrc +82 -82
- package/lrc//345/234/250/344/275/240/347/232/204/350/272/253/350/276/271.lrc +73 -73
- package/lrc//345/260/217/351/227/256/351/242/230.lrc +49 -49
- package/lrc//345/261/261/346/234/211/346/234/250/345/205/256.lrc +53 -53
- package/lrc//345/262/201/346/234/210/347/245/236/345/201/267.lrc +55 -55
- package/lrc//345/275/222/345/216/273/346/235/245/345/205/256.lrc +43 -43
- package/lrc//346/201/213/346/201/213/346/225/205/344/272/272/351/232/276.lrc +89 -89
- package/lrc//346/202/254/346/272/272.lrc +37 -37
- package/lrc//346/210/221/344/273/254/347/232/204/346/227/266/345/205/211.lrc +22 -22
- package/lrc//346/210/221/350/256/260/345/276/227.lrc +89 -89
- package/lrc//346/212/212/345/233/236/345/277/206/346/213/274/345/245/275/347/273/231/344/275/240.lrc +125 -125
- package/lrc//346/227/240/350/250/200.lrc +39 -39
- package/lrc//346/227/240/351/227/256.lrc +40 -40
- package/lrc//346/230/237/346/262/263/344/270/207/351/207/214.lrc +40 -40
- package/lrc//346/235/200/346/255/273/351/202/243/344/270/252/347/237/263/345/256/266/345/272/204/344/272/272.lrc +22 -22
- package/lrc//346/235/245/346/227/245/346/226/271/351/225/277.lrc +38 -38
- package/lrc//346/265/252/345/255/220/345/233/236/345/244/264.lrc +45 -45
- package/lrc//346/266/210/346/204/201.lrc +65 -65
- package/lrc//347/210/270/347/210/270/345/246/210/345/246/210.lrc +79 -79
- package/lrc//347/211/265/344/270/235/346/210/217.lrc +39 -39
- package/lrc//347/220/264/345/270/210.lrc +51 -51
- package/lrc//347/224/237/346/255/273/346/261/237/346/271/226.lrc +58 -58
- package/lrc//347/224/237/350/200/214/344/270/272/344/272/272.lrc +57 -57
- package/lrc//347/227/205/345/217/230.lrc +64 -64
- package/lrc//347/233/227/345/260/206/350/241/214.lrc +47 -47
- package/lrc//347/237/245/346/210/221.lrc +56 -56
- package/lrc//350/207/264/344/275/240.lrc +94 -94
- package/lrc//350/221/243/345/260/217/345/247/220.lrc +38 -38
- package/lrc//350/231/236/345/205/256/345/217/271.lrc +33 -33
- package/lrc//350/264/253/351/201/223.lrc +68 -68
- package/lrc//350/270/217/345/261/261/346/262/263.lrc +42 -42
- package/lrc//350/277/231/345/260/261/346/230/257/347/210/261.lrc +48 -48
- package/lrc//351/202/243/345/271/264/345/271/264/345/260/221.lrc +55 -55
- package/lrc//351/270/263/351/270/257/345/200/272.lrc +36 -36
- package/package.json +23 -23
package/js/utils.js
CHANGED
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
const btf = {
|
|
2
|
-
debounce: function (func, wait, immediate) {
|
|
3
|
-
let timeout
|
|
4
|
-
return function () {
|
|
5
|
-
const context = this
|
|
6
|
-
const args = arguments
|
|
7
|
-
const later = function () {
|
|
8
|
-
timeout = null
|
|
9
|
-
if (!immediate) func.apply(context, args)
|
|
10
|
-
}
|
|
11
|
-
const callNow = immediate && !timeout
|
|
12
|
-
clearTimeout(timeout)
|
|
13
|
-
timeout = setTimeout(later, wait)
|
|
14
|
-
if (callNow) func.apply(context, args)
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
throttle: function (func, wait, options) {
|
|
19
|
-
let timeout, context, args
|
|
20
|
-
let previous = 0
|
|
21
|
-
if (!options) options = {}
|
|
22
|
-
|
|
23
|
-
const later = function () {
|
|
24
|
-
previous = options.leading === false ? 0 : new Date().getTime()
|
|
25
|
-
timeout = null
|
|
26
|
-
func.apply(context, args)
|
|
27
|
-
if (!timeout) context = args = null
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const throttled = function () {
|
|
31
|
-
const now = new Date().getTime()
|
|
32
|
-
if (!previous && options.leading === false) previous = now
|
|
33
|
-
const remaining = wait - (now - previous)
|
|
34
|
-
context = this
|
|
35
|
-
args = arguments
|
|
36
|
-
if (remaining <= 0 || remaining > wait) {
|
|
37
|
-
if (timeout) {
|
|
38
|
-
clearTimeout(timeout)
|
|
39
|
-
timeout = null
|
|
40
|
-
}
|
|
41
|
-
previous = now
|
|
42
|
-
func.apply(context, args)
|
|
43
|
-
if (!timeout) context = args = null
|
|
44
|
-
} else if (!timeout && options.trailing !== false) {
|
|
45
|
-
timeout = setTimeout(later, remaining)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return throttled
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
sidebarPaddingR: () => {
|
|
53
|
-
const innerWidth = window.innerWidth
|
|
54
|
-
const clientWidth = document.body.clientWidth
|
|
55
|
-
const paddingRight = innerWidth - clientWidth
|
|
56
|
-
if (innerWidth !== clientWidth) {
|
|
57
|
-
document.body.style.paddingRight = paddingRight + 'px'
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
snackbarShow: (text, showAction = false, duration = 2000) => {
|
|
62
|
-
const { position, bgLight, bgDark } = GLOBAL_CONFIG.Snackbar
|
|
63
|
-
const bg = document.documentElement.getAttribute('data-theme') === 'light' ? bgLight : bgDark
|
|
64
|
-
Snackbar.show({
|
|
65
|
-
text: text,
|
|
66
|
-
backgroundColor: bg,
|
|
67
|
-
showAction: showAction,
|
|
68
|
-
duration: duration,
|
|
69
|
-
pos: position,
|
|
70
|
-
customClass: 'snackbar-css'
|
|
71
|
-
})
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
diffDate: (d, more = false) => {
|
|
75
|
-
const dateNow = new Date()
|
|
76
|
-
const datePost = new Date(d)
|
|
77
|
-
const dateDiff = dateNow.getTime() - datePost.getTime()
|
|
78
|
-
const minute = 1000 * 60
|
|
79
|
-
const hour = minute * 60
|
|
80
|
-
const day = hour * 24
|
|
81
|
-
const month = day * 30
|
|
82
|
-
|
|
83
|
-
let result
|
|
84
|
-
if (more) {
|
|
85
|
-
const monthCount = dateDiff / month
|
|
86
|
-
const dayCount = dateDiff / day
|
|
87
|
-
const hourCount = dateDiff / hour
|
|
88
|
-
const minuteCount = dateDiff / minute
|
|
89
|
-
|
|
90
|
-
if (monthCount > 12) {
|
|
91
|
-
result = datePost.toLocaleDateString().replace(/\//g, '-')
|
|
92
|
-
} else if (monthCount >= 1) {
|
|
93
|
-
result = parseInt(monthCount) + ' ' + GLOBAL_CONFIG.date_suffix.month
|
|
94
|
-
} else if (dayCount >= 1) {
|
|
95
|
-
result = parseInt(dayCount) + ' ' + GLOBAL_CONFIG.date_suffix.day
|
|
96
|
-
} else if (hourCount >= 1) {
|
|
97
|
-
result = parseInt(hourCount) + ' ' + GLOBAL_CONFIG.date_suffix.hour
|
|
98
|
-
} else if (minuteCount >= 1) {
|
|
99
|
-
result = parseInt(minuteCount) + ' ' + GLOBAL_CONFIG.date_suffix.min
|
|
100
|
-
} else {
|
|
101
|
-
result = GLOBAL_CONFIG.date_suffix.just
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
result = parseInt(dateDiff / day)
|
|
105
|
-
}
|
|
106
|
-
return result
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
loadComment: (dom, callback) => {
|
|
110
|
-
if ('IntersectionObserver' in window) {
|
|
111
|
-
const observerItem = new IntersectionObserver((entries) => {
|
|
112
|
-
if (entries[0].isIntersecting) {
|
|
113
|
-
callback()
|
|
114
|
-
observerItem.disconnect()
|
|
115
|
-
}
|
|
116
|
-
}, { threshold: [0] })
|
|
117
|
-
observerItem.observe(dom)
|
|
118
|
-
} else {
|
|
119
|
-
callback()
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
scrollToDest: (pos, time = 500) => {
|
|
124
|
-
const currentPos = Math.floor(window.pageYOffset)
|
|
125
|
-
if (currentPos > pos) pos = pos - 70
|
|
126
|
-
|
|
127
|
-
if ('scrollBehavior' in document.documentElement.style) {
|
|
128
|
-
window.scrollTo({
|
|
129
|
-
top: pos,
|
|
130
|
-
behavior: 'smooth'
|
|
131
|
-
})
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
let start = null
|
|
136
|
-
pos = +pos
|
|
137
|
-
window.requestAnimationFrame(function step (currentTime) {
|
|
138
|
-
start = !start ? currentTime : start
|
|
139
|
-
const progress = currentTime - start
|
|
140
|
-
if (currentPos < pos) {
|
|
141
|
-
window.scrollTo(0, ((pos - currentPos) * progress / time) + currentPos)
|
|
142
|
-
} else {
|
|
143
|
-
window.scrollTo(0, currentPos - ((currentPos - pos) * progress / time))
|
|
144
|
-
}
|
|
145
|
-
if (progress < time) {
|
|
146
|
-
window.requestAnimationFrame(step)
|
|
147
|
-
} else {
|
|
148
|
-
window.scrollTo(0, pos)
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
animateIn: (ele, text) => {
|
|
154
|
-
ele.style.display = 'block'
|
|
155
|
-
ele.style.animation = text
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
animateOut: (ele, text) => {
|
|
159
|
-
ele.addEventListener('animationend', function f () {
|
|
160
|
-
ele.style.display = ''
|
|
161
|
-
ele.style.animation = ''
|
|
162
|
-
ele.removeEventListener('animationend', f)
|
|
163
|
-
})
|
|
164
|
-
ele.style.animation = text
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
getParents: (elem, selector) => {
|
|
168
|
-
for (; elem && elem !== document; elem = elem.parentNode) {
|
|
169
|
-
if (elem.matches(selector)) return elem
|
|
170
|
-
}
|
|
171
|
-
return null
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
siblings: (ele, selector) => {
|
|
175
|
-
return [...ele.parentNode.children].filter((child) => {
|
|
176
|
-
if (selector) {
|
|
177
|
-
return child !== ele && child.matches(selector)
|
|
178
|
-
}
|
|
179
|
-
return child !== ele
|
|
180
|
-
})
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @param {*} selector
|
|
185
|
-
* @param {*} eleType the type of create element
|
|
186
|
-
* @param {*} options object key: value
|
|
187
|
-
*/
|
|
188
|
-
wrap: (selector, eleType, options) => {
|
|
189
|
-
const creatEle = document.createElement(eleType)
|
|
190
|
-
for (const [key, value] of Object.entries(options)) {
|
|
191
|
-
creatEle.setAttribute(key, value)
|
|
192
|
-
}
|
|
193
|
-
selector.parentNode.insertBefore(creatEle, selector)
|
|
194
|
-
creatEle.appendChild(selector)
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
unwrap: el => {
|
|
198
|
-
const elParentNode = el.parentNode
|
|
199
|
-
if (elParentNode !== document.body) {
|
|
200
|
-
elParentNode.parentNode.insertBefore(el, elParentNode)
|
|
201
|
-
elParentNode.parentNode.removeChild(elParentNode)
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
isHidden: ele => ele.offsetHeight === 0 && ele.offsetWidth === 0,
|
|
206
|
-
|
|
207
|
-
getEleTop: ele => {
|
|
208
|
-
let actualTop = ele.offsetTop
|
|
209
|
-
let current = ele.offsetParent
|
|
210
|
-
|
|
211
|
-
while (current !== null) {
|
|
212
|
-
actualTop += current.offsetTop
|
|
213
|
-
current = current.offsetParent
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return actualTop
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
loadLightbox: ele => {
|
|
220
|
-
const service = GLOBAL_CONFIG.lightbox
|
|
221
|
-
|
|
222
|
-
if (service === 'mediumZoom') {
|
|
223
|
-
const zoom = mediumZoom(ele)
|
|
224
|
-
zoom.on('open', e => {
|
|
225
|
-
const photoBg = document.documentElement.getAttribute('data-theme') === 'dark' ? '#121212' : '#fff'
|
|
226
|
-
zoom.update({
|
|
227
|
-
background: photoBg
|
|
228
|
-
})
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (service === 'fancybox') {
|
|
233
|
-
ele.forEach(i => {
|
|
234
|
-
if (i.parentNode.tagName !== 'A') {
|
|
235
|
-
const dataSrc = i.dataset.lazySrc || i.src
|
|
236
|
-
const dataCaption = i.title || i.alt || ''
|
|
237
|
-
btf.wrap(i, 'a', { href: dataSrc, 'data-fancybox': 'gallery', 'data-caption': dataCaption, 'data-thumb': dataSrc })
|
|
238
|
-
}
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
if (!window.fancyboxRun) {
|
|
242
|
-
Fancybox.bind('[data-fancybox]', {
|
|
243
|
-
Hash: false,
|
|
244
|
-
Thumbs: {
|
|
245
|
-
autoStart: false
|
|
246
|
-
}
|
|
247
|
-
})
|
|
248
|
-
window.fancyboxRun = true
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
initJustifiedGallery: function (selector) {
|
|
254
|
-
selector.forEach(function (i) {
|
|
255
|
-
if (!btf.isHidden(i)) {
|
|
256
|
-
fjGallery(i, {
|
|
257
|
-
itemSelector: '.fj-gallery-item',
|
|
258
|
-
rowHeight: 220,
|
|
259
|
-
gutter: 4,
|
|
260
|
-
onJustify: function () {
|
|
261
|
-
this.$container.style.opacity = '1'
|
|
262
|
-
}
|
|
263
|
-
})
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
updateAnchor: (anchor) => {
|
|
269
|
-
if (anchor !== window.location.hash) {
|
|
270
|
-
if (!anchor) anchor = location.pathname
|
|
271
|
-
const title = GLOBAL_CONFIG_SITE.title
|
|
272
|
-
window.history.replaceState({
|
|
273
|
-
url: location.href,
|
|
274
|
-
title: title
|
|
275
|
-
}, title, anchor)
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
1
|
+
const btf = {
|
|
2
|
+
debounce: function (func, wait, immediate) {
|
|
3
|
+
let timeout
|
|
4
|
+
return function () {
|
|
5
|
+
const context = this
|
|
6
|
+
const args = arguments
|
|
7
|
+
const later = function () {
|
|
8
|
+
timeout = null
|
|
9
|
+
if (!immediate) func.apply(context, args)
|
|
10
|
+
}
|
|
11
|
+
const callNow = immediate && !timeout
|
|
12
|
+
clearTimeout(timeout)
|
|
13
|
+
timeout = setTimeout(later, wait)
|
|
14
|
+
if (callNow) func.apply(context, args)
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
throttle: function (func, wait, options) {
|
|
19
|
+
let timeout, context, args
|
|
20
|
+
let previous = 0
|
|
21
|
+
if (!options) options = {}
|
|
22
|
+
|
|
23
|
+
const later = function () {
|
|
24
|
+
previous = options.leading === false ? 0 : new Date().getTime()
|
|
25
|
+
timeout = null
|
|
26
|
+
func.apply(context, args)
|
|
27
|
+
if (!timeout) context = args = null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const throttled = function () {
|
|
31
|
+
const now = new Date().getTime()
|
|
32
|
+
if (!previous && options.leading === false) previous = now
|
|
33
|
+
const remaining = wait - (now - previous)
|
|
34
|
+
context = this
|
|
35
|
+
args = arguments
|
|
36
|
+
if (remaining <= 0 || remaining > wait) {
|
|
37
|
+
if (timeout) {
|
|
38
|
+
clearTimeout(timeout)
|
|
39
|
+
timeout = null
|
|
40
|
+
}
|
|
41
|
+
previous = now
|
|
42
|
+
func.apply(context, args)
|
|
43
|
+
if (!timeout) context = args = null
|
|
44
|
+
} else if (!timeout && options.trailing !== false) {
|
|
45
|
+
timeout = setTimeout(later, remaining)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return throttled
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
sidebarPaddingR: () => {
|
|
53
|
+
const innerWidth = window.innerWidth
|
|
54
|
+
const clientWidth = document.body.clientWidth
|
|
55
|
+
const paddingRight = innerWidth - clientWidth
|
|
56
|
+
if (innerWidth !== clientWidth) {
|
|
57
|
+
document.body.style.paddingRight = paddingRight + 'px'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
snackbarShow: (text, showAction = false, duration = 2000) => {
|
|
62
|
+
const { position, bgLight, bgDark } = GLOBAL_CONFIG.Snackbar
|
|
63
|
+
const bg = document.documentElement.getAttribute('data-theme') === 'light' ? bgLight : bgDark
|
|
64
|
+
Snackbar.show({
|
|
65
|
+
text: text,
|
|
66
|
+
backgroundColor: bg,
|
|
67
|
+
showAction: showAction,
|
|
68
|
+
duration: duration,
|
|
69
|
+
pos: position,
|
|
70
|
+
customClass: 'snackbar-css'
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
diffDate: (d, more = false) => {
|
|
75
|
+
const dateNow = new Date()
|
|
76
|
+
const datePost = new Date(d)
|
|
77
|
+
const dateDiff = dateNow.getTime() - datePost.getTime()
|
|
78
|
+
const minute = 1000 * 60
|
|
79
|
+
const hour = minute * 60
|
|
80
|
+
const day = hour * 24
|
|
81
|
+
const month = day * 30
|
|
82
|
+
|
|
83
|
+
let result
|
|
84
|
+
if (more) {
|
|
85
|
+
const monthCount = dateDiff / month
|
|
86
|
+
const dayCount = dateDiff / day
|
|
87
|
+
const hourCount = dateDiff / hour
|
|
88
|
+
const minuteCount = dateDiff / minute
|
|
89
|
+
|
|
90
|
+
if (monthCount > 12) {
|
|
91
|
+
result = datePost.toLocaleDateString().replace(/\//g, '-')
|
|
92
|
+
} else if (monthCount >= 1) {
|
|
93
|
+
result = parseInt(monthCount) + ' ' + GLOBAL_CONFIG.date_suffix.month
|
|
94
|
+
} else if (dayCount >= 1) {
|
|
95
|
+
result = parseInt(dayCount) + ' ' + GLOBAL_CONFIG.date_suffix.day
|
|
96
|
+
} else if (hourCount >= 1) {
|
|
97
|
+
result = parseInt(hourCount) + ' ' + GLOBAL_CONFIG.date_suffix.hour
|
|
98
|
+
} else if (minuteCount >= 1) {
|
|
99
|
+
result = parseInt(minuteCount) + ' ' + GLOBAL_CONFIG.date_suffix.min
|
|
100
|
+
} else {
|
|
101
|
+
result = GLOBAL_CONFIG.date_suffix.just
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
result = parseInt(dateDiff / day)
|
|
105
|
+
}
|
|
106
|
+
return result
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
loadComment: (dom, callback) => {
|
|
110
|
+
if ('IntersectionObserver' in window) {
|
|
111
|
+
const observerItem = new IntersectionObserver((entries) => {
|
|
112
|
+
if (entries[0].isIntersecting) {
|
|
113
|
+
callback()
|
|
114
|
+
observerItem.disconnect()
|
|
115
|
+
}
|
|
116
|
+
}, { threshold: [0] })
|
|
117
|
+
observerItem.observe(dom)
|
|
118
|
+
} else {
|
|
119
|
+
callback()
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
scrollToDest: (pos, time = 500) => {
|
|
124
|
+
const currentPos = Math.floor(window.pageYOffset)
|
|
125
|
+
if (currentPos > pos) pos = pos - 70
|
|
126
|
+
|
|
127
|
+
if ('scrollBehavior' in document.documentElement.style) {
|
|
128
|
+
window.scrollTo({
|
|
129
|
+
top: pos,
|
|
130
|
+
behavior: 'smooth'
|
|
131
|
+
})
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let start = null
|
|
136
|
+
pos = +pos
|
|
137
|
+
window.requestAnimationFrame(function step (currentTime) {
|
|
138
|
+
start = !start ? currentTime : start
|
|
139
|
+
const progress = currentTime - start
|
|
140
|
+
if (currentPos < pos) {
|
|
141
|
+
window.scrollTo(0, ((pos - currentPos) * progress / time) + currentPos)
|
|
142
|
+
} else {
|
|
143
|
+
window.scrollTo(0, currentPos - ((currentPos - pos) * progress / time))
|
|
144
|
+
}
|
|
145
|
+
if (progress < time) {
|
|
146
|
+
window.requestAnimationFrame(step)
|
|
147
|
+
} else {
|
|
148
|
+
window.scrollTo(0, pos)
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
animateIn: (ele, text) => {
|
|
154
|
+
ele.style.display = 'block'
|
|
155
|
+
ele.style.animation = text
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
animateOut: (ele, text) => {
|
|
159
|
+
ele.addEventListener('animationend', function f () {
|
|
160
|
+
ele.style.display = ''
|
|
161
|
+
ele.style.animation = ''
|
|
162
|
+
ele.removeEventListener('animationend', f)
|
|
163
|
+
})
|
|
164
|
+
ele.style.animation = text
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
getParents: (elem, selector) => {
|
|
168
|
+
for (; elem && elem !== document; elem = elem.parentNode) {
|
|
169
|
+
if (elem.matches(selector)) return elem
|
|
170
|
+
}
|
|
171
|
+
return null
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
siblings: (ele, selector) => {
|
|
175
|
+
return [...ele.parentNode.children].filter((child) => {
|
|
176
|
+
if (selector) {
|
|
177
|
+
return child !== ele && child.matches(selector)
|
|
178
|
+
}
|
|
179
|
+
return child !== ele
|
|
180
|
+
})
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @param {*} selector
|
|
185
|
+
* @param {*} eleType the type of create element
|
|
186
|
+
* @param {*} options object key: value
|
|
187
|
+
*/
|
|
188
|
+
wrap: (selector, eleType, options) => {
|
|
189
|
+
const creatEle = document.createElement(eleType)
|
|
190
|
+
for (const [key, value] of Object.entries(options)) {
|
|
191
|
+
creatEle.setAttribute(key, value)
|
|
192
|
+
}
|
|
193
|
+
selector.parentNode.insertBefore(creatEle, selector)
|
|
194
|
+
creatEle.appendChild(selector)
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
unwrap: el => {
|
|
198
|
+
const elParentNode = el.parentNode
|
|
199
|
+
if (elParentNode !== document.body) {
|
|
200
|
+
elParentNode.parentNode.insertBefore(el, elParentNode)
|
|
201
|
+
elParentNode.parentNode.removeChild(elParentNode)
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
isHidden: ele => ele.offsetHeight === 0 && ele.offsetWidth === 0,
|
|
206
|
+
|
|
207
|
+
getEleTop: ele => {
|
|
208
|
+
let actualTop = ele.offsetTop
|
|
209
|
+
let current = ele.offsetParent
|
|
210
|
+
|
|
211
|
+
while (current !== null) {
|
|
212
|
+
actualTop += current.offsetTop
|
|
213
|
+
current = current.offsetParent
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return actualTop
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
loadLightbox: ele => {
|
|
220
|
+
const service = GLOBAL_CONFIG.lightbox
|
|
221
|
+
|
|
222
|
+
if (service === 'mediumZoom') {
|
|
223
|
+
const zoom = mediumZoom(ele)
|
|
224
|
+
zoom.on('open', e => {
|
|
225
|
+
const photoBg = document.documentElement.getAttribute('data-theme') === 'dark' ? '#121212' : '#fff'
|
|
226
|
+
zoom.update({
|
|
227
|
+
background: photoBg
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (service === 'fancybox') {
|
|
233
|
+
ele.forEach(i => {
|
|
234
|
+
if (i.parentNode.tagName !== 'A') {
|
|
235
|
+
const dataSrc = i.dataset.lazySrc || i.src
|
|
236
|
+
const dataCaption = i.title || i.alt || ''
|
|
237
|
+
btf.wrap(i, 'a', { href: dataSrc, 'data-fancybox': 'gallery', 'data-caption': dataCaption, 'data-thumb': dataSrc })
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
if (!window.fancyboxRun) {
|
|
242
|
+
Fancybox.bind('[data-fancybox]', {
|
|
243
|
+
Hash: false,
|
|
244
|
+
Thumbs: {
|
|
245
|
+
autoStart: false
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
window.fancyboxRun = true
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
initJustifiedGallery: function (selector) {
|
|
254
|
+
selector.forEach(function (i) {
|
|
255
|
+
if (!btf.isHidden(i)) {
|
|
256
|
+
fjGallery(i, {
|
|
257
|
+
itemSelector: '.fj-gallery-item',
|
|
258
|
+
rowHeight: 220,
|
|
259
|
+
gutter: 4,
|
|
260
|
+
onJustify: function () {
|
|
261
|
+
this.$container.style.opacity = '1'
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
updateAnchor: (anchor) => {
|
|
269
|
+
if (anchor !== window.location.hash) {
|
|
270
|
+
if (!anchor) anchor = location.pathname
|
|
271
|
+
const title = GLOBAL_CONFIG_SITE.title
|
|
272
|
+
window.history.replaceState({
|
|
273
|
+
url: location.href,
|
|
274
|
+
title: title
|
|
275
|
+
}, title, anchor)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|