PageSourceSearch

https://www.aed-rescue.com/common/js/jquery.cookie.js

js aed-rescue.com collected 2026-10-06 06:36:39 UTC 4,341 bytes, 191 lines download raw bytes

1/**
2
3 * Cookie plugin
4
5 *
6
7 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
8
9 * Dual licensed under the MIT and GPL licenses:
10
11 * http://www.opensource.org/licenses/mit-license.php
12
13 * http://www.gnu.org/licenses/gpl.html
14
15 *
16
17 */
18
19
20
21/**
22
23 * Create a cookie with the given name and value and other optional parameters.
24
25 *
26
27 * @example $.cookie('the_cookie', 'the_value');
28
29 * @desc Set the value of a cookie.
30
31 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
32
33 * @desc Create a cookie with all available options.
34
35 * @example $.cookie('the_cookie', 'the_value');
36
37 * @desc Create a session cookie.
38
39 * @example $.cookie('the_cookie', null);
40
41 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
42
43 *       used when the cookie was set.
44
45 *
46
47 * @param String name The name of the cookie.
48
49 * @param String value The value of the cookie.
50
51 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
52
53 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
54
55 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
56
57 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
58
59 *                             when the the browser exits.
60
61 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
62
63 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
64
65 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
66
67 *                        require a secure protocol (like HTTPS).
68
69 * @type undefined
70
71 *
72
73 * @name $.cookie
74
75 * @cat Plugins/Cookie
76
77 * @author Klaus Hartl/[email protected]
78
79 */
80
81
82
83/**
84
85 * Get the value of a cookie with the given name.
86
87 *
88
89 * @example $.cookie('the_cookie');
90
91 * @desc Get the value of a cookie.
92
93 *
94
95 * @param String name The name of the cookie.
96
97 * @return The value of the cookie.
98
99 * @type String
100
101 *
102
103 * @name $.cookie
104
105 * @cat Plugins/Cookie
106
107 * @author Klaus Hartl/[email protected]
108
109 */
110
111jQuery.cookie = function(name, value, options) {
112
113    if (typeof value != 'undefined') { // name and value given, set cookie
114
115        options = options || {};
116
117        if (value === null) {
118
119            value = '';
120
121            options.expires = -1;
122
123        }
124
125        var expires = '';
126
127        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
128
129            var date;
130
131            if (typeof options.expires == 'number') {
132
133                date = new Date();
134
135                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
136
137            } else {
138
139                date = options.expires;
140
141            }
142
143            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
144
145        }
146
147        // CAUTION: Needed to parenthesize options.path and options.domain
148
149        // in the following expressions, otherwise they evaluate to undefined
150
151        // in the packed version for some reason...
152
153        var path = options.path ? '; path=' + (options.path) : '';
154
155        var domain = options.domain ? '; domain=' + (options.domain) : '';
156
157        var secure = options.secure ? '; secure' : '';
158
159        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
160
161    } else { // only name given, get cookie
162
163        var cookieValue = null;
164
165        if (document.cookie && document.cookie != '') {
166
167            var cookies = document.cookie.split(';');
168
169            for (var i = 0; i < cookies.length; i++) {
170
171                var cookie = jQuery.trim(cookies[i]);
172
173                // Does this cookie string begin with the name we want?
174
175                if (cookie.substring(0, name.length + 1) == (name + '=')) {
176
177                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
178
179                    break;
180
181                }
182
183            }
184
185        }
186
187        return cookieValue;
188
189    }
190
191};

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.