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