From 32210183be026e1541bf097599ed64dd598a84ce Mon Sep 17 00:00:00 2001 From: Dioni Zhong Date: Tue, 4 May 2021 17:05:11 +0100 Subject: [PATCH 1/2] fix: update jquery.cookie to js.cookie --- game/static/game/js/event.js | 14 ------------- .../js/foundation/vendor/jquery.cookie.js | 8 -------- .../js/foundation/vendor/js.cookie.min.js | 3 +++ game/static/game/js/game.js | 6 +++--- game/static/game/js/saving.js | 20 +++++++++---------- game/templates/game/base.html | 2 +- game/templates/game/basenonav.html | 2 +- game/templates/game/level_moderation.html | 2 +- 8 files changed, 19 insertions(+), 38 deletions(-) delete mode 100644 game/static/game/js/foundation/vendor/jquery.cookie.js create mode 100644 game/static/game/js/foundation/vendor/js.cookie.min.js diff --git a/game/static/game/js/event.js b/game/static/game/js/event.js index 686ecfe73..2a3b76bc6 100644 --- a/game/static/game/js/event.js +++ b/game/static/game/js/event.js @@ -41,20 +41,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() { ocargo.event = new ocargo.Event(); }); diff --git a/game/static/game/js/foundation/vendor/jquery.cookie.js b/game/static/game/js/foundation/vendor/jquery.cookie.js deleted file mode 100644 index 9abcdeced..000000000 --- a/game/static/game/js/foundation/vendor/jquery.cookie.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * jQuery Cookie Plugin v1.4.1 - * https://github.com/carhartl/jquery-cookie - * - * Copyright 2013 Klaus Hartl - * Released under the MIT license - */ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}}); diff --git a/game/static/game/js/foundation/vendor/js.cookie.min.js b/game/static/game/js/foundation/vendor/js.cookie.min.js new file mode 100644 index 000000000..f5f4c36c1 --- /dev/null +++ b/game/static/game/js/foundation/vendor/js.cookie.min.js @@ -0,0 +1,3 @@ +/*! js-cookie v2.2.1 | MIT */ + +!function(a){var b;if("function"==typeof define&&define.amd&&(define(a),b=!0),"object"==typeof exports&&(module.exports=a(),b=!0),!b){var c=window.Cookies,d=window.Cookies=a();d.noConflict=function(){return window.Cookies=c,d}}}(function(){function a(){for(var a=0,b={};aRapid router has been created to teach the first principles of computer prog {% block scripts %} {{block.super}} - + diff --git a/game/templates/game/basenonav.html b/game/templates/game/basenonav.html index 7f00bd83c..70e04a055 100644 --- a/game/templates/game/basenonav.html +++ b/game/templates/game/basenonav.html @@ -57,7 +57,7 @@

{% block scripts %} - + diff --git a/game/templates/game/level_moderation.html b/game/templates/game/level_moderation.html index f56a79239..745c3b076 100644 --- a/game/templates/game/level_moderation.html +++ b/game/templates/game/level_moderation.html @@ -9,7 +9,7 @@ - + From a6274ac3818fb338d19e916aff0857acc74cb802 Mon Sep 17 00:00:00 2001 From: Dioni Zhong Date: Wed, 5 May 2021 11:44:55 +0100 Subject: [PATCH 2/2] put back function, or the tests would time out --- game/static/game/js/event.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/game/static/game/js/event.js b/game/static/game/js/event.js index 2a3b76bc6..69823af9c 100644 --- a/game/static/game/js/event.js +++ b/game/static/game/js/event.js @@ -41,6 +41,9 @@ var ocargo = ocargo || {}; ocargo.Event = function() {}; +ocargo.Event.prototype.sendEvent = function(eventType, details) { +}; + $(document).ready(function() { ocargo.event = new ocargo.Event(); });