PageSourceSearch

https://1812battles.com/js/jquery.cookie.js

js 1812battles.com collected 2026-09-30 12:58:17 UTC 2,475 bytes, 96 lines download raw bytes

1/*!
2 * jQuery Cookie Plugin v1.3.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. Register as anonymous module.
11    define(['jquery'], factory);
12  } else {
13    // Browser globals.
14    factory(jQuery);
15  }
16}(function ($) {
17
18  var pluses = /\+/g;
19
20  function decode(s) {
21    if (config.raw) {
22      return s;
23    }
24    return decodeURIComponent(s.replace(pluses, ' '));
25  }
26
27  function decodeAndParse(s) {
28    if (s.indexOf('"') === 0) {
29      // This is a quoted cookie as according to RFC2068, unescape...
30      s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
31    }
32
33    s = decode(s);
34
35    try {
36      return config.json ? JSON.parse(s) : s;
37    } catch(e) {}
38  }
39
40  var config = $.cookie = function (key, value, options) {
41
42    // Write
43    if (value !== undefined) {
44      options = $.extend({}, config.defaults, options);
45
46      if (typeof options.expires === 'number') {
47        var days = options.expires, t = options.expires = new Date();
48        t.setDate(t.getDate() + days);
49      }
50
51      value = config.json ? JSON.stringify(value) : String(value);
52
53      return (document.cookie = [
54        config.raw ? key : encodeURIComponent(key),
55        '=',
56        config.raw ? value : encodeURIComponent(value),
57        options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
58        options.path    ? '; path=' + options.path : '',
59        options.domain  ? '; domain=' + options.domain : '',
60        options.secure  ? '; secure' : ''
61      ].join(''));
62    }
63
64    // Read
65    var cookies = document.cookie.split('; ');
66    var result = key ? undefined : {};
67    for (var i = 0, l = cookies.length; i < l; i++) {
68      var parts = cookies[i].split('=');
69      var name = decode(parts.shift());
70      var cookie = parts.join('=');
71
72      if (key && key === name) {
73        result = decodeAndParse(cookie);
74        break;
75      }
76
77      if (!key) {
78        result[name] = decodeAndParse(cookie);
79      }
80    }
81
82    return result;
83  };
84
85  config.defaults = {};
86
87  $.removeCookie = function (key, options) {
88    if ($.cookie(key) !== undefined) {
89      // Must not alter options, thus extending a fresh object...
90      $.cookie(key, '', $.extend({}, options, { expires: -1 }));
91      return true;
92    }
93    return false;
94  };
95
96}));

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.