From d4af09c72a2ab9cfd267f66379f037aa557a7b13 Mon Sep 17 00:00:00 2001 From: Jason White Date: Wed, 2 Dec 2015 14:05:22 -0500 Subject: [PATCH 1/3] #133 hiding hint on change of lesson/loesson load --- .../src/main/webapp/js/goatApp/view/HintView.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webgoat-container/src/main/webapp/js/goatApp/view/HintView.js b/webgoat-container/src/main/webapp/js/goatApp/view/HintView.js index a9bc57f8d..cbe18e601 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/HintView.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/HintView.js @@ -16,7 +16,7 @@ function($, this.curHint=0; this.collection = new HintCollection(); this.listenTo(this.collection,'loaded',this.onModelLoaded); - + this.hideHints(); }, render:function() { @@ -37,6 +37,12 @@ function($, this.trigger('hints:loaded',{'helpElement':'hints','value':true}) }, + hideHints: function() { + if (this.$el.is(':visible')) { + this.$el.hide(350); + } + }, + showNextHint: function() { this.curHint = (this.curHint < this.collection.length -1) ? this.curHint+1 : this.curHint; this.hideShowPrevNextButtons(); From 0628a27b34ceeb41a695ac6681ce941901f886e2 Mon Sep 17 00:00:00 2001 From: Jason White Date: Wed, 2 Dec 2015 15:06:10 -0500 Subject: [PATCH 2/3] clean up --- .../src/main/webapp/js/goatApp/controller/LessonController.js | 3 --- .../src/main/webapp/js/goatApp/support/GoatUtils.js | 4 +++- .../src/main/webapp/js/goatApp/view/GoatRouter.js | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js b/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js index e26d7bc0e..43964bbe4 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js +++ b/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js @@ -52,7 +52,6 @@ define(['jquery', }; this.loadLesson = function(scr,menu,stage,num) { - console.log("Loading a lesson, scr: " + scr + ", menu: " + menu + ", stage: " + stage + ", num: " + num); this.titleView = new TitleView(); this.helpsLoaded = {}; if (typeof(scr) == "undefined") { @@ -85,7 +84,6 @@ define(['jquery', }; this.onInfoLoaded = function() { - console.log("Lesson info loaded") this.helpControlsView = new HelpControlsView({ hasPlan:this.lessonInfoModel.get('hasPlan'), hasSolution:this.lessonInfoModel.get('hasSolution'), @@ -105,7 +103,6 @@ define(['jquery', }; this.onContentLoaded = function(loadHelps) { - console.log("Lesson content loaded") this.lessonInfoModel = new LessonInfoModel(); this.listenTo(this.lessonInfoModel,'info:loaded',this.onInfoLoaded); diff --git a/webgoat-container/src/main/webapp/js/goatApp/support/GoatUtils.js b/webgoat-container/src/main/webapp/js/goatApp/support/GoatUtils.js index a41586a53..f5bad1c6d 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/support/GoatUtils.js +++ b/webgoat-container/src/main/webapp/js/goatApp/support/GoatUtils.js @@ -12,6 +12,7 @@ define(['jquery', //var id = return lessonName.replace(/\s|\(|\)|\!|\:|\;|\@|\#|\$|\%|\^|\&|\*/g, ''); }, + addMenuClasses: function(arr) { for (var i = 0; i < arr.length; i++) { var menuItem = arr[i]; @@ -46,7 +47,8 @@ define(['jquery', if (show) { $('#' + id).show(); } else { -a } + + } } }, diff --git a/webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js b/webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js index b95167123..2c6cb502a 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js @@ -40,13 +40,12 @@ define(['jquery', goatRouter.on('route:attackRoute', function(scr,menu,stage,num) { this.lessonController.loadLesson(scr,menu,stage,num); this.menuController.updateMenu(scr,menu); - //update menu }); goatRouter.on('route:welcomeRoute', function() { this.lessonController.loadWelcome(); }); goatRouter.on("route", function(route, params) { - console.log("Got a route event: " + route + ", params: " + params); + }); Backbone.history.start(); From 539985c59eee5e1ab1c51deecad0af099a19068f Mon Sep 17 00:00:00 2001 From: Jason White Date: Wed, 2 Dec 2015 15:08:32 -0500 Subject: [PATCH 3/3] #45 finally won't see two 'Stored XSS lessons hightlighted --- .../main/webapp/js/goatApp/view/MenuView.js | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/webgoat-container/src/main/webapp/js/goatApp/view/MenuView.js b/webgoat-container/src/main/webapp/js/goatApp/view/MenuView.js index f9ecf1177..005402ab4 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/MenuView.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/MenuView.js @@ -50,7 +50,6 @@ define(['jquery', catLink.append(catArrow); catLink.append(catLinkText); - //TODO: refactor this along with sub-views/components var self = this; catLink.click(_.bind(this.expandCategory,this,catId)); category.append(catLink); @@ -62,12 +61,12 @@ define(['jquery', for (var j=0; j < lessons.length;j++) { var lessonItem = $('
  • ',{class:'lesson'}); var lessonName = lessons[j].name; - var lessonId = GoatUtils.makeId(lessonName); + var lessonId = catId + '-' + GoatUtils.makeId(lessonName); if (this.curLessonLinkId === lessonId) { lessonItem.addClass('selected'); } var lessonLink = $('',{href:lessons[j].link,text:lessonName,id:lessonId}); - lessonLink.click(_.bind(this.onLessonClick,this,lessonName)); + lessonLink.click(_.bind(this.onLessonClick,this,lessonId)); lessonItem.append(lessonLink); //check for lab/stages categoryLessonList.append(lessonItem); @@ -78,12 +77,12 @@ define(['jquery', for (k=0; k < stages.length; k++) { var stageItem = $('
  • ',{class:'stage'}); var stageName = stages[k].name; - var stageId = GoatUtils.makeId(stageName); + var stageId = lessonId + '-stage' + k; if (this.curLessonLinkId === stageId) { stageItem.addClass('selected'); } var stageLink = $('',{href:stages[k].link,text:stageName,id:stageId}); - stageLink.click(_.bind(this.onLessonClick,this,stageName)); + stageLink.click(_.bind(this.onLessonClick,this,stageId)); stageItem.append(stageLink); categoryLessonList.append(stageItem); if (stages[k].complete) { @@ -108,14 +107,11 @@ define(['jquery', this.collection.fetch(); }, - onLessonClick: function (title) { - var oldLinkId = GoatUtils.makeId(this.curLessonLinkId); - $('#'+oldLinkId).removeClass('selected'); + onLessonClick: function (elementId) { + $('#'+this.curLessonLinkId).removeClass('selected'); //update - this.curLessonLinkId = GoatUtils.makeId(title); - var newLinkId = GoatUtils.makeId(this.curLessonLinkId) - $('#'+newLinkId).addClass('selected'); - this.trigger('lesson:click', title); // will cause menu reload + $('#'+elementId).addClass('selected'); + this.curLessonLinkId = elementId; }, expandCategory: function (id) {