From 57965973dc075817dbcce69d1815d4d8bc8592b7 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 18 Jun 2022 13:27:00 +1000 Subject: [PATCH] make guided tour cancel button DRY Move cancel button function into a separate JS file. The selector JS for this function cannot be within bookwyrm.js because the guided tour elements load after bookwyrm.js. --- bookwyrm/static/js/guided_tour.js | 17 + bookwyrm/templates/guided_tour/group.html | 30 +- bookwyrm/templates/guided_tour/home.html | 359 +++++++++--------- .../templates/guided_tour/user_groups.html | 15 +- .../templates/guided_tour/user_profile.html | 252 ++++++------ bookwyrm/templates/layout.html | 1 + 6 files changed, 326 insertions(+), 348 deletions(-) create mode 100644 bookwyrm/static/js/guided_tour.js diff --git a/bookwyrm/static/js/guided_tour.js b/bookwyrm/static/js/guided_tour.js new file mode 100644 index 000000000..7c9d9a7f1 --- /dev/null +++ b/bookwyrm/static/js/guided_tour.js @@ -0,0 +1,17 @@ +/** + * Set guided tour user value to False + * @param {csrf_token} string + * @return {undefined} + */ + +function disableGuidedTour(csrf_token) { + console.log(csrf_token); + fetch('/guided-tour/False', { + headers: { + 'X-CSRFToken': csrf_token, + }, + method: 'POST', + redirect: 'follow', + mode: 'same-origin', + }) +} diff --git a/bookwyrm/templates/guided_tour/group.html b/bookwyrm/templates/guided_tour/group.html index 619c48929..68d4e7759 100644 --- a/bookwyrm/templates/guided_tour/group.html +++ b/bookwyrm/templates/guided_tour/group.html @@ -1,21 +1,19 @@ {% load i18n %} {% csrf_token %} + + + diff --git a/bookwyrm/templates/guided_tour/user_groups.html b/bookwyrm/templates/guided_tour/user_groups.html index 1eebe2a09..603bc53b6 100644 --- a/bookwyrm/templates/guided_tour/user_groups.html +++ b/bookwyrm/templates/guided_tour/user_groups.html @@ -1,19 +1,6 @@ {% load i18n %} -{% csrf_token %} diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index 0155c6650..9c99eb7fa 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -225,6 +225,7 @@ + {% block scripts %}{% endblock %}