PageSourceSearch

https://tveni.ge/java/jquery.cookie.js

js tveni.ge collected 2026-10-02 20:36:32 UTC 2,201 bytes, 51 lines download raw bytes

1/**
2 * Cookie plugin
3 *
4 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
5 * Dual licensed under the MIT and GPL licenses:
6 * http://www.opensource.org/licenses/mit-license.php
7 * http://www.gnu.org/licenses/gpl.html
8 *
9 */
10 
11jQuery.cookie = function(name, value, options) {
12    if (typeof value != 'undefined') { // name and value given, set cookie
13        options = options || {};
14        if (value === null) {
15            value = '';
16            options.expires = -1;
17        }
18        var expires = '';
19        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
20            var date;
21            if (typeof options.expires == 'number') {
22                date = new Date();
23                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
24            } else {
25                date = options.expires;
26            }
27            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
28        }
29        // CAUTION: Needed to parenthesize options.path and options.domain
30        // in the following expressions, otherwise they evaluate to undefined
31        // in the packed version for some reason...
32        var path = options.path ? '; path=' + (options.path) : '';
33        var domain = options.domain ? '; domain=' + (options.domain) : '';
34        var secure = options.secure ? '; secure' : '';
35        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
36    } else { // only name given, get cookie
37        var cookieValue = null;
38        if (document.cookie && document.cookie != '') {
39            var cookies = document.cookie.split(';');
40            for (var i = 0; i < cookies.length; i++) {
41                var cookie = jQuery.trim(cookies[i]);
42                // Does this cookie string begin with the name we want?
43                if (cookie.substring(0, name.length + 1) == (name + '=')) {
44                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
45                    break;
46                }
47            }
48        }
49        return cookieValue;
50    }
51};

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.