PageSourceSearch

https://takismarakakis.com/catalog/view/javascript/isenselabs_gdpr/journal3/cookiemanager.js?v=14218c54

js takismarakakis.com collected 2026-10-06 12:53:24 UTC 5,958 bytes, 202 lines download raw bytes

1;(function (factory) {
2	var registeredInModuleLoader;
3	if (typeof define === 'function' && define.amd) {
4		define(factory);
5		registeredInModuleLoader = true;
6	}
7	if (typeof exports === 'object') {
8		module.exports = factory();
9		registeredInModuleLoader = true;
10	}
11	if (!registeredInModuleLoader) {
12		var OldCookies = window.Cookies;
13		var api = window.Cookies = factory();
14		api.noConflict = function () {
15			window.Cookies = OldCookies;
16			return api;
17		};
18	}
19}(function () {
20	function extend () {
21		var i = 0;
22		var result = {};
23		for (; i < arguments.length; i++) {
24			var attributes = arguments[ i ];
25			for (var key in attributes) {
26				result[key] = attributes[key];
27			}
28		}
29		return result;
30	}
31
32	function init (converter) {
33		function api (key, value, attributes) {
34			if (typeof document === 'undefined') {
35				return;
36			}
37
38			// Write
39
40			if (arguments.length > 1) {
41				attributes = extend({
42					path: '/'
43				}, api.defaults, attributes);
44
45				if (typeof attributes.expires === 'number') {
46					attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
47				}
48
49				// We're using "expires" because "max-age" is not supported by IE
50				attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
51
52				try {
53					var result = JSON.stringify(value);
54					if (/^[\{\[]/.test(result)) {
55						value = result;
56					}
57				} catch (e) {}
58
59				value = converter.write ?
60					converter.write(value, key) :
61					encodeURIComponent(String(value))
62						.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
63
64				key = encodeURIComponent(String(key))
65					.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
66					.replace(/[\(\)]/g, escape);
67
68				var stringifiedAttributes = '';
69				for (var attributeName in attributes) {
70					if (!attributes[attributeName]) {
71						continue;
72					}
73					stringifiedAttributes += '; ' + attributeName;
74					if (attributes[attributeName] === true) {
75						continue;
76					}
77
78					// Considers RFC 6265 section 5.2:
79					// ...
80					// 3.  If the remaining unparsed-attributes contains a %x3B (";")
81					//     character:
82					// Consume the characters of the unparsed-attributes up to,
83					// not including, the first %x3B (";") character.
84					// ...
85					stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
86				}
87
88				return (document.cookie = key + '=' + value + stringifiedAttributes);
89			}
90
91			// Read
92
93			var jar = {};
94			var decode = function (s) {
95				return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
96			};
97			// To prevent the for loop in the first place assign an empty array
98			// in case there are no cookies at all.
99			var cookies = document.cookie ? document.cookie.split('; ') : [];
100			var i = 0;
101
102			for (; i < cookies.length; i++) {
103				var parts = cookies[i].split('=');
104				var cookie = parts.slice(1).join('=');
105
106				if (!this.json && cookie.charAt(0) === '"') {
107					cookie = cookie.slice(1, -1);
108				}
109
110				try {
111					var name = decode(parts[0]);
112					cookie = (converter.read || converter)(cookie, name) ||
113						decode(cookie);
114
115					if (this.json) {
116						try {
117							cookie = JSON.parse(cookie);
118						} catch (e) {}
119					}
120
121					jar[name] = cookie;
122
123					if (key === name) {
124						break;
125					}
126				} catch (e) {}
127			}
128
129			return key ? jar[key] : jar;
130		}
131
132		api.set = api;
133		api.get = function (key) {
134			return api.call(api, key);
135		};
136		api.getJSON = function (key) {
137			return api.call({
138				json: true
139			}, key);
140		};
141		api.remove = function (key, attributes) {
142			api(key, '', extend(attributes, {
143				expires: -1
144			}));
145		};
146
147		api.defaults = {};
148
149		api.withConverter = init;
150
151		return api;
152	}
153
154	return init(function () {});
155}));
156
157function clearCookie(name, domain, path){
158	try {
159	    function Get_Cookie( check_name ) {
160	            // first we'll split this cookie up into name/value pairs
161	            // note: document.cookie only returns name=value, not the other components
162	            var a_all_cookies = document.cookie.split(';'),
163	            	a_temp_cookie = '',
164	        		cookie_name = '',
165	            	cookie_value = '',
166		            b_cookie_found = false;
167	    
168	            for ( i = 0; i < a_all_cookies.length; i++ ) {
169                    // now we'll split apart each name=value pair
170                    a_temp_cookie = a_all_cookies[i].split( '=' );
171    
172                    // and trim left/right whitespace while we're at it
173                    cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
174    
175                    // if the extracted name matches passed check_name
176                    if ( cookie_name == check_name ) {
177                        b_cookie_found = true;
178                        // we need to handle case where cookie has no value but exists (no = sign, that is):
179                        if ( a_temp_cookie.length > 1 ) {
180                            cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
181                        }
182                        // note that in cases where cookie is initialized but no value, null is returned
183                        return cookie_value;
184                        break;
185                    }
186                    a_temp_cookie = null;
187                    cookie_name = '';
188	            }
189	            if ( !b_cookie_found ) {
190	              return null;
191	            }
192	        }
193	        if (Get_Cookie(name)) {
194                var domain = domain || document.domain;
195                var path = path || "/";
196                document.cookie = name + "=; expires=" + new Date + "; domain=" + domain + "; path=" + path;
197				document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:01 GMT; domain=" + domain + "; path=" + path;
198	        }
199
200	}
201	catch(err) {}    
202};

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.