Self hosted FLOSS fitness/workout, nutrition and weight tracker
Simplify the toggle_comments function
Roland Geider931c98b44169
diff --git a/wger/core/static/js/workout-manager.js b/wger/core/static/js/workout-manager.jsindex 4fd5f84ab..5351345b7 100644--- a/wger/core/static/js/workout-manager.js+++ b/wger/core/static/js/workout-manager.js@@ -188,16 +188,15 @@ function toggle_comments() {$("#exercise-comments-toggle").click(function (e) {e.preventDefault();- if (showComment === 0) {+ var showComment = get_profile_field('show_comments');+ if(!showComment) {$('.exercise-comments').show();- showComment = 1;- } else if (showComment === 1) {+ } else {$('.exercise-comments').hide();- showComment = 0;}// Update user profile- set_profile_field('show_comments', showComment);+ set_profile_field('show_comments', !showComment);});}diff --git a/wger/manager/templates/mobile/workout/view.html b/wger/manager/templates/mobile/workout/view.htmlindex 5f5eeafdc..7ff3edc1d 100644--- a/wger/manager/templates/mobile/workout/view.html+++ b/wger/manager/templates/mobile/workout/view.html@@ -19,13 +19,11 @@ $(document).ready(function() {* Show/Hide the comments to the exercises*/{% if user.userprofile.show_comments %}- showComment = 1;$(".exercise-comments").show();{% else %}- showComment = 0;$(".exercise-comments").hide();{% endif %}- toggle_comments();+ toggle_comments();});</script>diff --git a/wger/manager/templates/workout/view.html b/wger/manager/templates/workout/view.htmlindex ca05355b1..48413a2bb 100644--- a/wger/manager/templates/workout/view.html+++ b/wger/manager/templates/workout/view.html@@ -19,10 +19,8 @@ $(document).ready(function() {// Show/Hide the comments to the exercises{% if user.userprofile.show_comments %}- showComment = 1;- $(".exercise-comments").show();+ $(".exercise-comments").show();{% else %}- showComment = 0;$(".exercise-comments").hide();{% endif %}toggle_comments();