Skip to content

Commit

Permalink
refactor: use js-cookie instead of jquery.cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
aarushtools committed Aug 15, 2024
1 parent 774c365 commit b32da03
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions intranet/static/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $.ajaxSetup({
crossDomain: false,
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", $.cookie("csrftoken"));
xhr.setRequestHeader("X-CSRFToken", Cookies.get("csrftoken"));
}
}
});
Expand Down Expand Up @@ -47,11 +47,11 @@ $(function() {
$("table[data-sortable] thead th[data-auto-sort]").trigger("click");


let collapseWarning = $.cookie("collapseWarning") === "true";
let collapseWarning = Cookies.get("collapseWarning") === "true";
$(".warning-title").on("click", function() {
$(".warning-content").slideToggle();
$(".warning-toggle-icon").toggleClass("fa-chevron-down fa-chevron-up");
$.cookie("collapseWarning", !collapseWarning, {path: "/", expires: 14})
Cookies.set("collapseWarning", !collapseWarning, {path: "/", expires: 14})
});
if(!collapseWarning) {
$(".warning-content").show();
Expand Down
2 changes: 1 addition & 1 deletion intranet/static/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $(function() {
});
var fd = new FormData();
fd.append("file", file);
fd.append("csrfmiddlewaretoken", $.cookie("csrftoken"));
fd.append("csrfmiddlewaretoken", Cookies.get("csrftoken"));
$.ajax({
url: endpoint,
type: "POST",
Expand Down
1 change: 1 addition & 0 deletions intranet/templates/page_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
{% block js %}
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="{% static 'js/vendor/modernizr.js' %}"></script>
<script src="{% static 'js/vendor/js.cookie.min.js' %}"></script>
<script src="{% static 'js/common.js' %}"></script>

<script>
Expand Down
2 changes: 1 addition & 1 deletion intranet/templates/schedule/embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</style>


<script src="{% static 'js/vendor/jquery.cookie.js' %}"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="{% static 'js/vendor/js.cookie.min.js' %}"></script>
<script src="{% static 'js/common.js' %}"></script>
<script src="{% static 'js/schedule.js' %}"></script>
<script src="{% static 'js/login.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion intranet/templates/schedule/week_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</style>


<script src="{% static 'js/vendor/jquery.cookie.js' %}"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="{% static 'js/vendor/js.cookie.min.js' %}"></script>
<script src="{% static 'js/common.js' %}"></script>
<script src="{% static 'js/schedule.js' %}"></script>
<script src="{% static 'js/login.js' %}"></script>
Expand Down

0 comments on commit b32da03

Please sign in to comment.