[16787] | 1 | /*! |
---|
| 2 | * jQuery Cookie Plugin v1.1 |
---|
| 3 | * https://github.com/carhartl/jquery-cookie |
---|
| 4 | * |
---|
| 5 | * Copyright 2011, Klaus Hartl |
---|
| 6 | * Dual licensed under the MIT or GPL Version 2 licenses. |
---|
| 7 | * http://www.opensource.org/licenses/mit-license.php |
---|
| 8 | * http://www.opensource.org/licenses/GPL-2.0 |
---|
| 9 | */ |
---|
| 10 | (function($, document) { |
---|
| 11 | |
---|
| 12 | var pluses = /\+/g; |
---|
| 13 | function raw(s) { |
---|
| 14 | return s; |
---|
| 15 | } |
---|
| 16 | function decoded(s) { |
---|
| 17 | return decodeURIComponent(s.replace(pluses, ' ')); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | $.cookie = function(key, value, options) { |
---|
| 21 | |
---|
| 22 | // key and at least value given, set cookie... |
---|
| 23 | if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value == null)) { |
---|
| 24 | options = $.extend({}, $.cookie.defaults, options); |
---|
| 25 | |
---|
| 26 | if (value == null) { |
---|
| 27 | options.expires = -1; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | if (typeof options.expires === 'number') { |
---|
| 31 | var days = options.expires, t = options.expires = new Date(); |
---|
| 32 | t.setDate(t.getDate() + days); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | value = String(value); |
---|
| 36 | |
---|
| 37 | return (document.cookie = [ |
---|
| 38 | encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value), |
---|
| 39 | options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE |
---|
| 40 | options.path ? '; path=' + options.path : '', |
---|
| 41 | options.domain ? '; domain=' + options.domain : '', |
---|
| 42 | options.secure ? '; secure' : '' |
---|
| 43 | ].join('')); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | // key and possibly options given, get cookie... |
---|
| 47 | options = value || $.cookie.defaults || {}; |
---|
| 48 | var decode = options.raw ? raw : decoded; |
---|
| 49 | var cookies = document.cookie.split('; '); |
---|
| 50 | for (var i = 0, parts; (parts = cookies[i] && cookies[i].split('=')); i++) { |
---|
| 51 | if (decode(parts.shift()) === key) { |
---|
| 52 | return decode(parts.join('=')); |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | return null; |
---|
| 56 | }; |
---|
| 57 | |
---|
| 58 | $.cookie.defaults = {}; |
---|
| 59 | |
---|
| 60 | })(jQuery, document); |
---|