Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update jquery.cookie to js.cookie #1177

Merged
merged 2 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions game/static/game/js/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ var ocargo = ocargo || {};
ocargo.Event = function() {};

ocargo.Event.prototype.sendEvent = function(eventType, details) {
//var csrftoken = $.cookie('csrftoken');
//$.ajax({
// url: '/reports/event',
// type: 'POST',
// async: true,
// dataType: 'json',
// beforeSend: function(xhr, settings) {
// xhr.setRequestHeader("X-CSRFToken", csrftoken);
// },
// data: JSON.stringify({ app: "RapidRouter", eventType: eventType, details: details }),
// });
};

$(document).ready(function() {
Expand Down
8 changes: 0 additions & 8 deletions game/static/game/js/foundation/vendor/jquery.cookie.js

This file was deleted.

3 changes: 3 additions & 0 deletions game/static/game/js/foundation/vendor/js.cookie.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions game/static/game/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ocargo.Game = function () {
this.tabs = null
this.failures = 0
this.currentlySelectedTab = null
this.isMuted = $.cookie('muted') === 'true'
this.isMuted = Cookies.get('muted') === 'true'
}

ocargo.Game.prototype.setup = function () {
Expand Down Expand Up @@ -258,7 +258,7 @@ ocargo.Game.prototype.sendAttempt = function (score) {
) {
// Send out the submitted data.
if (LEVEL_ID) {
var csrftoken = $.cookie('csrftoken')
var csrftoken = Cookies.get('csrftoken')
$.ajax({
url: Urls.submit_attempt(),
type: 'POST',
Expand Down Expand Up @@ -1226,7 +1226,7 @@ function hasFunctionalCookiesConsent() {

function setMutedCookie(mute) {
if (hasFunctionalCookiesConsent()) {
$.cookie('muted', mute.toString(), { path: Urls.levels() })
Cookies.set('muted', mute.toString(), { path: Urls.levels() })
}
}

Expand Down
20 changes: 10 additions & 10 deletions game/static/game/js/saving.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ ocargo.Saving.prototype.retrieveWorkspace = function (id, callback) {
};

ocargo.Saving.prototype.deleteWorkspace = function (id, callback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
if (USER_STATUS === 'TEACHER' || USER_STATUS === 'SCHOOL_STUDENT' || USER_STATUS === 'INDEPENDENT_STUDENT') {
$.ajax({
url: Urls.delete_workspace(id),
Expand Down Expand Up @@ -145,7 +145,7 @@ ocargo.Saving.prototype.deleteWorkspace = function (id, callback) {
};

ocargo.Saving.prototype.saveWorkspace = function (workspace, id, callback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
if (USER_STATUS === 'TEACHER' || USER_STATUS === 'SCHOOL_STUDENT' || USER_STATUS === 'INDEPENDENT_STUDENT') {
$.ajax({
url: (id ? Urls.save_workspace(id) : Urls.save_workspace()),
Expand Down Expand Up @@ -187,7 +187,7 @@ ocargo.Saving.prototype.saveWorkspace = function (workspace, id, callback) {
/****************************/

ocargo.Saving.prototype._retrieveLevels = function (url, callback, errorCallback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
$.ajax({
url: url,
type: 'GET',
Expand Down Expand Up @@ -215,7 +215,7 @@ ocargo.Saving.prototype.retrieveSharedLevels = function (callback, errorCallback
};

ocargo.Saving.prototype.retrieveLevel = function (id, callback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
$.ajax({
url: Urls.load_level_for_editor(id),
type: 'GET',
Expand Down Expand Up @@ -249,7 +249,7 @@ ocargo.Saving.prototype.loadSolution = function (levelID, callback) {
};

ocargo.Saving.prototype.retrieveRandomLevel = function (data, callback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
$.ajax({
url: Urls.generate_random_map_for_editor(),
type: "POST",
Expand All @@ -270,12 +270,12 @@ ocargo.Saving.prototype.retrieveRandomLevel = function (data, callback) {
};

ocargo.Saving.prototype.deleteLevel = function (id, callback, errorCallback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
$.ajax({
url: Urls.delete_level_for_editor(id),
type: 'POST',
dataType: 'json',
data: {csrfmiddlewaretoken: $.cookie('csrftoken')},
data: {csrfmiddlewaretoken: Cookies.get('csrftoken')},
beforeSend: function (xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
Expand All @@ -291,7 +291,7 @@ ocargo.Saving.prototype.deleteLevel = function (id, callback, errorCallback) {
};

ocargo.Saving.prototype.saveLevel = function (level, id, anonymous, callback, errorCallback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
level.anonymous = anonymous;
$.ajax({
url: (id ? Urls.save_level_for_editor(id) : Urls.save_level_for_editor()),
Expand All @@ -314,7 +314,7 @@ ocargo.Saving.prototype.saveLevel = function (level, id, anonymous, callback, er
};

ocargo.Saving.prototype.getSharingInformation = function (levelID, callback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
$.ajax({
url: Urls.get_sharing_information_for_editor(levelID),
type: 'GET',
Expand All @@ -334,7 +334,7 @@ ocargo.Saving.prototype.getSharingInformation = function (levelID, callback) {
};

ocargo.Saving.prototype.shareLevel = function (levelID, recipientData, callback) {
csrftoken = $.cookie('csrftoken');
csrftoken = Cookies.get('csrftoken');
$.ajax({
url: Urls.share_level_for_editor(levelID),
type: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion game/templates/game/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h4>Rapid router has been created to teach the first principles of computer prog

{% block scripts %}
{{block.super}}
<script type='text/javascript' src='{% static 'game/js/foundation/vendor/jquery.cookie.js' %}'></script>
<script type='text/javascript' src='{% static 'game/js/foundation/vendor/js.cookie.min.js' %}'></script>
<script type='text/javascript' src='{% url 'js-reverse' %}'></script>
<script type='text/javascript' src='{% url 'rapid-router/javascript-catalog' %}'></script>
<script type='text/javascript' src='{% static 'game/js/jquery.touchy.min.js' %}'></script>
Expand Down
2 changes: 1 addition & 1 deletion game/templates/game/basenonav.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h2 id="myModal-title" class="ocargo-modal-title"></h2>

{% block scripts %}
<script type='text/javascript' src="{% static 'game/js/svginnerhtml.js' %}"></script>
<script type='text/javascript' src='{% static 'game/js/foundation/vendor/jquery.cookie.js' %}'></script>
<script type='text/javascript' src='{% static 'game/js/foundation/vendor/js.cookie.min.js' %}'></script>
<script type='text/javascript' src='{% static 'game/js/handlebars.runtime-v4.7.7.js' %}'></script>
<script type='text/javascript' src='{% static 'game/js/templates.js' %}'></script>
<script type='text/javascript' src='{% static 'game/js/button.js' %}'></script>
Expand Down
2 changes: 1 addition & 1 deletion game/templates/game/level_moderation.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script src="{% static 'game/js/jquery.tablesorter.min.js' %}"></script>
<script type="text/javascript" src="{% static 'game/js/saving.js' %}"></script>
<script type="text/javascript" src="{% static 'game/js/level_moderation.js' %}"></script>
<script type="text/javascript" src="{% static 'game/js/foundation/vendor/jquery.cookie.js' %}"></script>
<script type="text/javascript" src="{% static 'game/js/foundation/vendor/js.cookie.min.js' %}"></script>
<script>
var students = {% if students %} true {% else %} false {% endif %};
</script>
Expand Down