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