PageSourceSearch

https://cdn.7days.ru/bitrix/templates/7days-redesign-2021/js/jquery.cookie.js?1772533886

js 7days.ru collected 2026-10-09 21:30:50 UTC 3,189 bytes, 121 lines download raw bytes

vendor: 3,189 bytes, lines 1-121
1/*!
2 * jQuery Cookie Plugin v1.4.1
3 * https://github.com/carhartl/jquery-cookie
4 *
5 * Copyright 2013 Klaus Hartl
6 * Released under the MIT license
7 */
8(function (factory) {
9	if (typeof define === 'function' && define.amd) {
10		// AMD
11		define(['jquery'], factory);
12	} else if (typeof exports === 'object') {
13		// CommonJS
14		factory(require('jquery'));
15	} else {
16		// Browser globals
17		factory(jQuery);
18	}
19}(function ($) {
20
21	var pluses = /\+/g;
22
23	function encode(s) {
24		return config.raw ? s : encodeURIComponent(s);
25	}
26
27	function decode(s) {
28		return config.raw ? s : decodeURIComponent(s);
29	}
30
31	function stringifyCookieValue(value) {
32		return encode(config.json ? JSON.stringify(value) : String(value));
33	}
34
35	function parseCookieValue(s) {
36		if (s.indexOf('"') === 0) {
37			// This is a quoted cookie as according to RFC2068, unescape...
38			s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
39		}
40
41		try {
42			// Replace server-side written pluses with spaces.
43			// If we can't decode the cookie, ignore it, it's unusable.
44			// If we can't parse the cookie, ignore it, it's unusable.
45			s = decodeURIComponent(s.replace(pluses, ' '));
46			return config.json ? JSON.parse(s) : s;
47		} catch(e) {}
48	}
49
50	function isFunction(value) {
51		return typeof value === "function";
52	}
53
54	function read(s, converter) {
55		var value = config.raw ? s : parseCookieValue(s);
56		return isFunction(converter) ? converter(value) : value;
57	}
58
59	var config = $.cookie = function (key, value, options) {
60
61		// Write
62
63		if (value !== undefined && !isFunction(value)) {
64			options = $.extend({}, config.defaults, options);
65
66			if (typeof options.expires === 'number') {
67				var days = options.expires, t = options.expires = new Date();
68				t.setTime(+t + days * 864e+5);
69			}
70
71			return (document.cookie = [
72				encode(key), '=', stringifyCookieValue(value),
73				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
74				options.path    ? '; path=' + options.path : '',
75				options.domain  ? '; domain=' + options.domain : '',
76				options.secure  ? '; secure' : ''
77			].join(''));
78		}
79
80		// Read
81
82		var result = key ? undefined : {};
83
84		// To prevent the for loop in the first place assign an empty array
85		// in case there are no cookies at all. Also prevents odd result when
86		// calling $.cookie().
87		var cookies = document.cookie ? document.cookie.split('; ') : [];
88
89		for (var i = 0, l = cookies.length; i < l; i++) {
90			var parts = cookies[i].split('=');
91			var name = decode(parts.shift());
92			var cookie = parts.join('=');
93
94			if (key && key === name) {
95				// If second argument (value) is a function it's a converter...
96				result = read(cookie, value);
97				break;
98			}
99
100			// Prevent storing a cookie that we couldn't decode.
101			if (!key && (cookie = read(cookie)) !== undefined) {
102				result[name] = cookie;
103			}
104		}
105
106		return result;
107	};
108
109	config.defaults = {};
110
111	$.removeCookie = function (key, options) {
112		if ($.cookie(key) === undefined) {
113			return false;
114		}
115
116		// Must not alter options, thus extending a fresh object...
117		$.cookie(key, '', $.extend({}, options, { expires: -1 }));
118		return !$.cookie(key);
119	};
120
121}));

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.