PageSourceSearch

https://castings.plc.uk/scripts/vendor/cookie.js?d=2

js castings.plc.uk collected 2026-10-07 01:17:46 UTC 5,389 bytes, 166 lines download raw bytes

1//console.log("cookie");
2/*!
3 * JavaScript Cookie v2.2.0
4 * https://github.com/js-cookie/js-cookie
5 *
6 * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
7 * Released under the MIT license
8 */
9; (function (factory) {
10    var registeredInModuleLoader = false;
11    if (typeof define === 'function' && define.amd) {
12        define(factory);
13        registeredInModuleLoader = true;
14    }
15    if (typeof exports === 'object') {
16        module.exports = factory();
17        registeredInModuleLoader = true;
18    }
19    if (!registeredInModuleLoader) {
20        var OldCookies = window.Cookies;
21        var api = window.Cookies = factory();
22        api.noConflict = function () {
23            window.Cookies = OldCookies;
24            return api;
25        };
26    }
27}(function () {
28    function extend() {
29        var i = 0;
30        var result = {};
31        for (; i < arguments.length; i++) {
32            var attributes = arguments[i];
33            for (var key in attributes) {
34                result[key] = attributes[key];
35            }
36        }
37        return result;
38    }
39
40    function init(converter) {
41        function api(key, value, attributes) {
42            var result;
43            if (typeof document === 'undefined') {
44                return;
45            }
46
47            // Write
48
49            if (arguments.length > 1) {
50                attributes = extend({
51                    path: '/'
52                }, api.defaults, attributes);
53
54                if (typeof attributes.expires === 'number') {
55                    var expires = new Date();
56                    expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
57                    attributes.expires = expires;
58                }
59
60                // We're using "expires" because "max-age" is not supported by IE
61                attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
62
63                try {
64                    result = JSON.stringify(value);
65                    if (/^[\{\[]/.test(result)) {
66                        value = result;
67                    }
68                } catch (e) { }
69
70                if (!converter.write) {
71                    value = encodeURIComponent(String(value))
72						.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
73                } else {
74                    value = converter.write(value, key);
75                }
76
77                key = encodeURIComponent(String(key));
78                key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
79                key = key.replace(/[\(\)]/g, escape);
80
81                var stringifiedAttributes = '';
82
83                for (var attributeName in attributes) {
84                    if (!attributes[attributeName]) {
85                        continue;
86                    }
87                    stringifiedAttributes += '; ' + attributeName;
88                    if (attributes[attributeName] === true) {
89                        continue;
90                    }
91                    stringifiedAttributes += '=' + attributes[attributeName];
92                }
93                return (document.cookie = key + '=' + value + stringifiedAttributes);
94            }
95
96            // Read
97
98            if (!key) {
99                result = {};
100            }
101
102            // To prevent the for loop in the first place assign an empty array
103            // in case there are no cookies at all. Also prevents odd result when
104            // calling "get()"
105            var cookies = document.cookie ? document.cookie.split('; ') : [];
106            var rdecode = /(%[0-9A-Z]{2})+/g;
107            var i = 0;
108
109            for (; i < cookies.length; i++) {
110                var parts = cookies[i].split('=');
111                var cookie = parts.slice(1).join('=');
112
113                if (!this.json && cookie.charAt(0) === '"') {
114                    cookie = cookie.slice(1, -1);
115                }
116
117                try {
118                    var name = parts[0].replace(rdecode, decodeURIComponent);
119                    cookie = converter.read ?
120						converter.read(cookie, name) : converter(cookie, name) ||
121						cookie.replace(rdecode, decodeURIComponent);
122
123                    if (this.json) {
124                        try {
125                            cookie = JSON.parse(cookie);
126                        } catch (e) { }
127                    }
128
129                    if (key === name) {
130                        result = cookie;
131                        break;
132                    }
133
134                    if (!key) {
135                        result[name] = cookie;
136                    }
137                } catch (e) { }
138            }
139
140            return result;
141        }
142
143        api.set = api;
144        api.get = function (key) {
145            return api.call(api, key);
146        };
147        api.getJSON = function () {
148            return api.apply({
149                json: true
150            }, [].slice.call(arguments));
151        };
152        api.defaults = {};
153
154        api.remove = function (key, attributes) {
155            api(key, '', extend(attributes, {
156                expires: -1
157            }));
158        };
159
160        api.withConverter = init;
161
162        return api;
163    }
164
165    return init(function () { });
166}));

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.