PageSourceSearch

https://medspark.ai/wp-content/plugins/foxiz-core/assets/core.js?ver=2.6.3

js medspark.ai collected 2026-10-05 12:15:08 UTC 10,827 bytes, 393 lines download raw bytes

1/** FOXIZ_CORE_SCRIPT */
2var FOXIZ_CORE_SCRIPT = (function (Module, $) {
3	"use strict";
4
5	Module.init = function () {
6		this.yesStorage = this.isStorageAvailable();
7		this._body = $('body');
8		this.themeSettings = foxizCoreParams || {};
9		this.darkModeID = this.themeSettings.darkModeID || 'RubyDarkMode';
10		this.mSiteID = this.themeSettings.mSiteID || null;
11		this.isCMode = document.body.classList.contains("is-cmode");
12		this.personailizeUID = this.getUserUUID();
13		this.initDarkModeCookie();
14		this.switchDarkMode();
15		this.noteToggle();
16		this.passwordToggle();
17		this.emailToDownload();
18	}
19
20	/**
21	 * generate UUID
22	 * @returns {string}
23	 */
24	Module.generateUUID = function () {
25		const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';
26		let id = '';
27		for (let i = 0; i < 7; i++) {
28			const randomIndex = Math.floor(Math.random() * alphabet.length);
29			id += alphabet[randomIndex];
30		}
31		return id;
32	}
33
34	/**
35	 * set cookies
36	 * @param name
37	 * @param value
38	 * @param days
39	 */
40	Module.setCookie = function (name, value, days = 60) {
41
42		const date = new Date();
43		date.setTime(date.getTime() + Math.round(days * 24 * 60 * 60 * 1000));
44
45		const expires = '; expires=' + date.toUTCString();
46		const cookieDomain = this.themeSettings.cookieDomain || '';
47		const cookiePath = this.themeSettings.cookiePath || '/';
48
49		document.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=' + cookiePath + '; domain=' + cookieDomain;
50	}
51
52	/**
53	 * get cookie
54	 * @param name
55	 * @returns {string|null}
56	 */
57	Module.getCookie = function (name) {
58		const nameEQ = name + '=';
59		const cookies = document.cookie.split(';');
60		for (let i = 0; i < cookies.length; i++) {
61			let cookie = cookies[i];
62			while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
63			if (cookie.indexOf(nameEQ) == 0) return decodeURIComponent(cookie.substring(nameEQ.length, cookie.length));
64		}
65		return null;
66	}
67
68	/**
69	 * delete cookies
70	 * @param name
71	 */
72	Module.deleteCookie = function (name) {
73		const cookieDomain = this.themeSettings.cookieDomain || '';
74		const cookiePath = this.themeSettings.cookiePath || '/';
75		document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=' + cookiePath + '; domain=' + cookieDomain;
76	}
77
78	/**
79	 *
80	 * @returns {boolean}
81	 */
82	Module.isStorageAvailable = function () {
83		let storage;
84		try {
85			storage = window['localStorage'];
86			storage.setItem('__rbStorageSet', 'x');
87			storage.removeItem('__rbStorageSet');
88			return true;
89		} catch (e) {
90			return false;
91		}
92	}
93
94	/**
95	 * set localStorage
96	 * @param key
97	 * @param data
98	 */
99	Module.setStorage = function (key, data) {
100		this.yesStorage && localStorage.setItem(key, typeof data === 'string' ? data : JSON.stringify(data));
101	}
102
103	/**
104	 * get localStorage
105	 * @param key
106	 * @param defaultValue
107	 * @returns {any}
108	 */
109	Module.getStorage = function (key, defaultValue) {
110		if (!this.yesStorage) return null;
111		const data = localStorage.getItem(key);
112		if (data === null) return defaultValue;
113		try {
114			return JSON.parse(data);
115		} catch (e) {
116			return data;
117		}
118	}
119
120	/**
121	 * delelte localStorage
122	 * @param key
123	 */
124	Module.deleteStorage = function (key) {
125		this.yesStorage && localStorage.removeItem(key);
126	}
127
128	/**
129	 * create UUID
130	 * @returns {string|*}
131	 */
132	Module.getUserUUID = function () {
133
134		let uuid;
135		if (this.getCookie('RBUUID')) {
136			uuid = this.getCookie('RBUUID');
137		} else {
138			uuid = this.getStorage('RBUUID', null);
139			if (null === uuid) {
140				uuid = this.generateUUID();
141				this.setStorage('RBUUID', uuid);
142				this.setCookie('personalize_sync', 'yes', 1);
143			}
144
145			this.setCookie('RBUUID', uuid);
146		}
147
148		if (this.mSiteID) {
149			uuid = this.mSiteID + uuid;
150		}
151
152		return uuid;
153	}
154
155	Module.initDarkModeCookie = function () {
156		if (this.isCMode && !this.getCookie(this.darkModeID)) {
157			this.setCookie(this.darkModeID, document.body.getAttribute('data-theme'));
158		}
159	}
160
161	Module.setDarkModeCookie = function (name, value) {
162		if (this.isCMode) {
163			this.setCookie(name, value);
164		}
165	}
166
167	Module.switchDarkMode = function () {
168		const self = this;
169
170		$('.dark-mode-toggle').off('click').on('click', function (e) {
171			e.preventDefault();
172			e.stopPropagation();
173
174			const target = $(this);
175			!target.hasClass('triggered') && target.addClass('triggered');
176
177			const iconDefault = $('.mode-icon-default');
178			const iconDark = $('.mode-icon-dark');
179			const currentMode = (self.isCMode || !self.yesStorage) ? document.body.getAttribute('data-theme') : self.getStorage(self.darkModeID);
180
181			self._body.addClass('switch-smooth');
182			if ('dark' === currentMode) {
183				self.setStorage(self.darkModeID, 'default');
184				self.setDarkModeCookie(self.darkModeID, 'default');
185				self._body.attr('data-theme', 'default');
186				iconDefault.addClass('activated');
187				iconDark.removeClass('activated');
188			} else {
189				self.setStorage(self.darkModeID, 'dark');
190				self.setDarkModeCookie(self.darkModeID, 'dark');
191				self._body.attr('data-theme', 'dark');
192				iconDefault.removeClass('activated');
193				iconDark.addClass('activated');
194			}
195		})
196	}
197
198	/** share action */
199	Module.shareTrigger = function () {
200
201		$('a.share-trigger').off('click').on('click', function (e) {
202			e.preventDefault();
203			e.stopPropagation();
204			window.open($(this).attr('href'), '_blank', 'width=600, height=350');
205			return false;
206		});
207
208		const copyButton = $('a.copy-trigger');
209		if (navigator.clipboard) {
210			copyButton.off('click').on('click', function (e) {
211				e.preventDefault();
212				e.stopPropagation();
213				const target = $(this);
214				const link = target.data('link');
215				const copied = target.data('copied');
216				if (link) {
217					navigator.clipboard.writeText(link).then(
218						function () {
219							$('body').find('.tipsy-inner').html((copied));
220						}).catch(function () {
221					});
222				}
223			});
224		} else {
225			copyButton.hide();
226		}
227
228		const shareButton = $('a.native-share-trigger');
229		if (navigator.share) {
230			shareButton.on('click', function (e) {
231				e.preventDefault();
232				e.stopPropagation();
233
234				const target = $(this);
235				const link = target.data('link');
236				const title = target.data('ptitle');
237				navigator.share({
238					title: title,
239					url: link
240				})
241			});
242		} else {
243			shareButton.hide();
244		}
245	};
246
247	/** single infinite load */
248	Module.loadGoogleAds = function (response) {
249		const googleAds = $(response).find('.adsbygoogle');
250		if (typeof window.adsbygoogle !== 'undefined' && googleAds.length) {
251			var adsbygoogle;
252			googleAds.each(function () {
253				(adsbygoogle = window.adsbygoogle || []).push({});
254			});
255		}
256	}
257
258	Module.loadInstagram = function (response) {
259		let instEmbed = $(response).find('.instagram-media');
260		if ('undefined' !== typeof window.instgrm) {
261			window.instgrm.Embeds.process();
262		} else if (instEmbed.length && 'undefined' === typeof window.instgrm) {
263			const embedJS = document.createElement('script');
264			embedJS.src = '//platform.instagram.com/en_US/embeds.js';
265			embedJS.onload = function () {
266				window.instgrm.Embeds.process();
267			};
268			this._body.append(embedJS);
269		}
270	}
271
272	Module.loadTwttr = function () {
273		if (typeof twttr !== 'undefined' && typeof twttr.widgets !== 'undefined') {
274			twttr.ready(function (twttr) {
275				twttr.widgets.load();
276			});
277		}
278	}
279
280	Module.updateGA = function (article) {
281		const gaURL = article.postURL.replace(/https?:\/\/[^\/]+/i, '');
282		if (typeof _gaq !== 'undefined' && _gaq !== null) {
283			_gaq.push(['_trackPageview', gaURL]);
284		}
285		if (typeof ga !== 'undefined' && ga !== null) {
286			ga('send', 'pageview', gaURL);
287		}
288		if (typeof __gaTracker !== 'undefined' && __gaTracker !== null) {
289			__gaTracker('send', 'pageview', gaURL);
290		}
291
292		if (window.googletag && googletag.pubadsReady) {
293			googletag.pubads().refresh();
294		}
295	}
296
297	Module.noteToggle = function () {
298		$('.yes-toggle > .note-header').on('click', function () {
299			let wrapper = $(this).parent();
300			let timing = wrapper.hasClass('is-inline') ? 0 : 300;
301
302			wrapper.toggleClass('explain');
303			wrapper.find('.note-content').slideToggle(timing);
304		});
305	}
306
307	Module.passwordToggle = function () {
308		$('.rb-password-toggle').on('click', function () {
309			const $this = $(this);
310			const $input = $this.prev('input');
311			const $icon = $this.find('i');
312
313			if ($input.attr('type') === 'password') {
314				$input.attr('type', 'text');
315				$icon.removeClass('rbi-show').addClass('rbi-hide');
316			} else {
317				$input.attr('type', 'password');
318				$icon.removeClass('rbi-hide').addClass('rbi-show');
319			}
320		});
321	}
322
323	Module.isValidEmail = function (email) {
324		const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
325		return emailRegex.test(email);
326	}
327
328	Module.emailToDownload = function () {
329		const self = this;
330
331		$('.download-form').each(function () {
332			const form = $(this);
333			const acceptTermsCheckbox = form.find('input[name="acceptTerms"]');
334			const submitButton = form.find('input[type="submit"]');
335			const noticeText = form.find('.notice-text');
336
337			if (acceptTermsCheckbox.length > 0) {
338				acceptTermsCheckbox.change(function () {
339					submitButton.prop('disabled', !this.checked);
340				});
341			}
342
343			form.submit(function (event) {
344				event.preventDefault();
345
346				const emailInput = form.find('input[name="EMAIL"]');
347				const email = emailInput.val();
348				const label = form.find('input[type="submit"]').val();
349				noticeText.empty();
350
351				if (!self.isValidEmail(email)) {
352					const errorNotice = 'Please enter a valid email address.';
353					noticeText.text(errorNotice);
354					return;
355				}
356
357				const wrapper = form.parents('.gb-download');
358				wrapper.addClass('submitting');
359
360				$.ajax({
361					url: self.themeSettings.ajaxurl || null,
362					method: 'POST',
363					data: form.serialize(),
364					success: function (response) {
365						const fileURL = response.file;
366						if (fileURL) {
367							const link = document.createElement('a');
368							link.href = fileURL;
369							link.setAttribute('download', '');
370							link.click();
371							const newContent = `<div class="fallback-info">${response.message}</div><a href="${response.file}" download="" class="is-btn gb-download-btn fallback-download-btn">${label}</a>`;
372							form.replaceWith(newContent);
373						} else {
374							noticeText.text(response.message);
375						}
376						wrapper.removeClass('submitting');
377					}
378				});
379			});
380		});
381	};
382
383	return Module;
384
385}(FOXIZ_CORE_SCRIPT || {}, jQuery));
386
387jQuery(document).ready(function () {
388	FOXIZ_CORE_SCRIPT.init();
389});
390
391jQuery(window).on('load', function () {
392	FOXIZ_CORE_SCRIPT.shareTrigger();
393});

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.