PageSourceSearch

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

js mxdm999.com collected 2026-10-06 13:14:57 UTC 9,380 bytes, 291 lines download raw bytes

1window.Joe.scrollTo = (selector) => {
2	const $comment = document.querySelector(selector);
3	const $header = document.querySelector('.joe_header');
4	if (!$comment || !$header) return;
5	const top = $comment.offsetTop - $header.offsetHeight - 15;
6	window.scrollTo({ top, behavior: 'smooth' });
7}
8
9function loadJS(url, callback = function () { }) {
10	window.loadJSList = window.loadJSList ? window.loadJSList : {};
11	if (!loadJSList[url]) {
12		var script = document.createElement('script');
13		script.type = 'text/javascript';
14		script.addEventListener('load', callback);
15		script.src = url;
16		document.getElementsByTagName('head')[0].appendChild(script);
17		loadJSList[url] = script;
18	} else {
19		var script = loadJSList[url];
20		script.addEventListener('load', callback);
21	}
22	// 检查元素是否存在,如果存在,则删除,浏览器不会重复载入
23	// const existingScript = document.querySelector(`script[src="${url}"]`);
24	// if (existingScript) existingScript.remove();
25}
26
27/**
28 * 防抖函数
29 * @param {*} fn 
30 * @param {*} delay 
31 * @returns 
32 */
33function throttle(fn, delay = 100) {
34	let valid = true;
35	return function (...args) {
36		if (!valid) {
37			//休息时间 暂不接客
38			return false;
39		}
40		// 工作时间,执行函数并且在间隔期内把状态位设为无效
41		valid = false;
42		setTimeout(function () {
43			fn.apply(this, args);
44			valid = true;
45		}, delay);
46	};
47}
48
49
50/**
51 * @description: 节流函数
52 * @param {*} callback 函数
53 * @param {*} delay 时间
54 * @param {*} immediate  是否立即执行 为true则计时开始就就执行
55 * @return {*}
56 */
57// 定义一个debounce函数,用于函数防抖
58function debounce(callback, delay, immediate) {
59	// 定义一个变量,用于存放定时器
60	var timeout;
61	// 返回一个函数
62	return function () {
63		// 定义一个变量,用于存放this
64		var context = this,
65			// 定义一个变量,用于存放参数
66			args = arguments;
67		// 定义一个函数,用于清除定时器
68		var later = function () {
69			// 将定时器置为null
70			timeout = null;
71			// 如果不是立即执行,则执行回调函数
72			if (!immediate) {
73				callback.apply(context, args);
74			}
75		};
76		// 如果是立即执行,且定时器不存在,则立即执行回调函数
77		var callNow = immediate && !timeout;
78		// 清除定时器
79		clearTimeout(timeout);
80		// 重新设置定时器
81		timeout = setTimeout(later, delay);
82		// 如果是立即执行,则立即执行回调函数
83		if (callNow) {
84			callback.apply(context, args);
85		}
86	};
87}
88
89/**
90 * @description: ajax请求封装
91 * @param {*} _this 按钮的jquery对象
92 * @param {*} data 传递的数据
93 * @param {*} success 成功后的回调函数
94 * @param {*} noty 提示信息
95 * @param {*} no_loading 是否不显示加载动画
96 * @return {*}
97 */
98function zib_ajax(_this, data, success, noty, no_loading) {
99	if (_this.attr('disabled')) {
100		return !1;
101	}
102	if (!data) {
103		var _data = _this.attr('form-data');
104		if (_data) {
105			try {
106				data = $.parseJSON(_data);
107			} catch (e) { }
108		}
109		if (!data) {
110			var form = _this.parents('form');
111			data = form.serializeObject();
112		}
113	}
114
115	var _action = _this.attr('form-action');
116	if (_action) {
117		data.action = _action;
118	}
119
120	//人机验证
121	if (data.captcha_mode && is_captcha(data.captcha_mode)) {
122		tbquire(['captcha'], function () {
123			CaptchaOpen(_this, data.captcha_mode);
124		});
125		return !1;
126	}
127
128	if (window.captcha) {
129		data.captcha = JSON.parse(JSON.stringify(window.captcha));
130		data.captcha._this && delete data.captcha._this;
131		window.captcha = {}; //只能使用一次
132	}
133
134	var _text = _this.html();
135	var _loading = no_loading ? _text : '<i class="loading mr6"></i><text>请稍候</text>';
136	noty != 'stop' && Qmsg.warning(noty || '正在处理请稍后...', 'load', '', 'wp_ajax');
137	_this.attr('disabled', true).html(_loading);
138	var _url = _this.attr('ajax-href') || window.Joe.BASE_API;
139
140	$.ajax({
141		type: 'POST',
142		url: _url,
143		data: data,
144		dataType: 'json',
145		error: function (n) {
146			var _msg = '操作失败 ' + n.status + ' ' + n.statusText + ',请刷新页面后重试';
147			if (n.responseText && n.responseText.indexOf('致命错误') > -1) {
148				_msg = '网站遇到致命错误,请检查插件冲突或通过错误日志排除错误';
149			}
150			console.error('ajax请求错误,错误信息如下:', n);
151			Qmsg.error(_msg, 'danger', '', noty != 'stop' ? 'wp_ajax' : '');
152			_this.attr('disabled', false).html(_text);
153		},
154		success: function (n) {
155			var ys = n.ys ? n.ys : n.error ? 'danger' : '';
156			if (n.error) {
157				// _win.slidercaptcha = false;
158				data.tcaptcha_ticket && (tcaptcha = {});
159			}
160			if (noty != 'stop') {
161				Qmsg.success(n.msg || '处理完成', ys, '', 'wp_ajax');
162			} else if (n.msg) {
163				Qmsg.success(n.msg, ys);
164			}
165
166			_this.attr('disabled', false).html(_text).trigger('zib_ajax.success', n); //完成
167			$.isFunction(success) && success(n, _this, data);
168
169			if (n.hide_modal) {
170				_this.closest('.modal').modal('hide');
171			}
172			if (n.reload) {
173				if (n.goto) {
174					window.location.href = n.goto;
175					window.location.reload;
176				} else {
177					window.location.reload();
178				}
179			}
180		},
181	});
182}
183
184//AJAX执行完成后自动切换到下一个tab
185$('body').on('zib_ajax.success', '[next-tab]', function (e, n) {
186	var _next = $(this).attr('next-tab');
187	if (_next && n && !n.error) {
188		$('a[href="#' + _next + '"]').tab('show');
189	}
190});
191
192// 滑动手势minitouch
193$.fn.minitouch = function (options) {
194	var is_on = 'minitouch-isload';
195	var _e = $(this);
196	if (_e.data(is_on)) {
197		return;
198	}
199
200	options = $.extend(
201		{
202			direction: 'bottom',
203			selector: '',
204			start_selector: '',
205			depreciation: 50,
206			stop: false,
207			onStart: false,
208			onIng: false,
209			onEnd: false,
210			inEnd: false,
211		},
212		options
213	);
214	var is_stop = false;
215	var dep = options.depreciation;
216	var startX = 0;
217	var startY = 0;
218	var endX = 0;
219	var endY = 0;
220	var angle = 0;
221	var distanceX = 0;
222	var distanceY = 0;
223	var dragging = false;
224
225	var cssTransition = function (a, b, c, d, s) {
226		var e, f, g;
227		d && ((b += 'px'), (c += 'px'), (e = 'translate3D(' + b + ',' + c + ' , 0)'), (f = {}), (g = cssT_Support()), (f[g + 'transform'] = e), (f[g + 'transition'] = g + 'transform 0s linear'), (f['cursor'] = s), 'null' == d && ((f[g + 'transform'] = ''), (f[g + 'transition'] = '')), a.css(f));
228	};
229	var cssT_Support = function () {
230		var a = document.body || document.documentElement;
231		a = a.style;
232		return '' == a.WebkitTransition ? '-webkit-' : '' == a.MozTransition ? '-moz-' : '' == a.OTransition ? '-o-' : '' == a.transition ? '' : void 0;
233	};
234
235	var touch_selector = options.start_selector || options.selector;
236	_e.on('touchstart pointerdown MSPointerDown', touch_selector, function (e) {
237		startX = startY = endX = endY = angle = distanceX = distanceY = 0;
238		startX = e.originalEvent.pageX || e.originalEvent.touches[0].pageX;
239		startY = e.originalEvent.pageY || e.originalEvent.touches[0].pageY;
240		dragging = !0;
241		//兼容swiper
242		if ($(e.target).parentsUntil(touch_selector, '.swiper-container,.scroll-x').length) {
243			dragging = !1;
244		}
245	})
246		.on('touchmove pointermove MSPointerMove', touch_selector, function (a) {
247			var _move = options.start_selector ? (options.selector ? _e.find(options.selector) : _e.find(options.start_selector)) : $(this);
248			if ($.isFunction(options.stop)) {
249				is_stop = options.stop(_e, _move, startX, startY);
250			}
251			if (dragging && !is_stop) {
252				endX = a.originalEvent.pageX || a.originalEvent.touches[0].pageX;
253				endY = a.originalEvent.pageY || a.originalEvent.touches[0].pageY;
254				distanceX = endX - startX;
255				distanceY = endY - startY;
256				angle = (180 * Math.atan2(distanceY, distanceX)) / Math.PI;
257				'right' == options.direction && ((distanceY = 0), (distanceX = angle > -40 && angle < 40 && distanceX > 0 ? distanceX : 0));
258				'left' == options.direction && ((distanceY = 0), (distanceX = (angle > 150 || angle < -150) && 0 > distanceX ? distanceX : 0));
259				'top' == options.direction && ((distanceX = 0), (distanceY = angle > -130 && angle < -50 && 0 > distanceY ? distanceY : 0));
260				'bottom' == options.direction && ((distanceX = 0), (distanceY = angle > 50 && angle < 130 && distanceY > 0 ? distanceY : 0));
261				if (distanceX !== 0 || distanceY !== 0) {
262					a.preventDefault ? a.preventDefault() : (a.returnValue = !1);
263					cssTransition(_move, distanceX, distanceY, dragging, 'grab');
264					$.isFunction(options.onIng) && options.onIng(_e, _move, distanceX, distanceY);
265				}
266			}
267		})
268		.on('touchend touchcancel pointerup MSPointerUp', touch_selector, function () {
269			var _move = options.start_selector ? (options.selector ? _e.find(options.selector) : _e.find(options.start_selector)) : $(this);
270			if (dragging && !is_stop) {
271				cssTransition(_move, 0, 0, 'null', '');
272				$.isFunction(options.inEnd) && options.inEnd(_e, _move, distanceX, distanceY);
273				if (Math.abs(distanceX) > dep || Math.abs(distanceY) > dep) {
274					$.isFunction(options.onEnd) && options.onEnd(_e, _move, distanceX, distanceY);
275				}
276				startX = startY = endX = endY = angle = distanceX = distanceY = 0;
277				dragging = !1;
278			}
279		})
280		.data(is_on, true);
281};
282
283$.fn.serializeObject = function () {
284	var t = {}
285		, e = this.serializeArray();
286	return $.each(e, function () {
287		void 0 !== t[this.name] ? (t[this.name].push || (t[this.name] = [t[this.name]]),
288			t[this.name].push(this.value || "")) : t[this.name] = this.value || ""
289	}),
290		t
291}

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.