質問編集履歴
1
cokkieライブラリのコードの記載を削除いたしました(変更していないため)。
title
CHANGED
File without changes
|
body
CHANGED
@@ -101,147 +101,7 @@
|
|
101
101
|
</body>
|
102
102
|
</html>
|
103
103
|
|
104
|
-
**【cokkieを使用するためのライブラリ】
|
105
|
-
(初期設定のままなので、いじってません)**
|
106
|
-
/*!
|
107
|
-
* JavaScript Cookie v2.0.2
|
108
|
-
* https://github.com/js-cookie/js-cookie
|
109
|
-
*
|
110
|
-
* Copyright 2006, 2015 Klaus Hartl
|
111
|
-
* Released under the MIT license
|
112
|
-
*/
|
113
|
-
(function (factory) {
|
114
|
-
if (typeof define === 'function' && define.amd) {
|
115
|
-
define(factory);
|
116
|
-
} else if (typeof exports === 'object') {
|
117
|
-
module.exports = factory();
|
118
|
-
} else {
|
119
|
-
var _OldCookies = window.Cookies;
|
120
|
-
var api = window.Cookies = factory(window.jQuery);
|
121
|
-
api.noConflict = function () {
|
122
|
-
window.Cookies = _OldCookies;
|
123
|
-
return api;
|
124
|
-
};
|
125
|
-
}
|
126
|
-
}(function () {
|
127
|
-
function extend () {
|
128
|
-
var i = 0;
|
129
|
-
var result = {};
|
130
|
-
for (; i < arguments.length; i++) {
|
131
|
-
var attributes = arguments[ i ];
|
132
|
-
for (var key in attributes) {
|
133
|
-
result[key] = attributes[key];
|
134
|
-
}
|
135
|
-
}
|
136
|
-
return result;
|
137
|
-
}
|
138
104
|
|
139
|
-
function init (converter) {
|
140
|
-
function api (key, value, attributes) {
|
141
|
-
var result;
|
142
|
-
|
143
|
-
// Write
|
144
|
-
|
145
|
-
if (arguments.length > 1) {
|
146
|
-
attributes = extend({
|
147
|
-
path: '/'
|
148
|
-
}, api.defaults, attributes);
|
149
|
-
|
150
|
-
if (typeof attributes.expires === 'number') {
|
151
|
-
var expires = new Date();
|
152
|
-
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
|
153
|
-
attributes.expires = expires;
|
154
|
-
}
|
155
|
-
|
156
|
-
try {
|
157
|
-
result = JSON.stringify(value);
|
158
|
-
if (/^[\{[]/.test(result)) {
|
159
|
-
value = result;
|
160
|
-
}
|
161
|
-
} catch (e) {}
|
162
|
-
|
163
|
-
value = encodeURIComponent(String(value));
|
164
|
-
value = value.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
165
|
-
|
166
|
-
key = encodeURIComponent(String(key));
|
167
|
-
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
|
168
|
-
key = key.replace(/[()]/g, escape);
|
169
|
-
|
170
|
-
return (document.cookie = [
|
171
|
-
key, '=', value,
|
172
|
-
attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE
|
173
|
-
attributes.path && '; path=' + attributes.path,
|
174
|
-
attributes.domain && '; domain=' + attributes.domain,
|
175
|
-
attributes.secure ? '; secure' : ''
|
176
|
-
].join(''));
|
177
|
-
}
|
178
|
-
|
179
|
-
// Read
|
180
|
-
|
181
|
-
if (!key) {
|
182
|
-
result = {};
|
183
|
-
}
|
184
|
-
|
185
|
-
// To prevent the for loop in the first place assign an empty array
|
186
|
-
// in case there are no cookies at all. Also prevents odd result when
|
187
|
-
// calling "get()"
|
188
|
-
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
189
|
-
var rdecode = /(%[0-9A-Z]{2})+/g;
|
190
|
-
var i = 0;
|
191
|
-
|
192
|
-
for (; i < cookies.length; i++) {
|
193
|
-
var parts = cookies[i].split('=');
|
194
|
-
var name = parts[0].replace(rdecode, decodeURIComponent);
|
195
|
-
var cookie = parts.slice(1).join('=');
|
196
|
-
|
197
|
-
if (cookie.charAt(0) === '"') {
|
198
|
-
cookie = cookie.slice(1, -1);
|
199
|
-
}
|
200
|
-
|
201
|
-
cookie = converter && converter(cookie, name) || cookie.replace(rdecode, decodeURIComponent);
|
202
|
-
|
203
|
-
if (this.json) {
|
204
|
-
try {
|
205
|
-
cookie = JSON.parse(cookie);
|
206
|
-
} catch (e) {}
|
207
|
-
}
|
208
|
-
|
209
|
-
if (key === name) {
|
210
|
-
result = cookie;
|
211
|
-
break;
|
212
|
-
}
|
213
|
-
|
214
|
-
if (!key) {
|
215
|
-
result[name] = cookie;
|
216
|
-
}
|
217
|
-
}
|
218
|
-
|
219
|
-
return result;
|
220
|
-
}
|
221
|
-
|
222
|
-
api.get = api.set = api;
|
223
|
-
api.getJSON = function () {
|
224
|
-
return api.apply({
|
225
|
-
json: true
|
226
|
-
}, [].slice.call(arguments));
|
227
|
-
};
|
228
|
-
api.defaults = {};
|
229
|
-
|
230
|
-
api.remove = function (key, attributes) {
|
231
|
-
api(key, '', extend(attributes, {
|
232
|
-
expires: -1
|
233
|
-
}));
|
234
|
-
};
|
235
|
-
|
236
|
-
api.withConverter = init;
|
237
|
-
|
238
|
-
return api;
|
239
|
-
}
|
240
|
-
|
241
|
-
return init();
|
242
|
-
}));
|
243
|
-
|
244
|
-
|
245
105
|
```
|
246
106
|
|
247
107
|
### 試したこと
|