PageSourceSearch

https://phole.vn/assets/js/functions.js?v=mdtoTDkDSp

js phole.vn collected 2026-10-08 17:41:35 UTC 7,440 bytes, 343 lines download raw bytes

1
2
3function isExist(ele) {
4	return ele.length;
5}
6
7function isNumeric(value) {
8	return /^\d+$/.test(value);
9}
10
11function getLen(str) {
12	return /^\s*$/.test(str) ? 0 : str.length;
13}
14
15function showNotify(text = 'Notify text', title = LANG['thongbao'], status = 'success') {
16	new Notify({
17		status: status, // success, warning, error
18		title: title,
19		text: text,
20		effect: 'fade',
21		speed: 400,
22		customClass: null,
23		customIcon: null,
24		showIcon: true,
25		showCloseButton: true,
26		autoclose: true,
27		autotimeout: 3000,
28		gap: 10,
29		distance: 10,
30		type: 3,
31		position: 'right top'
32	});
33}
34
35function notifyDialog(content = '', title = LANG['thongbao'], icon = 'fas fa-exclamation-triangle', type = 'blue') {
36	$.alert({
37		title: title,
38		icon: icon, // font awesome
39		type: type, // red, green, orange, blue, purple, dark
40		content: content, // html, text
41		backgroundDismiss: true,
42		animationSpeed: 600,
43		animation: 'zoom',
44		closeAnimation: 'scale',
45		typeAnimated: true,
46		animateFromElement: false,
47		autoClose: 'accept|3000',
48		escapeKey: 'accept',
49		buttons: {
50			accept: {
51				text: LANG['dongy'],
52				btnClass: 'btn-sm btn-primary'
53			}
54		}
55	});
56}
57
58function confirmDialog(
59	action,
60	text,
61	value,
62	title = LANG['thongbao'],
63	icon = 'fas fa-exclamation-triangle',
64	type = 'blue'
65) {
66	$.confirm({
67		title: title,
68		icon: icon, // font awesome
69		type: type, // red, green, orange, blue, purple, dark
70		content: text, // html, text
71		backgroundDismiss: true,
72		animationSpeed: 600,
73		animation: 'zoom',
74		closeAnimation: 'scale',
75		typeAnimated: true,
76		animateFromElement: false,
77		autoClose: 'cancel|3000',
78		escapeKey: 'cancel',
79		buttons: {
80			success: {
81				text: LANG['dongy'],
82				btnClass: 'btn-sm btn-primary',
83				action: function () {
84					if (action == 'delete-procart') deleteCart(value);
85				}
86			},
87			cancel: {
88				text: LANG['huy'],
89				btnClass: 'btn-sm btn-danger'
90			}
91		}
92	});
93}
94
95function validateForm(ele = '') {
96	if (ele) {
97		$('.' + ele)
98			.find('input[type=submit]')
99			.removeAttr('disabled');
100		var forms = document.getElementsByClassName(ele);
101		var validation = Array.prototype.filter.call(forms, function (form) {
102			form.addEventListener(
103				'submit',
104				function (event) {
105					if (form.checkValidity() === false) {
106						event.preventDefault();
107						event.stopPropagation();
108					}
109					form.classList.add('was-validated');
110				},
111				false
112			);
113		});
114	}
115}
116
117function readImage(inputFile, elementPhoto) {
118	if (inputFile[0].files[0]) {
119		if (inputFile[0].files[0].name.match(/.(jpg|jpeg|png|gif)$/i)) {
120			var size = parseInt(inputFile[0].files[0].size) / 1024;
121
122			if (size <= 4096) {
123				var reader = new FileReader();
124				reader.onload = function (e) {
125					$(elementPhoto).attr('src', e.target.result);
126				};
127				reader.readAsDataURL(inputFile[0].files[0]);
128			} else {
129				notifyDialog(LANG['dungluonghinhanhlon']);
130				return false;
131			}
132		} else {
133			$(elementPhoto).attr('src', '');
134			notifyDialog(LANG['dinhdanghinhanhkhonghople']);
135			return false;
136		}
137	} else {
138		$(elementPhoto).attr('src', '');
139		return false;
140	}
141}
142
143function photoZone(eDrag, iDrag, eLoad) {
144	if ($(eDrag).length) {
145		/* Drag over */
146		$(eDrag).on('dragover', function () {
147			$(this).addClass('drag-over');
148			return false;
149		});
150
151		/* Drag leave */
152		$(eDrag).on('dragleave', function () {
153			$(this).removeClass('drag-over');
154			return false;
155		});
156
157		/* Drop */
158		$(eDrag).on('drop', function (e) {
159			e.preventDefault();
160			$(this).removeClass('drag-over');
161
162			var lengthZone = e.originalEvent.dataTransfer.files.length;
163
164			if (lengthZone == 1) {
165				$(iDrag).prop('files', e.originalEvent.dataTransfer.files);
166				readImage($(iDrag), eLoad);
167			} else if (lengthZone > 1) {
168				notifyDialog(LANG['banchiduocchon1hinhanhdeuplen']);
169				return false;
170			} else {
171				notifyDialog(LANG['dulieukhonghople']);
172				return false;
173			}
174		});
175
176		/* File zone */
177		$(iDrag).change(function () {
178			readImage($(this), eLoad);
179		});
180	}
181}
182
183function generateCaptcha(action, id, id_form) {
184	if (RECAPTCHA_ACTIVE && action && id && $('#' + id).length) {
185		grecaptcha.execute(RECAPTCHA_SITEKEY, { action: action }).then(function (token) {
186			var recaptchaResponse = document.getElementById(id);
187			recaptchaResponse.value = token;
188			document.getElementById(id_form).submit();
189		});
190	}
191}
192
193function loadPaging(url = '', show = '') {
194	const productsContainer = document.querySelector('.' + show);
195	if (url) {
196		//showLoading(productsContainer); // Hiển thị loading
197		$.ajax({
198			url: url,
199			type: 'GET',
200			data: {
201				show: show
202			},
203			success: function (result) {
204				//hideLoading(productsContainer); // Ẩn loading sau khi load xong
205				$('.' + show + ' .show').html(result);
206			}
207		});
208	}
209}
210
211function doEnter(event, obj) {
212	if (event.keyCode == 13 || event.which == 13) onSearch(obj);
213}
214
215function onSearch(obj) {
216	var keyword = $('#' + obj).val();
217
218	if (keyword == '') {
219		notifyDialog(LANG['no_keywords']);
220		return false;
221	} else {
222		location.href = 'tim-kiem?keyword=' + encodeURI(keyword);
223	}
224}
225
226function goToByScroll(id, minusTop) {
227	minusTop = parseInt(minusTop) ? parseInt(minusTop) : 0;
228	id = id.replace('#', '');
229	$('html,body').animate(
230		{
231			scrollTop: $('#' + id).offset().top - minusTop
232		},
233		'slow'
234	);
235}
236
237function holdonOpen(
238	theme = 'sk-circle',
239	text = 'Loading...',
240	backgroundColor = 'rgba(0,0,0,0.8)',
241	textColor = 'white'
242) {
243	var options = {
244		theme: theme,
245		message: text,
246		backgroundColor: backgroundColor,
247		textColor: textColor
248	};
249
250	HoldOn.open(options);
251}
252
253function holdonClose() {
254	HoldOn.close();
255}
256
257function FirstLoadAPI(div, url, name_api) {
258	$(div).addClass('active');
259	var id = $(div).data('id');
260	var tenkhongdau = $(div).data('tenkhongdau');
261	FrameAjax(
262		url,
263		'POST',
264		{
265			id: id,
266			tenkhongdau: tenkhongdau
267		},
268		name_api
269	);
270}
271
272function LoadAPI(div, url, name_api) {
273	$(div).click(function (event) {
274		$(div).removeClass('active');
275		$(this).addClass('active');
276		var id = $(this).data('id');
277		var tenkhongdau = $(this).data('tenkhongdau');
278		FrameAjax(
279			url,
280			'POST',
281			{
282				id: id,
283				tenkhongdau: tenkhongdau
284			},
285			name_api
286		);
287	});
288}
289
290function FrameAjax(url, type, data, name) {
291	$.ajax({
292		url: url,
293		type: type,
294		data: data,
295		success: function (data) {
296			$(name).html(data);
297			NN_FRAMEWORK.Lazys();
298		}
299	});
300}
301
302function Filter() {
303	holdonOpen();
304	var url = $('.url-search').val();
305	var sort = $('.sort-select-main p .check').data('sort');
306	var idCat = {};
307	$('input[name="ip-search"]:checked').each(function (index, element) {
308		var id = $(this).data('list');
309		if (!idCat[id]) idCat[id] = [];
310		idCat[id].push($(this).val());
311	});
312	var queryString = Object.keys(idCat)
313		.map(function (key) {
314			return key + '=' + idCat[key].join(',');
315		})
316		.join('&');
317	url += '?sort=' + sort + (queryString ? '&' + queryString : '');
318	window.location.href = url;
319}
320
321function TextSort() {
322	var text = $('.sort-select-main p .check').text();
323	$('.sort-show').text(text);
324}
325
326function useStrict(val = '') {
327	return Function(`"use strict";return ${val}`)();
328}
329
330function showLoading(container) {
331	const loadingOverlay = container.querySelector('.loading-overlay');
332	if (loadingOverlay) {
333		loadingOverlay.style.display = 'flex';
334	}
335}
336
337// Function để ẩn loading trong đúng class .products
338function hideLoading(container) {
339	const loadingOverlay = container.querySelector('.loading-overlay');
340	if (loadingOverlay) {
341		loadingOverlay.style.display = 'none';
342	}
343}

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.