From d6f08d37069a03d488c49b9bbd6df7c8bdbb45fe Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Fri, 14 Dec 2018 17:53:25 +0100 Subject: [PATCH] core: use pure js to get cookie in markdown input --- core/templates/core/markdown_textarea.jinja | 25 ++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/core/templates/core/markdown_textarea.jinja b/core/templates/core/markdown_textarea.jinja index 495a1c61..5efaf0d3 100644 --- a/core/templates/core/markdown_textarea.jinja +++ b/core/templates/core/markdown_textarea.jinja @@ -15,23 +15,22 @@ // You can't get the csrf token from the template in a widget // We get it from a cookie as a workaround, see this link // https://docs.djangoproject.com/en/2.0/ref/csrf/#ajax - function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie !== '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) === (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } + function getCookie(cname) { + var name = cname + "="; + var decodedCookie = decodeURIComponent(document.cookie); + var ca = decodedCookie.split(';'); + for(var i = 0; i