From 8a52344b29cad04045fc59642b7cf5c7f6b53ca8 Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Fri, 28 Feb 2025 00:28:29 +0100 Subject: [PATCH] Move jquery .load() to fetch --- app/assets/javascripts/leaflet.key.js | 5 ++++- app/assets/javascripts/richtext.js | 12 +++++++++--- app/assets/javascripts/user.js | 6 +++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js index 937d9b052..45d22feed 100644 --- a/app/assets/javascripts/leaflet.key.js +++ b/app/assets/javascripts/leaflet.key.js @@ -16,7 +16,10 @@ L.OSM.key = function (options) { function shown() { map.on("zoomend baselayerchange", update); - $section.load("/key", update); + fetch("/key") + .then(r => r.text()) + .then(html => { $section.html(html); }) + .then(update); } function hidden() { diff --git a/app/assets/javascripts/richtext.js b/app/assets/javascripts/richtext.js index eb13392eb..d4b59cadc 100644 --- a/app/assets/javascripts/richtext.js +++ b/app/assets/javascripts/richtext.js @@ -36,9 +36,15 @@ if (preview.children(".richtext").contents().length === 0) { preview.children(".richtext_placeholder").removeAttr("hidden").addClass("delayed-fade-in"); - preview.children(".richtext").load(editor.data("previewUrl"), { text: editor.val() }, function () { - preview.children(".richtext_placeholder").attr("hidden", true).removeClass("delayed-fade-in"); - }); + fetch(editor.data("previewUrl"), { + method: "POST", + body: new URLSearchParams({ text: editor.val(), ...OSM.csrf }) + }) + .then(r => r.text()) + .then(html => { + preview.children(".richtext").html(html); + preview.children(".richtext_placeholder").attr("hidden", true).removeClass("delayed-fade-in"); + }); } }); diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 2af9e18cb..9d225a859 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -210,10 +210,10 @@ $(document).ready(function () { }); $("input[name=legale]").change(function () { - const url = $(this).data("url"); - $("#contributorTerms").html("