From 24cf8067875c4b9e2b11dca32119b0ffee2b1518 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 25 Oct 2017 18:05:08 -0600 Subject: [PATCH] more hints/helps cleanup --- .../static/js/goatApp/controller/LessonController.js | 10 ++++++++-- .../main/resources/static/js/goatApp/view/HintView.js | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js b/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js index 216a33897..e692e0beb 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js @@ -102,12 +102,13 @@ define(['jquery', hasSource:this.lessonInfoModel.get('hasSource') }); - this.listenTo(this.helpControlsView,'hints:show',this.showHints); + this.listenTo(this.helpControlsView,'hints:show',this.showHintsView); this.listenTo(this.helpControlsView,'lesson:restart',this.restartLesson); this.listenTo(this.developerControlsView, 'dev:labels', this.restartLesson); this.helpControlsView.render(); + this.showHintsView(); this.titleView.render(this.lessonInfoModel.get('lessonTitle')); }; @@ -180,8 +181,13 @@ define(['jquery', // } // }; - this.showHints = function() { + this.showHintsView = function() { this.lessonHintView.render(); + if (this.lessonHintView.getHintsCount > 0) { + this.helpControlsView.showHintsButton(); + } else { + this.helpControlsView.hideHintsButton(); + } }; this.restartLesson = function() { diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/HintView.js b/webgoat-container/src/main/resources/static/js/goatApp/view/HintView.js index 169185c56..f8b4a2159 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/HintView.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/view/HintView.js @@ -126,6 +126,10 @@ function($, } else { this.$el.find('#show-prev-hint').css('visibility','visible'); } + }, + + getHintsCount: function () { + return this.collection.length; } });