PageSourceSearch

https://www.badmintonbay.com/catalog/view/javascript/autodetect/autodetect.js

js badmintonbay.com collected 2026-10-04 16:08:15 UTC 3,755 bytes, 140 lines download raw bytes

1(function (factory) {
2	if (typeof define === 'function' && define.amd) {
3		// AMD
4		define(['jquery'], factory);
5	} else if (typeof exports === 'object') {
6		// CommonJS
7		factory(require('jquery'));
8	} else {
9		// Browser globals
10		factory(jQuery);
11	}
12}(function ($) {
13
14	var pluses = /\+/g;
15
16	function encode(s) {
17		return config.raw ? s : encodeURIComponent(s);
18	}
19
20	function decode(s) {
21		return config.raw ? s : decodeURIComponent(s);
22	}
23
24	function stringifyCookieValue(value) {
25		return encode(config.json ? JSON.stringify(value) : String(value));
26	}
27
28	function parseCookieValue(s) {
29		if (s.indexOf('"') === 0) {
30			// This is a quoted cookie as according to RFC2068, unescape...
31			s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
32		}
33
34		try {
35			// Replace server-side written pluses with spaces.
36			// If we can't decode the cookie, ignore it, it's unusable.
37			// If we can't parse the cookie, ignore it, it's unusable.
38			s = decodeURIComponent(s.replace(pluses, ' '));
39			return config.json ? JSON.parse(s) : s;
40		} catch(e) {}
41	}
42
43	function read(s, converter) {
44		var value = config.raw ? s : parseCookieValue(s);
45		return $.isFunction(converter) ? converter(value) : value;
46	}
47
48	var config = $.cookie = function (key, value, options) {
49
50		// Write
51
52		if (arguments.length > 1 && !$.isFunction(value)) {
53			options = $.extend({}, config.defaults, options);
54
55			if (typeof options.expires === 'number') {
56				var days = options.expires, t = options.expires = new Date();
57				t.setTime(+t + days * 864e+5);
58			}
59
60			return (document.cookie = [
61				encode(key), '=', stringifyCookieValue(value),
62				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
63				options.path    ? '; path=' + options.path : '',
64				options.domain  ? '; domain=' + options.domain : '',
65				options.secure  ? '; secure' : ''
66			].join(''));
67		}
68
69		// Read
70
71		var result = key ? undefined : {};
72
73		// To prevent the for loop in the first place assign an empty array
74		// in case there are no cookies at all. Also prevents odd result when
75		// calling $.cookie().
76		var cookies = document.cookie ? document.cookie.split('; ') : [];
77
78		for (var i = 0, l = cookies.length; i < l; i++) {
79			var parts = cookies[i].split('=');
80			var name = decode(parts.shift());
81			var cookie = parts.join('=');
82
83			if (key && key === name) {
84				// If second argument (value) is a function it's a converter...
85				result = read(cookie, value);
86				break;
87			}
88
89			// Prevent storing a cookie that we couldn't decode.
90			if (!key && (cookie = read(cookie)) !== undefined) {
91				result[name] = cookie;
92			}
93		}
94
95		return result;
96	};
97
98	config.defaults = {};
99
100	$.removeCookie = function (key, options) {
101		if ($.cookie(key) === undefined) {
102			return false;
103		}
104
105		// Must not alter options, thus extending a fresh object...
106		$.cookie(key, '', $.extend({}, options, { expires: -1 }));
107		return !$.cookie(key);
108	};
109
110}));
111
112
113function getCookie(name) {
114	var re = new RegExp(name + "=([^;]+)");
115	var value = re.exec(document.cookie);
116	return (value != null) ? unescape(value[1]) : null;
117}
118
119	$('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'catalog/view/theme/default/stylesheet/autodetect/autodetect.css') );
120
121	$.ajax({
122	  type: "POST",
123	  url: "index.php?route=module/autodetect/detect",
124	  success: function(data) {
125	  		console.log(data);
126		  if(data.syncmethod == "async"){	  
127			  if(data.reload == true) {
128			  	location.reload();
129			  	return;
130			  }
131			  
132			  if (data.redirectto) {
133				  if (!$.cookie("redirectto")) {
134				  		$.cookie("redirectto", 1, { expires : 10 });
135					  	document.location=data.redirectto.replace('amp;','');
136				  	}	
137				  }	  
138	  }
139	}});
140  

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.