From c972d23561f606e51a15f540f3d899c39013078a Mon Sep 17 00:00:00 2001 From: Yam Mesicka Date: Sat, 6 Apr 2024 05:48:16 +0300 Subject: [PATCH] fix: Share view bugs (#390) * fix: Prevent adblock killing share buttons * fix: Order of execution bug in firing events --- lms/static/shared.js | 3 +++ lms/static/solution.js | 2 +- lms/templates/view.html | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 lms/static/shared.js diff --git a/lms/static/shared.js b/lms/static/shared.js new file mode 100644 index 00000000..4f65118f --- /dev/null +++ b/lms/static/shared.js @@ -0,0 +1,3 @@ +window.addEventListener('load', () => { + window.dispatchEvent(new Event('defined-window-variables')); +}); diff --git a/lms/static/solution.js b/lms/static/solution.js index 31948b06..e2ca4a88 100644 --- a/lms/static/solution.js +++ b/lms/static/solution.js @@ -34,4 +34,4 @@ function addLineSpansToPre(items) { window.addEventListener('defined-window-variables', () => { addLineSpansToPre(document.getElementsByTagName('code')); -}); +}, { once: true }); diff --git a/lms/templates/view.html b/lms/templates/view.html index c04c0de3..6642f0ae 100644 --- a/lms/templates/view.html +++ b/lms/templates/view.html @@ -61,8 +61,8 @@

{{ _('Exercise view') }} {{ solution['exercise']['number'] }}: {{ solution['
- - + +
@@ -151,7 +151,9 @@

{{ _('Comments for this exercise') }}

-{% if not shared_url %} +{% if shared_url %} + +{% else %} {% include 'comment-template.html' %}