From bae3e75ae23f65626354cf822c760a8d9887c3ec Mon Sep 17 00:00:00 2001 From: Matthias Grundmann Date: Mon, 11 Jun 2018 16:43:16 +0200 Subject: [PATCH] Fix minor issues in hint view --- .../js/goatApp/controller/LessonController.js | 3 ++- .../static/js/goatApp/view/HintView.js | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 9 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 11b8279cf..f9bfadf6e 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 @@ -79,6 +79,7 @@ define(['jquery', this.listenTo(this.lessonHintView, 'hints:hideButton', this.onHideHintsButton); this.lessonContentView.navToPage(pageNum); this.lessonHintView.hideHints(); + this.lessonHintView.showFirstHint(); //this.lessonHintView.selectHints(); this.titleView.render(this.lessonInfoModel.get('lessonTitle')); return; @@ -160,7 +161,7 @@ define(['jquery', } // this.lessonHintView.render(); - if (this.lessonHintView.getHintsCount > 0) { + if (this.lessonHintView.getHintsCount() > 0) { this.helpControlsView.showHintsButton(); } else { this.helpControlsView.hideHintsButton(); 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 f8b4a2159..a1d83ef89 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 @@ -32,21 +32,19 @@ function($, toggleLabel: function() { if (this.isVisible()) { - $('show-hints-button').text('Hide hints'); + $('#show-hints-button').text('Hide hints'); } else { - $('show-hints-button').text('Show hints'); + $('#show-hints-button').text('Show hints'); } }, render:function() { if (this.isVisible()) { - this.$el.hide(350); + this.$el.hide(350, this.toggleLabel.bind(this)); } else if (this.hintsToShow.length > 0) { - this.$el.show(350); + this.$el.show(350, this.toggleLabel.bind(this)); } - this.toggleLabel() - if (this.hintsToShow.length > 0) { this.hideShowPrevNextButtons(); } @@ -90,9 +88,9 @@ function($, hideHints: function() { if (this.$el.is(':visible')) { - this.$el.hide(350); + this.$el.hide(350, this.toggleLabel.bind(this)); } - }, + }, showNextHint: function() { this.curHint = (this.curHint < this.hintsToShow.length -1) ? this.curHint+1 : this.curHint; @@ -106,6 +104,12 @@ function($, this.displayHint(this.curHint); }, + showFirstHint: function() { + this.curHint = 0; + this.hideShowPrevNextButtons(); + this.displayHint(this.curHint); + }, + displayHint: function(curHint) { if(this.hintsToShow.length == 0) { // this.hideHints();