Skip to content

Commit 5bd348f

Browse files
committed
Merge pull request WebGoat#153 from misfir3/master
WebGoat#133 hiding hint on change of lesson/loesson load
2 parents e530be6 + 539985c commit 5bd348f

5 files changed

Lines changed: 19 additions & 19 deletions

File tree

webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ define(['jquery',
5252
};
5353

5454
this.loadLesson = function(scr,menu,stage,num) {
55-
console.log("Loading a lesson, scr: " + scr + ", menu: " + menu + ", stage: " + stage + ", num: " + num);
5655
this.titleView = new TitleView();
5756
this.helpsLoaded = {};
5857
if (typeof(scr) == "undefined") {
@@ -85,7 +84,6 @@ define(['jquery',
8584
};
8685

8786
this.onInfoLoaded = function() {
88-
console.log("Lesson info loaded")
8987
this.helpControlsView = new HelpControlsView({
9088
hasPlan:this.lessonInfoModel.get('hasPlan'),
9189
hasSolution:this.lessonInfoModel.get('hasSolution'),
@@ -105,7 +103,6 @@ define(['jquery',
105103
};
106104

107105
this.onContentLoaded = function(loadHelps) {
108-
console.log("Lesson content loaded")
109106
this.lessonInfoModel = new LessonInfoModel();
110107
this.listenTo(this.lessonInfoModel,'info:loaded',this.onInfoLoaded);
111108

webgoat-container/src/main/webapp/js/goatApp/support/GoatUtils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ define(['jquery',
1212
//var id =
1313
return lessonName.replace(/\s|\(|\)|\!|\:|\;|\@|\#|\$|\%|\^|\&|\*/g, '');
1414
},
15+
1516
addMenuClasses: function(arr) {
1617
for (var i = 0; i < arr.length; i++) {
1718
var menuItem = arr[i];
@@ -46,7 +47,8 @@ define(['jquery',
4647
if (show) {
4748
$('#' + id).show();
4849
} else {
49-
a }
50+
51+
}
5052
}
5153
},
5254

webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ define(['jquery',
4040
goatRouter.on('route:attackRoute', function(scr,menu,stage,num) {
4141
this.lessonController.loadLesson(scr,menu,stage,num);
4242
this.menuController.updateMenu(scr,menu);
43-
//update menu
4443
});
4544
goatRouter.on('route:welcomeRoute', function() {
4645
this.lessonController.loadWelcome();
4746
});
4847
goatRouter.on("route", function(route, params) {
49-
console.log("Got a route event: " + route + ", params: " + params);
48+
5049
});
5150

5251
Backbone.history.start();

webgoat-container/src/main/webapp/js/goatApp/view/HintView.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function($,
1616
this.curHint=0;
1717
this.collection = new HintCollection();
1818
this.listenTo(this.collection,'loaded',this.onModelLoaded);
19-
19+
this.hideHints();
2020
},
2121

2222
render:function() {
@@ -37,6 +37,12 @@ function($,
3737
this.trigger('hints:loaded',{'helpElement':'hints','value':true})
3838
},
3939

40+
hideHints: function() {
41+
if (this.$el.is(':visible')) {
42+
this.$el.hide(350);
43+
}
44+
},
45+
4046
showNextHint: function() {
4147
this.curHint = (this.curHint < this.collection.length -1) ? this.curHint+1 : this.curHint;
4248
this.hideShowPrevNextButtons();

webgoat-container/src/main/webapp/js/goatApp/view/MenuView.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ define(['jquery',
5050

5151
catLink.append(catArrow);
5252
catLink.append(catLinkText);
53-
//TODO: refactor this along with sub-views/components
5453
var self = this;
5554
catLink.click(_.bind(this.expandCategory,this,catId));
5655
category.append(catLink);
@@ -62,12 +61,12 @@ define(['jquery',
6261
for (var j=0; j < lessons.length;j++) {
6362
var lessonItem = $('<li>',{class:'lesson'});
6463
var lessonName = lessons[j].name;
65-
var lessonId = GoatUtils.makeId(lessonName);
64+
var lessonId = catId + '-' + GoatUtils.makeId(lessonName);
6665
if (this.curLessonLinkId === lessonId) {
6766
lessonItem.addClass('selected');
6867
}
6968
var lessonLink = $('<a>',{href:lessons[j].link,text:lessonName,id:lessonId});
70-
lessonLink.click(_.bind(this.onLessonClick,this,lessonName));
69+
lessonLink.click(_.bind(this.onLessonClick,this,lessonId));
7170
lessonItem.append(lessonLink);
7271
//check for lab/stages
7372
categoryLessonList.append(lessonItem);
@@ -78,12 +77,12 @@ define(['jquery',
7877
for (k=0; k < stages.length; k++) {
7978
var stageItem = $('<li>',{class:'stage'});
8079
var stageName = stages[k].name;
81-
var stageId = GoatUtils.makeId(stageName);
80+
var stageId = lessonId + '-stage' + k;
8281
if (this.curLessonLinkId === stageId) {
8382
stageItem.addClass('selected');
8483
}
8584
var stageLink = $('<a>',{href:stages[k].link,text:stageName,id:stageId});
86-
stageLink.click(_.bind(this.onLessonClick,this,stageName));
85+
stageLink.click(_.bind(this.onLessonClick,this,stageId));
8786
stageItem.append(stageLink);
8887
categoryLessonList.append(stageItem);
8988
if (stages[k].complete) {
@@ -108,14 +107,11 @@ define(['jquery',
108107
this.collection.fetch();
109108
},
110109

111-
onLessonClick: function (title) {
112-
var oldLinkId = GoatUtils.makeId(this.curLessonLinkId);
113-
$('#'+oldLinkId).removeClass('selected');
110+
onLessonClick: function (elementId) {
111+
$('#'+this.curLessonLinkId).removeClass('selected');
114112
//update
115-
this.curLessonLinkId = GoatUtils.makeId(title);
116-
var newLinkId = GoatUtils.makeId(this.curLessonLinkId)
117-
$('#'+newLinkId).addClass('selected');
118-
this.trigger('lesson:click', title); // will cause menu reload
113+
$('#'+elementId).addClass('selected');
114+
this.curLessonLinkId = elementId;
119115
},
120116

121117
expandCategory: function (id) {

0 commit comments

Comments
 (0)