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