PageSourceSearch

https://naturalnutmeg.com/wp-content/themes/magone/assets/js/lib.js?ver=9.1

js naturalnutmeg.com collected 2026-10-03 22:56:25 UTC 8,087 bytes, 292 lines download raw bytes

1/*STORAGE*/
2// check if is firefox
3var Magone_Is_Firefox = false;
4if (jQuery('.is-firefox').css('display') != 'none') {
5	Magone_Is_Firefox = true;
6}
7var Magone_Is_Ie9 = false;
8if (jQuery('.is-ie9').css('display') != 'none') {
9	Magone_Is_Ie9 = true;
10}
11var Magone_Is_Retina = false;
12
13
14// store content to web browser
15function magone_included_cookie() {
16	if ('cookie' in document) {
17		return true;
18	}
19	return false;
20}
21function magone_set_cookie(c_name,value,exdays) {
22	if (!magone_included_cookie()) {
23		return false;
24	}
25    var exdate=new Date();
26    exdate.setDate(exdate.getDate() + exdays);
27    var c_value=escape(value) + ((exdays==null) ? '' : '; expires='+exdate.toUTCString())+'; path=/';
28    document.cookie=c_name + "=" + c_value;
29	if (magone_get_cookie(c_name) !== value) {
30		return false;
31	}
32	return true;
33}
34function magone_has_cookie() {
35	if (magone_set_cookie('test', 'ok')) {
36		return true;
37	}
38	return false;
39}
40function magone_get_cookie(c_name) {
41	if (!magone_included_cookie()) {
42		return '';
43	}
44    var i,x,y,ARRcookies=document.cookie.split(";");
45    for (i=0;i<ARRcookies.length;i++)
46    {
47        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
48        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
49        x=x.replace(/^\s+|\s+$/g,"");
50        if (x==c_name)
51        {
52            return unescape(y);
53        }
54    }
55	return '';
56}
57function magone_has_storage() {
58	if(typeof(localStorage) !== "undefined") {
59		return true;
60	} 
61	return false;
62}
63function magone_set_storage(key,value) {
64	if (magone_has_storage()) {
65		localStorage.setItem(key,value);
66		return true;
67	}
68	return false;
69}
70function magone_get_storage(key) {
71	if (magone_has_storage()) {
72		var ret = localStorage.getItem(key);
73		if (ret) {
74			return ret;
75		}
76	}
77	return '';
78}
79function magone_update_option(option_name, option_value) {
80	if (magone_has_storage()) {
81		return magone_set_storage(option_name, option_value);
82	} else if (magone_has_cookie()) {
83		return magone_set_cookie(option_name, option_value);
84	}
85	return false;
86}
87function magone_get_option(option_name) {
88	if (magone_has_storage()) {
89		return magone_get_storage(option_name);
90	} else if (magone_has_cookie()) {
91		return magone_get_cookie(option_name);
92	}
93	return '';
94}
95
96
97
98/*remake UI*/
99
100
101/*IMAGE MASTER*/
102function magone_is_high_density(){
103    return ((window.matchMedia && (window.matchMedia('only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)').matches)) || (window.devicePixelRatio && window.devicePixelRatio > 1.3));
104}
105
106
107function magone_is_retina(){
108    return ((window.matchMedia && (window.matchMedia('only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx), only screen and (min-resolution: 75.6dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min--moz-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)').matches)) || (window.devicePixelRatio && window.devicePixelRatio >= 2)) && /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
109}
110
111(function() {
112    var root = (typeof exports === 'undefined' ? window : exports);
113    
114    function Retina() {}
115
116    root.Retina = Retina;
117
118    Retina.isRetina = function(){
119        
120    };
121})();
122
123function magone_srcset_parse(srcset) {
124	
125	var ret = srcset.split(', ');
126	
127	// colllect sets
128	for (var i = 0; i < ret.length; i++) {
129		ret[i] = ret[i].split(' ');
130		if (ret[i].length == 2) {
131			ret[i][1] = ret[i][1].replace('w', '');
132			if (isNaN(ret[i][1])) {
133				ret[i][1] = 0;
134			}
135			ret[i][1] = Number(ret[i][1]);
136		}
137	}
138	
139	// remove blank
140	for (var i = ret.length - 1; i >= 0; i-=1) {
141		if (ret[i].length != 2 || ret[i][1] == 0) {
142			ret.splice(i, 1);
143		}
144	}
145
146	// sort from low to high
147	for (var i = 0; i < ret.length - 1; i++) {
148		for (var j = i+1; j < ret.length; j++) {
149			if (ret[i][1] > ret[j][1]) {
150				var temp = ret[j];
151				ret[j] = ret[i];
152				ret[i] = temp;
153			}
154		}
155	}
156
157	return ret;
158}
159/*
160You must make sure your image container has class name .item-thumbnail and add below css into your style sheet.
161
162.item-thumbnail *, .item-thumbnail img {display:block;max-width: 9999px; max-height: 9999px; padding: 0!important;}
163.item-thumbnail {overflow: hidden;display: block;z-index:9;}
164*/
165Magone_Is_Retina = (magone_is_high_density() || magone_is_retina());
166
167jQuery(window).resize(function(){
168	Magone_Is_Retina = (magone_is_high_density() || magone_is_retina());
169});
170
171
172
173/*extra lib*/
174function magone_is_number (variable) {
175	return (typeof(variable) != 'undefined' && !isNaN(variable));
176}
177
178function magone_ajax_error(data) {
179	return (!data || ((data.indexOf('<b>Warning:</b> ') != -1  || data.indexOf('Warning: ') != -1 || data.indexOf('Fatal error: ') != -1 || data.indexOf('<b>Fatal error:</b> ') != -1) && data.indexOf(' on line ') != -1));
180}
181
182function magone_select_all (elem) {
183	jQuery(elem).select();
184	// Work around Chrome's little problem
185	jQuery(elem).mouseup(function() {
186		// Prevent further mouseup intervention
187		jQuery(elem).unbind("mouseup");
188		return false;
189	});
190}
191
192function magone_selectText(element) {
193    var doc = document;
194    var text = doc.getElementById(element);
195    var range;
196    var selection;    
197
198    if (doc.body.createTextRange) { //ms
199        range = doc.body.createTextRange();
200        range.moveToElementText(text);
201        range.select();
202    } else if (window.getSelection) { //all others
203        selection = window.getSelection();        
204        range = doc.createRange();
205        range.selectNodeContents(text);
206        selection.removeAllRanges();
207        selection.addRange(range);
208    }
209}
210
211function magone_is_image_src(url) {
212	return (url.toLowerCase().match/***/(/\.(jpeg|jpg|gif|png)$/)/***/ != null);
213}
214
215function magone_scroll_to(elem, delay) {
216	if (typeof(elem) == 'undefined' || jQuery(elem).length == 0) {
217		return;
218	}
219	if (typeof(delay) == 'undefined') {
220		delay = 50;
221	}
222	jQuery('html, body').animate({
223		scrollTop: jQuery(elem).offset().top
224	}, delay);
225}
226
227function magone_is_variable_name_character(character) {
228	var character = character.charCodeAt(0);
229	if (character >= 'a'.charCodeAt(0) && 
230		character <= 'z'.charCodeAt(0) ||
231		character >= 'A'.charCodeAt(0) &&
232		character <= 'Z'.charCodeAt(0) ||
233		character >= '0'.charCodeAt(0) &&
234		character <= '9'.charCodeAt(0) ||
235		character == '_'.charCodeAt(0)) {
236		return true;
237	}
238
239	return false;
240}
241function magone_url_to_slug(url) {
242	for (var i = 0; i < url.length; i++) {
243		if (!magone_is_variable_name_character(url[i])) {
244			url = url.replace(url[i], '_');
245		}
246	}
247	return url;
248}
249
250function magone_get_str_between_arrays(original_text, open_keys, close_keys) {
251	var found = false;
252	for (var i = 0; i < open_keys.length; i++) {
253		if (original_text.indexOf(open_keys[i]) != -1) {
254			original_text = original_text.split(open_keys[i])[1];
255			found = true;
256		}
257	}
258	if (!found) {
259		return '';
260	}
261	for (var i = 0; i < close_keys.length; i++) {
262		original_text = original_text.split(close_keys[i])[0];
263	}
264
265	return original_text;
266}
267
268function magone_is_image_src(url) {
269	return (url.toLowerCase().match/***/(/\.(jpeg|jpg|gif|png)$/)/***/ != null);
270}
271
272function magone_get_youtube_video_id (url) {	
273	if (url.indexOf('youtube') == -1 && url.indexOf('youtu.be') == -1) {
274		return '';
275	}
276	return magone_get_str_between_arrays(url, ['/embed/','youtu.be/', '/videos/', '/v/', '?v=', '&v='], ['#', '/', '?', '&', '.']);
277}
278
279function magone_get_youtube_list_id (url) {
280	if (url.indexOf('youtube') == -1 && url.indexOf('youtu.be') == -1) {
281		return '';
282	}
283	return magone_get_str_between_arrays(url, ['list='], ['#', '/', '?', '&', '.']);	
284}
285
286function magone_get_vimeo_video_id (url) {
287	if (url.indexOf('vimeo') == -1) {
288		return '';
289	}
290	return magone_get_str_between_arrays(url, ['vimeo.com/', '/video/'], ['#', '/', '?', '&', '.']);	
291}
292

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.