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