scratch – Diff between revs 58 and 125
?pathlinks?
Rev 58 | Rev 125 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | /*! |
1 | /*! |
|
2 | * JavaScript Cookie v2.1.3 |
2 | * JavaScript Cookie v2.1.4 |
|
3 | * https://github.com/js-cookie/js-cookie |
3 | * https://github.com/js-cookie/js-cookie |
|
4 | * |
4 | * |
|
5 | * Copyright 2006, 2015 Klaus Hartl & Fagner Brack |
5 | * Copyright 2006, 2015 Klaus Hartl & Fagner Brack |
|
6 | * Released under the MIT license |
6 | * Released under the MIT license |
|
7 | */ |
7 | */ |
|
Line 54... | Line 54... | |||
54 | var expires = new Date(); |
54 | var expires = new Date(); |
|
55 | expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); |
55 | expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); |
|
56 | attributes.expires = expires; |
56 | attributes.expires = expires; |
|
57 | } |
57 | } |
|
Line -... | Line 58... | |||
- | 58 | |
||
- | 59 | // We're using "expires" because "max-age" is not supported by IE |
||
- | 60 | attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; |
||
58 | |
61 | |
|
59 | try { |
62 | try { |
|
60 | result = JSON.stringify(value); |
63 | result = JSON.stringify(value); |
|
61 | if (/^[\{\[]/.test(result)) { |
64 | if (/^[\{\[]/.test(result)) { |
|
62 | value = result; |
65 | value = result; |
|
Line 72... | Line 75... | |||
72 | |
75 | |
|
73 | key = encodeURIComponent(String(key)); |
76 | key = encodeURIComponent(String(key)); |
|
74 | key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); |
77 | key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); |
|
Line 75... | Line 78... | |||
75 | key = key.replace(/[\(\)]/g, escape); |
78 | key = key.replace(/[\(\)]/g, escape); |
|
- | 79 | |
||
76 | |
80 | var stringifiedAttributes = ''; |
|
77 | return (document.cookie = [ |
- | ||
78 | key, '=', value, |
81 | |
|
- | 82 | for (var attributeName in attributes) { |
||
- | 83 | if (!attributes[attributeName]) { |
||
79 | attributes.expires ? '; expires=' + attributes.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE |
84 | continue; |
|
80 | attributes.path ? '; path=' + attributes.path : '', |
85 | } |
|
81 | attributes.domain ? '; domain=' + attributes.domain : '', |
86 | stringifiedAttributes += '; ' + attributeName; |
|
- | 87 | if (attributes[attributeName] === true) { |
||
- | 88 | continue; |
||
- | 89 | } |
||
- | 90 | stringifiedAttributes += '=' + attributes[attributeName]; |
||
82 | attributes.secure ? '; secure' : '' |
91 | } |
|
Line 83... | Line 92... | |||
83 | ].join('')); |
92 | return (document.cookie = key + '=' + value + stringifiedAttributes); |
|
Line 84... | Line 93... | |||
84 | } |
93 | } |