1// JavaScript Document 2/*! 3 * jQuery Cookie Plugin v1.3.1 4 * https://github.com/carhartl/jquery-cookie 5 * 6 * Copyright 2013 Klaus Hartl 7 * Released under the MIT license 8 */ 9(function (factory) { 10 if (typeof define === 'function' && define.amd) { 11 // AMD. Register as anonymous module. 12 define(['jquery'], factory); 13 } else { 14 // Browser globals. 15 factory(jQuery); 16 } 17}(function (jQuery) { 18 19 var pluses = /\+/g; 20 21 function raw(s) { 22 return s; 23 } 24 25 function decoded(s) { 26 return decodeURIComponent(s.replace(pluses, ' ')); 27 } 28 29 function converted(s) { 30 if (s.indexOf('"') === 0) { 31 // This is a quoted cookie as according to RFC2068, unescape 32 s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); 33 } 34 try { 35 return config.json ? JSON.parse(s) : s; 36 } catch(er) {} 37 } 38 39 var config = jQuery.cookie = function (key, value, options) { 40 41 // write 42 if (value !== undefined) { 43 options = jQuery.extend({}, config.defaults, options); 44 45 if (typeof options.expires === 'number') { 46 var days = options.expires, t = options.expires = new Date(); 47 t.setDate(t.getDate() + days); 48 } 49 50 value = config.json ? JSON.stringify(value) : String(value); 51 52 return (document.cookie = [ 53 config.raw ? key : encodeURIComponent(key), 54 '=', 55 config.raw ? value : encodeURIComponent(value), 56 options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE 57 options.path ? '; path=' + options.path : '', 58 options.domain ? '; domain=' + options.domain : '', 59 options.secure ? '; secure' : '' 60 ].join('')); 61 } 62 63 // read 64 var decode = config.raw ? raw : decoded; 65 var cookies = document.cookie.split('; '); 66 var result = key ? undefined : {}; 67 for (var i = 0, l = cookies.length; i < l; i++) { 68 var parts = cookies[i].split('='); 69 var name = decode(parts.shift()); 70 var cookie = decode(parts.join('=')); 71 72 if (key && key === name) { 73 result = converted(cookie); 74 break; 75 } 76 77 if (!key) { 78 result[name] = converted(cookie); 79 } 80 } 81 82 return result; 83 }; 84 85 config.defaults = {}; 86 87 jQuery.removeCookie = function (key, options) { 88 if (jQuery.cookie(key) !== undefined) { 89 // Must not alter options, thus extending a fresh object... 90 jQuery.cookie(key, '', jQuery.extend({}, options, { expires: -1 })); 91 return true; 92 } 93 return false; 94 }; 95 96}));
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.