質問編集履歴

1

cokkieライブラリのコードの記載を削除いたしました(変更していないため)。

2018/09/15 12:59

投稿

kazin
kazin

スコア12

test CHANGED
File without changes
test CHANGED
@@ -204,286 +204,6 @@
204
204
 
205
205
 
206
206
 
207
- **【cokkieを使用するためのライブラリ】
208
-
209
- (初期設定のままなので、いじってません)**
210
-
211
- /*!
212
-
213
- * JavaScript Cookie v2.0.2
214
-
215
- * https://github.com/js-cookie/js-cookie
216
-
217
- *
218
-
219
- * Copyright 2006, 2015 Klaus Hartl
220
-
221
- * Released under the MIT license
222
-
223
- */
224
-
225
- (function (factory) {
226
-
227
- if (typeof define === 'function' && define.amd) {
228
-
229
- define(factory);
230
-
231
- } else if (typeof exports === 'object') {
232
-
233
- module.exports = factory();
234
-
235
- } else {
236
-
237
- var _OldCookies = window.Cookies;
238
-
239
- var api = window.Cookies = factory(window.jQuery);
240
-
241
- api.noConflict = function () {
242
-
243
- window.Cookies = _OldCookies;
244
-
245
- return api;
246
-
247
- };
248
-
249
- }
250
-
251
- }(function () {
252
-
253
- function extend () {
254
-
255
- var i = 0;
256
-
257
- var result = {};
258
-
259
- for (; i < arguments.length; i++) {
260
-
261
- var attributes = arguments[ i ];
262
-
263
- for (var key in attributes) {
264
-
265
- result[key] = attributes[key];
266
-
267
- }
268
-
269
- }
270
-
271
- return result;
272
-
273
- }
274
-
275
-
276
-
277
- function init (converter) {
278
-
279
- function api (key, value, attributes) {
280
-
281
- var result;
282
-
283
-
284
-
285
- // Write
286
-
287
-
288
-
289
- if (arguments.length > 1) {
290
-
291
- attributes = extend({
292
-
293
- path: '/'
294
-
295
- }, api.defaults, attributes);
296
-
297
-
298
-
299
- if (typeof attributes.expires === 'number') {
300
-
301
- var expires = new Date();
302
-
303
- expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
304
-
305
- attributes.expires = expires;
306
-
307
- }
308
-
309
-
310
-
311
- try {
312
-
313
- result = JSON.stringify(value);
314
-
315
- if (/^[\{[]/.test(result)) {
316
-
317
- value = result;
318
-
319
- }
320
-
321
- } catch (e) {}
322
-
323
-
324
-
325
- value = encodeURIComponent(String(value));
326
-
327
- value = value.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
328
-
329
-
330
-
331
- key = encodeURIComponent(String(key));
332
-
333
- key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
334
-
335
- key = key.replace(/[()]/g, escape);
336
-
337
-
338
-
339
- return (document.cookie = [
340
-
341
- key, '=', value,
342
-
343
- attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE
344
-
345
- attributes.path && '; path=' + attributes.path,
346
-
347
- attributes.domain && '; domain=' + attributes.domain,
348
-
349
- attributes.secure ? '; secure' : ''
350
-
351
- ].join(''));
352
-
353
- }
354
-
355
-
356
-
357
- // Read
358
-
359
-
360
-
361
- if (!key) {
362
-
363
- result = {};
364
-
365
- }
366
-
367
-
368
-
369
- // To prevent the for loop in the first place assign an empty array
370
-
371
- // in case there are no cookies at all. Also prevents odd result when
372
-
373
- // calling "get()"
374
-
375
- var cookies = document.cookie ? document.cookie.split('; ') : [];
376
-
377
- var rdecode = /(%[0-9A-Z]{2})+/g;
378
-
379
- var i = 0;
380
-
381
-
382
-
383
- for (; i < cookies.length; i++) {
384
-
385
- var parts = cookies[i].split('=');
386
-
387
- var name = parts[0].replace(rdecode, decodeURIComponent);
388
-
389
- var cookie = parts.slice(1).join('=');
390
-
391
-
392
-
393
- if (cookie.charAt(0) === '"') {
394
-
395
- cookie = cookie.slice(1, -1);
396
-
397
- }
398
-
399
-
400
-
401
- cookie = converter && converter(cookie, name) || cookie.replace(rdecode, decodeURIComponent);
402
-
403
-
404
-
405
- if (this.json) {
406
-
407
- try {
408
-
409
- cookie = JSON.parse(cookie);
410
-
411
- } catch (e) {}
412
-
413
- }
414
-
415
-
416
-
417
- if (key === name) {
418
-
419
- result = cookie;
420
-
421
- break;
422
-
423
- }
424
-
425
-
426
-
427
- if (!key) {
428
-
429
- result[name] = cookie;
430
-
431
- }
432
-
433
- }
434
-
435
-
436
-
437
- return result;
438
-
439
- }
440
-
441
-
442
-
443
- api.get = api.set = api;
444
-
445
- api.getJSON = function () {
446
-
447
- return api.apply({
448
-
449
- json: true
450
-
451
- }, [].slice.call(arguments));
452
-
453
- };
454
-
455
- api.defaults = {};
456
-
457
-
458
-
459
- api.remove = function (key, attributes) {
460
-
461
- api(key, '', extend(attributes, {
462
-
463
- expires: -1
464
-
465
- }));
466
-
467
- };
468
-
469
-
470
-
471
- api.withConverter = init;
472
-
473
-
474
-
475
- return api;
476
-
477
- }
478
-
479
-
480
-
481
- return init();
482
-
483
- }));
484
-
485
-
486
-
487
207
 
488
208
 
489
209
  ```