Move jquery .load() to fetch

This commit is contained in:
Marwin Hochfelsner 2025-02-28 00:28:29 +01:00
parent a19ee80c1e
commit 8a52344b29
3 changed files with 16 additions and 7 deletions

View file

@ -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() {

View file

@ -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");
});
}
});

View file

@ -210,10 +210,10 @@ $(document).ready(function () {
});
$("input[name=legale]").change(function () {
const url = $(this).data("url");
$("#contributorTerms").html("<div class='spinner-border' role='status'><span class='visually-hidden'>" + I18n.t("browse.start_rjs.loading") + "</span></div>");
$("#contributorTerms").load(url);
fetch($(this).data("url"))
.then(r => r.text())
.then(html => { $("#contributorTerms").html(html); });
});
$("#read_ct").on("click", function () {