diff options
author | Adrian Lang <mail@adrianlang.de> | 2011-11-10 15:43:15 +0100 |
---|---|---|
committer | Adrian Lang <mail@adrianlang.de> | 2011-11-10 15:43:15 +0100 |
commit | 16a774a8a61756df2d8fb813bfbaed98b42e3e65 (patch) | |
tree | 3a48d311e74ccbf4017330cef8af00003b0ddb34 /lib/scripts/jquery/jquery.cookie.js | |
parent | 662a7b3fcc22d8327026bc1ef161a096683f1580 (diff) | |
parent | a5a71ecfcc1ed6bfca1995b39cd0abe4b8dd9eeb (diff) | |
download | rpg-16a774a8a61756df2d8fb813bfbaed98b42e3e65.tar.gz rpg-16a774a8a61756df2d8fb813bfbaed98b42e3e65.tar.bz2 |
Merge branch 'master' into stable
Conflicts:
doku.php
Diffstat (limited to 'lib/scripts/jquery/jquery.cookie.js')
-rw-r--r-- | lib/scripts/jquery/jquery.cookie.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/scripts/jquery/jquery.cookie.js b/lib/scripts/jquery/jquery.cookie.js new file mode 100644 index 000000000..6a3e394b4 --- /dev/null +++ b/lib/scripts/jquery/jquery.cookie.js @@ -0,0 +1,41 @@ +/** + * jQuery Cookie plugin + * + * Copyright (c) 2010 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ +jQuery.cookie = function (key, value, options) { + + // key and at least value given, set cookie... + if (arguments.length > 1 && String(value) !== "[object Object]") { + options = jQuery.extend({}, options); + + if (value === null || value === undefined) { + options.expires = -1; + } + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = String(value); + + return (document.cookie = [ + encodeURIComponent(key), '=', + options.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // key and possibly options given, get cookie... + options = value || {}; + var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; + return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; +}; |