PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.7.1
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.7.1
8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 8.5.4 8.5.3 8.5.2 All 533 releases
chatbot / js / jquery.cookie.js

jquery.cookie.js in WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services 8.7.1, at js/jquery.cookie.js

229 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*!
2
3 * jQuery Cookie Plugin v1.4.1
4
5 * https://github.com/carhartl/jquery-cookie
6
7 *
8
9 * Copyright 2006, 2014 Klaus Hartl
10
11 * Released under the MIT license
12
13 */
14
15 (function (factory) {
16
17 if (typeof define === 'function' && define.amd) {
18
19 // AMD (Register as an anonymous module)
20
21 define(['jquery'], factory);
22
23 } else if (typeof exports === 'object') {
24
25 // Node/CommonJS
26
27 module.exports = factory(require('jquery'));
28
29 } else {
30
31 // Browser globals
32
33 factory(jQuery);
34
35 }
36
37 }(function ($) {
38
39
40
41 var pluses = /\+/g;
42
43
44
45 function encode(s) {
46
47 return config.raw ? s : encodeURIComponent(s);
48
49 }
50
51
52
53 function decode(s) {
54
55 return config.raw ? s : decodeURIComponent(s);
56
57 }
58
59
60
61 function stringifyCookieValue(value) {
62
63 return encode(config.json ? JSON.stringify(value) : String(value));
64
65 }
66
67
68
69 function parseCookieValue(s) {
70
71 if (s.indexOf('"') === 0) {
72
73 // This is a quoted cookie as according to RFC2068, unescape...
74
75 s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
76
77 }
78
79
80
81 try {
82
83 // Replace server-side written pluses with spaces.
84
85 // If we can't decode the cookie, ignore it, it's unusable.
86
87 // If we can't parse the cookie, ignore it, it's unusable.
88
89 s = decodeURIComponent(s.replace(pluses, ' '));
90
91 return config.json ? JSON.parse(s) : s;
92
93 } catch(e) {}
94
95 }
96
97
98
99 function read(s, converter) {
100
101 var value = config.raw ? s : parseCookieValue(s);
102
103 return $.isFunction(converter) ? converter(value) : value;
104
105 }
106
107
108
109 var config = $.cookie = function (key, value, options) {
110
111
112
113 // Write
114
115
116
117 if (arguments.length > 1 && !$.isFunction(value)) {
118
119 options = $.extend({}, config.defaults, options);
120
121
122
123 if (typeof options.expires === 'number') {
124
125 var days = options.expires, t = options.expires = new Date();
126
127 t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
128
129 }
130
131
132
133 return (document.cookie = [
134
135 encode(key), '=', stringifyCookieValue(value),
136
137 options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
138
139 options.path ? '; path=' + options.path : '',
140
141 options.domain ? '; domain=' + options.domain : '',
142
143 options.secure ? '; secure' : ''
144
145 ].join(''));
146
147 }
148
149
150
151 // Read
152
153
154
155 var result = key ? undefined : {},
156
157 // To prevent the for loop in the first place assign an empty array
158
159 // in case there are no cookies at all. Also prevents odd result when
160
161 // calling $.cookie().
162
163 cookies = document.cookie ? document.cookie.split('; ') : [],
164
165 i = 0,
166
167 l = cookies.length;
168
169
170
171 for (; i < l; i++) {
172
173 var parts = cookies[i].split('='),
174
175 name = decode(parts.shift()),
176
177 cookie = parts.join('=');
178
179
180
181 if (key === name) {
182
183 // If second argument (value) is a function it's a converter...
184
185 result = read(cookie, value);
186
187 break;
188
189 }
190
191
192
193 // Prevent storing a cookie that we couldn't decode.
194
195 if (!key && (cookie = read(cookie)) !== undefined) {
196
197 result[name] = cookie;
198
199 }
200
201 }
202
203
204
205 return result;
206
207 };
208
209
210
211 config.defaults = {};
212
213
214
215 $.removeCookie = function (key, options) {
216
217 // Must not alter options, thus extending a fresh object...
218
219 $.cookie(key, '', $.extend({}, options, { expires: -1 }));
220
221 return !$.cookie(key);
222
223 };
224
225
226
227 }));
228
229