PageSourceSearch

https://mxdm999.com/usr/themes/Joe-master/assets/js/joe.post_page.js?version=1.3294

js mxdm999.com collected 2026-10-06 13:15:04 UTC 11,666 bytes, 364 lines download raw bytes

1document.addEventListener('DOMContentLoaded', () => {
2	const encryption = str => window.btoa(unescape(encodeURIComponent(str)));
3	const decrypt = str => decodeURIComponent(escape(window.atob(str)));
4
5	/* 当前页的CID */
6	const cid = $('.joe_detail').attr('data-cid');
7	window.cid = cid;
8
9	/* 获取本篇文章百度收录情况 */
10	{
11		if (document.getElementById('Joe_Baidu_Record')) {
12			$.ajax({
13				url: Joe.BASE_API,
14				type: 'POST',
15				dataType: 'json',
16				data: {
17					routeType: 'baidu_record',
18					site: window.location.href,
19					cid: cid
20				},
21				success(res) {
22					if (!res.data) {
23						if (Joe.BAIDU_PUSH) {
24							$('#Joe_Baidu_Record').html(`<a href="javascript:submit_baidu();" rel="noopener noreferrer nofollow" style="color: #F56C6C">检测失败,提交收录</a>`);
25							return
26						}
27						const url = `https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;
28						$('#Joe_Baidu_Record').html(`<a target="_blank" href="${url}" rel="noopener noreferrer nofollow" style="color: #F56C6C">检测失败,提交收录</a>`);
29						return
30					}
31					if (res.data == '未收录,已推送') {
32						$('#Joe_Baidu_Record').css('color', '#67C23A');
33						$('#Joe_Baidu_Record').html(res.data);
34						return
35					}
36					if (res.data == '已收录') {
37						$('#Joe_Baidu_Record').css('color', '#67C23A');
38						$('#Joe_Baidu_Record').html('已收录');
39						return
40					}
41					/* 如果填写了Token,则自动推送给百度 */
42					if ((res.data == '未收录') && (Joe.BAIDU_PUSH)) {
43						submit_baidu('未收录,推送中...');
44						return
45					}
46					if (Joe.BAIDU_PUSH) {
47						$('#Joe_Baidu_Record').html(`<a href="javascript:submit_baidu();" rel="noopener noreferrer nofollow" style="color: #F56C6C">${res.data},提交收录</a>`);
48						return
49					}
50					const url = `https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;
51					$('#Joe_Baidu_Record').html(`<a target="_blank" href="${url}" rel="noopener noreferrer nofollow" style="color: #F56C6C">${res.data},提交收录</a>`);
52				}
53			});
54		}
55
56	}
57
58	/* 激活代码高亮 */
59	{
60		Prism.highlightAll();
61		$("pre[class*='language-']").each(function (index, item) {
62			let text = $(item).find("code[class*='language-']").text().replace(/    /g, '	');
63			let span = $(`<span data-toggle="tooltip" data-placement="top" title="点击复制" class="copy"><i class="fa fa-clone"></i></span>`);
64			if (!Joe.IS_MOBILE) {
65				span.tooltip({
66					container: "body"
67				});
68				span.on('click', function (event) {
69					$(this).tooltip('hide');
70				});
71			}
72			new ClipboardJS(span[0], {
73				text: () => text
74			}).on('success', () => {
75				window.code_copy = true;
76				Qmsg.success(`复制成功 内容版权属于 ${Joe.TITLE} 转载请标明出处!`, { 'showClose': true, 'autoClose': false });
77			});
78			$(item).append(span);
79		});
80	}
81
82	/* 监听网页复制行为 */
83	{
84		// 获取所有具有类名 "joe_detail__article" 的元素
85		const articleElements = document.querySelectorAll('.joe_detail__article');
86		// 遍历每个元素,添加复制事件监听
87		articleElements.forEach(article => {
88			article.addEventListener('copy', (event) => {
89				// 获取被复制的元素
90				// const copiedElement = event.target;
91				if (window.code_copy !== true && window.post_copy !== true) {
92					Qmsg.warning(`本文版权属于 ${Joe.TITLE} 转载请标明出处!`, {
93						'showClose': true,
94						'autoClose': false
95					});
96					window.post_copy = true;
97				}
98				window.code_copy = false;
99			});
100		});
101	}
102
103	/* 激活图片预览功能 */
104	{
105		$('.joe_detail__article img:not(img.owo_image)[fancybox!="false"]').each(function () {
106			$(this).wrap($(
107				`<span style="display: block;" data-fancybox="Joe" href="${$(this).attr('src')}"></span>`
108			));
109		});
110	}
111
112	/* 激活浏览功能 */
113	{
114		let viewsArr = localStorage.getItem(encryption('views')) ? JSON.parse(decrypt(localStorage.getItem(
115			encryption('views')))) : [];
116		const flag = viewsArr.includes(cid);
117		if (!flag) {
118			$.ajax({
119				url: Joe.BASE_API,
120				type: 'POST',
121				dataType: 'json',
122				data: {
123					routeType: 'handle_views',
124					cid
125				},
126				success(res) {
127					if (res.code !== 1) return;
128					$('#Joe_Article_Views').html(res.data.views);
129					viewsArr.push(cid);
130					const name = encryption('views');
131					const val = encryption(JSON.stringify(viewsArr));
132					localStorage.setItem(name, val);
133				}
134			});
135		}
136	}
137
138	/* 激活文章点赞功能 */
139	{
140		let agreeArr = localStorage.getItem(encryption('agree')) ? JSON.parse(decrypt(localStorage.getItem(
141			encryption('agree')))) : [];
142		if (agreeArr.includes(cid)) {
143			$('.action-like').addClass('active');
144			$('.action-like>text').text('已赞');
145		} else {
146			$('.action-like').removeClass('active');
147			$('.action-like>text').text('点赞');
148		}
149		let _loading = false;
150		$('.action-like').on('click', function () {
151			if (_loading) return;
152			_loading = true;
153			agreeArr = localStorage.getItem(encryption('agree')) ? JSON.parse(decrypt(localStorage
154				.getItem(encryption('agree')))) : [];
155			let flag = agreeArr.includes(cid);
156			$.ajax({
157				url: Joe.BASE_API,
158				type: 'POST',
159				dataType: 'json',
160				data: {
161					routeType: 'handle_agree',
162					cid,
163					type: flag ? 'disagree' : 'agree'
164				},
165				beforeSend: function () {
166					$('.action-like').css('pointer-events', 'none').find('count').html('<i class="loading zts"></i>');
167				},
168				success(res) {
169					if (res.code !== 1) return;
170					$('.action-like>count').html(res.data.agree);
171					if (flag) {
172						const index = agreeArr.findIndex(_ => _ === cid);
173						agreeArr.splice(index, 1);
174						$('.action-like').removeClass('active');
175						$('.action-like>text').text('点赞');
176						Qmsg.info('点赞已取消');
177					} else {
178						agreeArr.push(cid);
179						$('.action-like').addClass('active');
180						$('.action-like>text').text('已赞');
181						Qmsg.success('已赞,感谢您的支持!');
182					}
183					const name = encryption('agree');
184					const val = encryption(JSON.stringify(agreeArr));
185					localStorage.setItem(name, val);
186					$('.action-like').css('pointer-events', '')
187				},
188				complete() {
189					_loading = false;
190				}
191			});
192		});
193	}
194
195	/* 密码保护文章,输入密码访问 */
196	{
197		let isSubmit = false;
198		$('.joe_detail__article-protected').on('submit', function (e) {
199			e.preventDefault();
200			const url = $(this).attr('action') + '&time=' + +new Date();
201			const protectPassword = $(this).find('input[type="password"]').val();
202			if (protectPassword.trim() === '') return Qmsg.info('请输入访问密码!');
203			if (isSubmit) return;
204			isSubmit = true;
205			$.ajax({
206				url,
207				type: 'POST',
208				data: {
209					cid,
210					protectCID: cid,
211					protectPassword
212				},
213				dataType: 'text',
214				success(res) {
215					let arr = [],
216						str = '';
217					arr = $(res).contents();
218					Array.from(arr).forEach(_ => {
219						if (_.parentNode.className === 'container') str = _;
220					});
221					if (!/Joe/.test(res)) {
222						Qmsg.warning(str.textContent.trim() || '');
223						isSubmit = false;
224						$('.joe_comment__respond-form .foot .submit button').html('发表评论');
225					} else {
226						location.reload();
227					}
228				}
229			});
230		});
231	}
232
233	/* 激活文章视频模块 */
234	{
235		if ($('.joe_detail__article-video').length > 0) {
236			window.videoPlayer = new DPlayer({
237				container: document.querySelector('.joe_detail__article-video>.dplayer-video'), // 播放器容器元素
238				autoplay: true, // 视频自动播放
239				theme: getComputedStyle(document.documentElement).getPropertyValue('--theme').trim(), // 主题色
240				lang: 'zh-cn', // 可选值: 'en', 'zh-cn', 'zh-tw'
241				preload: 'auto', // 视频预加载,可选值: 'none', 'metadata', 'auto'
242				loop: false, // 视频循环播放
243				screenshot: true, // 开启截图,如果开启,视频和视频封面需要允许跨域
244				airplay: true, // 在 Safari 中开启 AirPlay
245				volume: 1, // 默认音量,请注意播放器会记忆用户设置,用户手动设置音量后默认音量即失效
246				playbackSpeed: [2.00, 1.75, 1.50, 1.25, 1.00, 0.75, 0.50, 0.25], // 可选的播放速率,可以设置成自定义的数组
247				video: {
248					pic: Joe.CONTENT.cover
249				}
250			});
251			$('.featured-video-episode>.switch-video').on('click', function () {
252				$(this).addClass('active').siblings().removeClass('active');
253				const url = $(this).attr('video-url');
254				let title = $(this).attr('data-original-title');
255				videoPlayer.switchVideo({ url: url });
256				if (title) $('.joe_detail__article-video>.title').html(title);
257			});
258			$('.featured-video-episode>.switch-video').first().click();
259			const next = () => {
260				let item = document.querySelector('.featured-video-episode>.switch-video.active');
261				if (item.nextSibling) item.nextSibling.nextElementSibling.click();
262			}
263			videoPlayer.on('ended', () => {
264				next();
265			});
266			videoPlayer.on('loadeddata', () => {
267				if (videoPlayer.video.paused) {
268					videoPlayer.play();
269				}
270				if (videoPlayer.video.paused) {
271					console.log(videoPlayer.video.paused);
272					videoPlayer.video.play();
273				}
274			});
275			videoPlayer.on('error', () => {
276				if (!videoPlayer.video.error) {
277					// 不是视频加载错误,可能是海报加载失败,请参阅 #307
278					return;
279				}
280				console.log('视频加载失败:' + videoPlayer.video.src);
281				next();
282			});
283		}
284	}
285
286	/* 分享 */
287	{
288		// if ($('.joe_detail__operate-share').length) {
289		// 	$('.joe_detail__operate-share > svg').on('click', e => {
290		// 		e.stopPropagation();
291		// 		$('.joe_detail__operate-share').toggleClass('active');
292		// 	});
293		// 	$(document).on('click', () => $('.joe_detail__operate-share').removeClass('active'));
294		// }
295	}
296});
297
298/* 写在load事件里,为了解决图片未加载完成,滚动距离获取会不准确的问题 */
299window.addEventListener('load', function () {
300	/* 判断地址栏是否有锚点链接,有则跳转到对应位置 */
301	{
302		const scroll = new URLSearchParams(location.search).get('scroll');
303		if (scroll) {
304			let elementEL = null;
305			if ($('#' + scroll).length > 0) {
306				elementEL = $('#' + scroll);
307			} else {
308				elementEL = $('.' + scroll);
309			}
310			if (elementEL && elementEL.length > 0) {
311				const top = elementEL.offset().top - $('.joe_header').height() - 15;
312				window.scrollTo({
313					top,
314					behavior: 'smooth'
315				});
316			}
317		}
318	}
319});
320
321function submit_baidu(msg = '推送中...') {
322	$('#Joe_Baidu_Record').html(`<span style="color: #E6A23C">${msg}</span>`);
323	$.ajax({
324		url: Joe.BASE_API,
325		type: 'POST',
326		dataType: 'json',
327		data: {
328			routeType: 'baidu_push',
329			domain: window.location.protocol + '//' + window
330				.location.hostname,
331			url: encodeURI(window.location.href),
332			cid: window.cid
333		},
334		success(res) {
335			if (res.already) {
336				$('#Joe_Baidu_Record').css('color', '#67C23A');
337				$('#Joe_Baidu_Record').html('已推送');
338				return
339			}
340			if (res.data.error) {
341				if (res.data.message == 'over quota') res.data.message = '超过配额';
342				$('#Joe_Baidu_Record').html('<span style="color: #F56C6C">推送失败,' + res.data.message + '</span>');
343			} else {
344				$('#Joe_Baidu_Record').html('<span style="color: #67C23A">推送成功!今日剩余' + res.data.remain + '条</span>');
345			}
346		},
347		error(res) {
348			$('#Joe_Baidu_Record').html('<span style="color: #F56C6C">推送失败,请检查!</span>');
349		}
350	});
351	// 	顺便推送URL到必应
352	if (!Joe.BING_PUSH) return;
353	$.ajax({
354		url: Joe.BASE_API,
355		type: 'POST',
356		dataType: 'json',
357		data: {
358			routeType: 'bing_push',
359			domain: window.location.protocol + '//' + window
360				.location.hostname,
361			url: encodeURI(window.location.href)
362		}
363	});
364}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.