1/** 2 * jQuery Cookie plugin 3 * 4 * Copyright (c) 2010 Klaus Hartl (stilbuero.de) 5 * Dual licensed under the MIT and GPL licenses: 6 * http://www.opensource.org/licenses/mit-license.php 7 * http://www.gnu.org/licenses/gpl.html 8 * 9 */ 10jQuery.cookie = function(name, value, options) { 11 if (typeof value != 'undefined') { // name and value given, set cookie 12 options = options || {}; 13 if (value === null) { 14 value = ''; 15 options.expires = -1; 16 } 17 var expires = ''; 18 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { 19 var date; 20 if (typeof options.expires == 'number') { 21 date = new Date(); 22 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); 23 } else { 24 date = options.expires; 25 } 26 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE 27 } 28 // CAUTION: Needed to parenthesize options.path and options.domain 29 // in the following expressions, otherwise they evaluate to undefined 30 // in the packed version for some reason... 31 var path = options.path ? '; path=' + (options.path) : ''; 32 var domain = options.domain ? '; domain=' + (options.domain) : ''; 33 var secure = options.secure ? '; secure' : ''; 34 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); 35 } else { // only name given, get cookie 36 var cookieValue = null; 37 if (document.cookie && document.cookie != '') { 38 var cookies = document.cookie.split(';'); 39 for (var i = 0; i < cookies.length; i++) { 40 var cookie = jQuery.trim(cookies[i]); 41 // Does this cookie string begin with the name we want? 42 if (cookie.substring(0, name.length + 1) == (name + '=')) { 43 cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 44 break; 45 } 46 } 47 } 48 return cookieValue; 49 } 50};
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.