1/*! 2 * jQuery Cookie Plugin v1.4.1 3 * https://github.com/carhartl/jquery-cookie 4 * 5 * Copyright 2006, 2014 Klaus Hartl 6 * Released under the MIT license 7 */ 8(function (factory) { 9 if (typeof define === "function" && define.amd) { 10 // AMD (Register as an anonymous module) 11 define(["jquery"], factory); 12 } else if (typeof exports === "object") { 13 // Node/CommonJS 14 module.exports = factory(require("jquery")); 15 } else { 16 // Browser globals 17 factory(jQuery); 18 } 19})(function ($) { 20 var pluses = /\+/g; 21 22 function encode(s) { 23 return config.raw ? s : encodeURIComponent(s); 24 } 25 26 function decode(s) { 27 return config.raw ? s : decodeURIComponent(s); 28 } 29 30 function stringifyCookieValue(value) { 31 return encode(config.json ? JSON.stringify(value) : String(value)); 32 } 33 34 function parseCookieValue(s) { 35 if (s.indexOf('"') === 0) { 36 // This is a quoted cookie as according to RFC2068, unescape... 37 s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, "\\"); 38 } 39 40 try { 41 // Replace server-side written pluses with spaces. 42 // If we can't decode the cookie, ignore it, it's unusable. 43 // If we can't parse the cookie, ignore it, it's unusable. 44 s = decodeURIComponent(s.replace(pluses, " ")); 45 return config.json ? JSON.parse(s) : s; 46 } catch (e) {} 47 } 48 49 function read(s, converter) { 50 var value = config.raw ? s : parseCookieValue(s); 51 return $.isFunction(converter) ? converter(value) : value; 52 } 53 54 var config = ($.cookie = function (key, value, options) { 55 // Write 56 57 if (arguments.length > 1 && !$.isFunction(value)) { 58 options = $.extend({}, config.defaults, options); 59 60 if (typeof options.expires === "number") { 61 var days = options.expires, 62 t = (options.expires = new Date()); 63 t.setMilliseconds(t.getMilliseconds() + days * 864e5); 64 } 65 66 return (document.cookie = [ 67 encode(key), 68 "=", 69 stringifyCookieValue(value), 70 options.expires 71 ? "; expires=" + options.expires.toUTCString() 72 : "", // use expires attribute, max-age is not supported by IE 73 options.path ? "; path=" + options.path : "", 74 options.domain ? "; domain=" + options.domain : "", 75 options.secure ? "; secure" : "", 76 ].join("")); 77 } 78 79 // Read 80 81 var result = key ? undefined : {}, 82 // To prevent the for loop in the first place assign an empty array 83 // in case there are no cookies at all. Also prevents odd result when 84 // calling $.cookie(). 85 cookies = document.cookie ? document.cookie.split("; ") : [], 86 i = 0, 87 l = cookies.length; 88 89 for (; i < l; i++) { 90 var parts = cookies[i].split("="), 91 name = decode(parts.shift()), 92 cookie = parts.join("="); 93 94 if (key === name) { 95 // If second argument (value) is a function it's a converter... 96 result = read(cookie, value); 97 break; 98 } 99 100 // Prevent storing a cookie that we couldn't decode. 101 if (!key && (cookie = read(cookie)) !== undefined) { 102 result[name] = cookie; 103 } 104 } 105 106 return result; 107 }); 108 109 config.defaults = {}; 110 111 $.removeCookie = function (key, options) { 112 // Must not alter options, thus extending a fresh object... 113 $.cookie(key, "", $.extend({}, options, { expires: -1 })); 114 return !$.cookie(key); 115 }; 116});
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.