Skip to content

Commit 428525d

Browse files
committed
Merged in [17211] from rjsparks@nostrum.com:
Upgrade to the newer js-cookie library that replaced jquery.cookie. Fixes ietf-tools#2832. - Legacy-Id: 17221 Note: SVN reference [17211] has been migrated to Git commit d9ea373
2 parents 09b83a0 + d9ea373 commit 428525d

10 files changed

Lines changed: 194 additions & 146 deletions

File tree

ietf/bower.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"fullcalendar": "~4",
1111
"highcharts": "~6",
1212
"html5shiv": "~3",
13+
"js-cookie": "~2",
1314
"jquery": "~1",
14-
"jquery.cookie": "~1",
1515
"jquery.tablesorter": "~2",
1616
"respond": "~1",
1717
"select2": "~3",
@@ -56,6 +56,9 @@
5656
"modules/offline-exporting.js",
5757
"modules/map.js"
5858
]
59+
},
60+
"js-cookie": {
61+
"main": "src/js.cookie.js"
5962
}
6063
}
6164
}

ietf/externals/static/jquery.cookie/bower.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

ietf/externals/static/jquery.cookie/jquery.cookie.js

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "js-cookie",
3+
"license": "MIT",
4+
"main": [
5+
"src/js.cookie.js"
6+
],
7+
"ignore": [
8+
"test",
9+
"Gruntfile.js",
10+
"package.json",
11+
".gitignore",
12+
".eslintintignore",
13+
".eslintrc",
14+
".tm_properties",
15+
".travis.yml"
16+
]
17+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/*!
2+
* JavaScript Cookie v2.2.1
3+
* https://github.com/js-cookie/js-cookie
4+
*
5+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
6+
* Released under the MIT license
7+
*/
8+
;(function (factory) {
9+
var registeredInModuleLoader;
10+
if (typeof define === 'function' && define.amd) {
11+
define(factory);
12+
registeredInModuleLoader = true;
13+
}
14+
if (typeof exports === 'object') {
15+
module.exports = factory();
16+
registeredInModuleLoader = true;
17+
}
18+
if (!registeredInModuleLoader) {
19+
var OldCookies = window.Cookies;
20+
var api = window.Cookies = factory();
21+
api.noConflict = function () {
22+
window.Cookies = OldCookies;
23+
return api;
24+
};
25+
}
26+
}(function () {
27+
function extend () {
28+
var i = 0;
29+
var result = {};
30+
for (; i < arguments.length; i++) {
31+
var attributes = arguments[ i ];
32+
for (var key in attributes) {
33+
result[key] = attributes[key];
34+
}
35+
}
36+
return result;
37+
}
38+
39+
function decode (s) {
40+
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
41+
}
42+
43+
function init (converter) {
44+
function api() {}
45+
46+
function set (key, value, attributes) {
47+
if (typeof document === 'undefined') {
48+
return;
49+
}
50+
51+
attributes = extend({
52+
path: '/'
53+
}, api.defaults, attributes);
54+
55+
if (typeof attributes.expires === 'number') {
56+
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
57+
}
58+
59+
// We're using "expires" because "max-age" is not supported by IE
60+
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
61+
62+
try {
63+
var result = JSON.stringify(value);
64+
if (/^[\{\[]/.test(result)) {
65+
value = result;
66+
}
67+
} catch (e) {}
68+
69+
value = converter.write ?
70+
converter.write(value, key) :
71+
encodeURIComponent(String(value))
72+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
73+
74+
key = encodeURIComponent(String(key))
75+
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
76+
.replace(/[\(\)]/g, escape);
77+
78+
var stringifiedAttributes = '';
79+
for (var attributeName in attributes) {
80+
if (!attributes[attributeName]) {
81+
continue;
82+
}
83+
stringifiedAttributes += '; ' + attributeName;
84+
if (attributes[attributeName] === true) {
85+
continue;
86+
}
87+
88+
// Considers RFC 6265 section 5.2:
89+
// ...
90+
// 3. If the remaining unparsed-attributes contains a %x3B (";")
91+
// character:
92+
// Consume the characters of the unparsed-attributes up to,
93+
// not including, the first %x3B (";") character.
94+
// ...
95+
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
96+
}
97+
98+
return (document.cookie = key + '=' + value + stringifiedAttributes);
99+
}
100+
101+
function get (key, json) {
102+
if (typeof document === 'undefined') {
103+
return;
104+
}
105+
106+
var jar = {};
107+
// To prevent the for loop in the first place assign an empty array
108+
// in case there are no cookies at all.
109+
var cookies = document.cookie ? document.cookie.split('; ') : [];
110+
var i = 0;
111+
112+
for (; i < cookies.length; i++) {
113+
var parts = cookies[i].split('=');
114+
var cookie = parts.slice(1).join('=');
115+
116+
if (!json && cookie.charAt(0) === '"') {
117+
cookie = cookie.slice(1, -1);
118+
}
119+
120+
try {
121+
var name = decode(parts[0]);
122+
cookie = (converter.read || converter)(cookie, name) ||
123+
decode(cookie);
124+
125+
if (json) {
126+
try {
127+
cookie = JSON.parse(cookie);
128+
} catch (e) {}
129+
}
130+
131+
jar[name] = cookie;
132+
133+
if (key === name) {
134+
break;
135+
}
136+
} catch (e) {}
137+
}
138+
139+
return key ? jar[key] : jar;
140+
}
141+
142+
api.set = set;
143+
api.get = function (key) {
144+
return get(key, false /* read as raw */);
145+
};
146+
api.getJSON = function (key) {
147+
return get(key, true /* read as json */);
148+
};
149+
api.remove = function (key, attributes) {
150+
set(key, '', extend(attributes, {
151+
expires: -1
152+
}));
153+
};
154+
155+
api.defaults = {};
156+
157+
api.withConverter = init;
158+
159+
return api;
160+
}
161+
162+
return init(function () {});
163+
}));

ietf/static/ietf/js/ietf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ jQuery.ajaxSetup({
77
crossDomain: false, // obviates need for sameOrigin test
88
beforeSend: function(xhr, settings) {
99
if (!csrfSafeMethod(settings.type)) {
10-
xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken'));
10+
xhr.setRequestHeader("X-CSRFToken", Cookies.get('csrftoken'));
1111
}
1212
}
1313
});
1414

1515
// Remember the state of the "browsehappy" alert
1616
$('#browsehappy .close').click(function(e) {
1717
e.preventDefault();
18-
$.cookie('browsehappy', 'closed', { path: '/' });
18+
Cookies.set('browsehappy', 'closed');
1919
});
2020

21-
if(typeof $.cookie('browsehappy') === 'undefined') {
21+
if(typeof Cookies.get('browsehappy') === 'undefined') {
2222
$('#browsehappy').show();
2323
}
2424

ietf/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
{% endcomment %}
170170
<script>$(".visible-nojs").removeClass("visible-nojs");</script>
171171
<script>$(".hidden-nojs").removeClass("hidden-nojs");</script>
172-
<script src="{% static 'jquery.cookie/jquery.cookie.js' %}"></script>
172+
<script src="{% static 'js-cookie/src/js.cookie.js' %}"></script>
173173
<script src="{% static 'ietf/bootstrap/js/bootstrap.min.js' %}"></script>
174174
<script src="{% static 'ietf/js/ietf.js' %}"></script>
175175
{% block js %}{% endblock %}

ietf/templates/meeting/landscape_edit.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525

2626
{% block js %}
2727
<script type="text/javascript" src="{% static 'ietf/js/agenda/jquery-1.8.2.min.js' %}"></script>
28-
<script src="{% static 'jquery.cookie/jquery.cookie.js' %}"></script>
28+
<script src="{% static 'js-cookie/src/js.cookie.js' %}"></script>
2929
<script>
3030
jQuery.ajaxSetup({
3131
crossDomain: false, // obviates need for sameOrigin test
3232
beforeSend: function(xhr, settings) {
3333
if (!csrfSafeMethod(settings.type)) {
34-
xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken'));
34+
xhr.setRequestHeader("X-CSRFToken", Cookies.get('csrftoken'));
3535
}
3636
}
3737
});

0 commit comments

Comments
 (0)