mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 06:17:17 +00:00
updated js.cookie.js
This commit is contained in:
@@ -1,145 +1,142 @@
|
||||
/*!
|
||||
* JavaScript Cookie v2.1.0
|
||||
* https://github.com/js-cookie/js-cookie
|
||||
*
|
||||
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory();
|
||||
} else {
|
||||
var _OldCookies = window.Cookies;
|
||||
var api = window.Cookies = factory();
|
||||
api.noConflict = function () {
|
||||
window.Cookies = _OldCookies;
|
||||
return api;
|
||||
};
|
||||
}
|
||||
}(function () {
|
||||
function extend () {
|
||||
var i = 0;
|
||||
var result = {};
|
||||
for (; i < arguments.length; i++) {
|
||||
var attributes = arguments[ i ];
|
||||
for (var key in attributes) {
|
||||
result[key] = attributes[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/*! js-cookie v3.0.0-rc.1 | MIT */
|
||||
;
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = global || self, (function () {
|
||||
var current = global.Cookies;
|
||||
var exports = global.Cookies = factory();
|
||||
exports.noConflict = function () { global.Cookies = current; return exports; };
|
||||
}()));
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
function init (converter) {
|
||||
function api (key, value, attributes) {
|
||||
var result;
|
||||
function assign (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
// Write
|
||||
var defaultConverter = {
|
||||
read: function (value) {
|
||||
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
||||
},
|
||||
write: function (value) {
|
||||
return encodeURIComponent(value).replace(
|
||||
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
||||
decodeURIComponent
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
if (arguments.length > 1) {
|
||||
attributes = extend({
|
||||
path: '/'
|
||||
}, api.defaults, attributes);
|
||||
function init (converter, defaultAttributes) {
|
||||
function set (key, value, attributes) {
|
||||
if (typeof document === 'undefined') {
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof attributes.expires === 'number') {
|
||||
var expires = new Date();
|
||||
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
|
||||
attributes.expires = expires;
|
||||
}
|
||||
attributes = assign({}, defaultAttributes, attributes);
|
||||
|
||||
try {
|
||||
result = JSON.stringify(value);
|
||||
if (/^[\{\[]/.test(result)) {
|
||||
value = result;
|
||||
}
|
||||
} catch (e) {}
|
||||
if (typeof attributes.expires === 'number') {
|
||||
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
||||
}
|
||||
if (attributes.expires) {
|
||||
attributes.expires = attributes.expires.toUTCString();
|
||||
}
|
||||
|
||||
if (!converter.write) {
|
||||
value = encodeURIComponent(String(value))
|
||||
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
||||
} else {
|
||||
value = converter.write(value, key);
|
||||
}
|
||||
key = encodeURIComponent(key)
|
||||
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
||||
.replace(/[()]/g, escape);
|
||||
|
||||
key = encodeURIComponent(String(key));
|
||||
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
|
||||
key = key.replace(/[\(\)]/g, escape);
|
||||
value = converter.write(value, key);
|
||||
|
||||
return (document.cookie = [
|
||||
key, '=', value,
|
||||
attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE
|
||||
attributes.path && '; path=' + attributes.path,
|
||||
attributes.domain && '; domain=' + attributes.domain,
|
||||
attributes.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
var stringifiedAttributes = '';
|
||||
for (var attributeName in attributes) {
|
||||
if (!attributes[attributeName]) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Read
|
||||
stringifiedAttributes += '; ' + attributeName;
|
||||
|
||||
if (!key) {
|
||||
result = {};
|
||||
}
|
||||
if (attributes[attributeName] === true) {
|
||||
continue
|
||||
}
|
||||
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all. Also prevents odd result when
|
||||
// calling "get()"
|
||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||
var rdecode = /(%[0-9A-Z]{2})+/g;
|
||||
var i = 0;
|
||||
// Considers RFC 6265 section 5.2:
|
||||
// ...
|
||||
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
||||
// character:
|
||||
// Consume the characters of the unparsed-attributes up to,
|
||||
// not including, the first %x3B (";") character.
|
||||
// ...
|
||||
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
||||
}
|
||||
|
||||
for (; i < cookies.length; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var name = parts[0].replace(rdecode, decodeURIComponent);
|
||||
var cookie = parts.slice(1).join('=');
|
||||
return (document.cookie = key + '=' + value + stringifiedAttributes)
|
||||
}
|
||||
|
||||
if (cookie.charAt(0) === '"') {
|
||||
cookie = cookie.slice(1, -1);
|
||||
}
|
||||
function get (key) {
|
||||
if (typeof document === 'undefined' || (arguments.length && !key)) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
cookie = converter.read ?
|
||||
converter.read(cookie, name) : converter(cookie, name) ||
|
||||
cookie.replace(rdecode, decodeURIComponent);
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all.
|
||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||
var jar = {};
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var value = parts.slice(1).join('=');
|
||||
|
||||
if (this.json) {
|
||||
try {
|
||||
cookie = JSON.parse(cookie);
|
||||
} catch (e) {}
|
||||
}
|
||||
if (value[0] === '"') {
|
||||
value = value.slice(1, -1);
|
||||
}
|
||||
|
||||
if (key === name) {
|
||||
result = cookie;
|
||||
break;
|
||||
}
|
||||
try {
|
||||
var foundKey = defaultConverter.read(parts[0]);
|
||||
jar[foundKey] = converter.read(value, foundKey);
|
||||
|
||||
if (!key) {
|
||||
result[name] = cookie;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
if (key === foundKey) {
|
||||
break
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return key ? jar[key] : jar
|
||||
}
|
||||
|
||||
api.get = api.set = api;
|
||||
api.getJSON = function () {
|
||||
return api.apply({
|
||||
json: true
|
||||
}, [].slice.call(arguments));
|
||||
};
|
||||
api.defaults = {};
|
||||
return Object.create(
|
||||
{
|
||||
set: set,
|
||||
get: get,
|
||||
remove: function (key, attributes) {
|
||||
set(
|
||||
key,
|
||||
'',
|
||||
assign({}, attributes, {
|
||||
expires: -1
|
||||
})
|
||||
);
|
||||
},
|
||||
withAttributes: function (attributes) {
|
||||
return init(this.converter, assign({}, this.attributes, attributes))
|
||||
},
|
||||
withConverter: function (converter) {
|
||||
return init(assign({}, this.converter, converter), this.attributes)
|
||||
}
|
||||
},
|
||||
{
|
||||
attributes: { value: Object.freeze(defaultAttributes) },
|
||||
converter: { value: Object.freeze(converter) }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
api.remove = function (key, attributes) {
|
||||
api(key, '', extend(attributes, {
|
||||
expires: -1
|
||||
}));
|
||||
};
|
||||
var api = init(defaultConverter, { path: '/' });
|
||||
|
||||
api.withConverter = init;
|
||||
return api;
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
return init(function () {});
|
||||
}));
|
||||
})));
|
||||
|
||||
2
static/js/js.cookie.min.js
vendored
Normal file
2
static/js/js.cookie.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! js-cookie v3.0.0-rc.1 | MIT */
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,r=e.Cookies=t();r.noConflict=function(){return e.Cookies=n,r}}())}(this,function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var t={read:function(e){return e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};return function n(r,o){function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),n=r.write(n,t);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+c}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var c=n[i].split("="),u=c.slice(1).join("=");'"'===u[0]&&(u=u.slice(1,-1));try{var f=t.read(c[0]);if(o[f]=r.read(u,f),e===f)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){i(t,"",e({},n,{expires:-1}))},withAttributes:function(t){return n(this.converter,e({},this.attributes,t))},withConverter:function(t){return n(e({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(r)}})}(t,{path:"/"})});
|
||||
Reference in New Issue
Block a user