diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java index 6ba39b4cb..45bfea76f 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java @@ -567,6 +567,7 @@ public abstract class AbstractLesson extends Screen implements Comparable 0), }); this.helpControlsView.render(); - // + this.listenTo(this.helpControlsView,'plan:show',this.hideShowHelps); this.listenTo(this.helpControlsView,'solution:show',this.hideShowHelps); this.listenTo(this.helpControlsView,'hints:show',this.onShowHints) diff --git a/webgoat-container/src/main/webapp/js/goatApp/controller/MenuController.js b/webgoat-container/src/main/webapp/js/goatApp/controller/MenuController.js index a8c154b50..f6da24e3e 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/controller/MenuController.js +++ b/webgoat-container/src/main/webapp/js/goatApp/controller/MenuController.js @@ -1,5 +1,12 @@ -define(['jquery','underscore','backbone','goatApp/view/MenuView'], - function($,_,Backbone,MenuView) { +define(['jquery', + 'underscore', + 'backbone', + 'goatApp/view/MenuView' + ], + function($, + _, + Backbone, + MenuView) { Controller = function(options){ _.extend(Controller.prototype,Backbone.Events); options = options || {}; @@ -10,8 +17,8 @@ define(['jquery','underscore','backbone','goatApp/view/MenuView'], this.listenTo(this.menuView,'lesson:click',this.renderTitle); } - this.updateMenu = function(curLesson) { - + this.updateMenu = function(){ + this.menuView.updateMenu(); }, //TODO: move title rendering into lessonContent/View pipeline once data can support it @@ -19,6 +26,7 @@ define(['jquery','underscore','backbone','goatApp/view/MenuView'], this.titleView.render(title); } + }; return Controller; diff --git a/webgoat-container/src/main/webapp/js/goatApp/model/LessonContentModel.js b/webgoat-container/src/main/webapp/js/goatApp/model/LessonContentModel.js index b0301cd6a..f0f0f1dbe 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/model/LessonContentModel.js +++ b/webgoat-container/src/main/webapp/js/goatApp/model/LessonContentModel.js @@ -16,13 +16,14 @@ define(['jquery', initialize: function (options) { this.screenParam = null; this.menuParam = null; + this.stageParam = null; this.baseUrlRoot = 'attack?Screen='; }, loadData: function(options) { - this.urlRoot = this.baseUrlRoot +options.screen + '&menu=' + options.menu; + this.urlRoot = this.baseUrlRoot +options.screen + '&menu=' + options.menu + '&stage=' + options.stage; this.set('menuParam',options.menu); this.set('screenParam',options.screen); - + this.set('stageParam',options.stage) var self=this; this.fetch().then(function(data) { self.setContent(data); diff --git a/webgoat-container/src/main/webapp/js/goatApp/model/MenuCollection.js b/webgoat-container/src/main/webapp/js/goatApp/model/MenuCollection.js index 6df19033f..709c557f7 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/model/MenuCollection.js +++ b/webgoat-container/src/main/webapp/js/goatApp/model/MenuCollection.js @@ -9,13 +9,21 @@ define(['jquery', url:'service/lessonmenu.mvc', initialize: function () { var self = this; - this.fetch().then(function (data) { - this.models = data; - self.onDataLoaded(); - }); + this.fetch(); }, - onDataLoaded:function() { + + onDataLoaded: function() { this.trigger('menuData:loaded'); + }, + + fetch: function() { + var self=this; + Backbone.Collection.prototype.fetch.apply(this,arguments).then( + function(data) { + this.models = data; + self.onDataLoaded(); + } + ); } }); }); \ No newline at end of file diff --git a/webgoat-container/src/main/webapp/js/goatApp/model/MenuData.js b/webgoat-container/src/main/webapp/js/goatApp/model/MenuData.js index 67708c622..8b57441aa 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/model/MenuData.js +++ b/webgoat-container/src/main/webapp/js/goatApp/model/MenuData.js @@ -30,28 +30,3 @@ var menuData = Backbone.Model.extend({ }); }); - -/* -var menuData = Backbone.Model.extend({ - urlRoot:'/webgoat/service/lessonmenu.mvc', - defaults: { - items:null, - selectedItem:null - }, - initialize: function () { - var self = this; - this.fetch().then(function(menuItems){ - menuItems = goatUtils.enhanceMenuData(menuItems,this.selectedItem); - self.items = menuItems; - }); - }, - - update: function() { - var self = this; - this.fetch().then(function(data) { - self.items = data; - self.render(0); - }); - } - }); -*/ \ No newline at end of file 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 07cf17eb9..8e42fd0eb 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js @@ -16,7 +16,7 @@ define(['jquery', routes: { //#.... 'welcome':'welcomeRoute', - 'attack/:scr/:menu':'attackRoute' // + 'attack/:scr/:menu(/:stage)':'attackRoute' // }, lessonController: new LessonController({ @@ -33,8 +33,8 @@ define(['jquery', this.lessonController.start(); this.menuController.initMenu(); - goatRouter.on('route:attackRoute', function(scr,menu) { - this.lessonController.loadLesson(scr,menu); + goatRouter.on('route:attackRoute', function(scr,menu,stage) { + this.lessonController.loadLesson(scr,menu,stage); this.menuController.updateMenu(scr,menu); //update menu }); @@ -43,11 +43,11 @@ define(['jquery', }); Backbone.history.start(); - this.listenTo(this.menuController, 'menu:reload',this.reloadMenu) + this.listenTo(this.lessonController, 'menu:reload',this.reloadMenu) }, reloadMenu: function (curLesson) { - this.menuController.updateMenu(curLesson); + this.menuController.updateMenu(); } 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 4ed9340ad..ab721d98a 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/MenuView.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/MenuView.js @@ -17,10 +17,11 @@ define(['jquery', initialize: function() { this.collection = new MenuCollection(); this.listenTo(this.collection,'menuData:loaded',this.render); - this.listenTo(this,'menu:click',this.accordionMenu); + // this.listenTo(this,'menu:click',this.accordionMenu); + this.curLessonLinkId = ''; }, // rendering top level menu - render: function (model){ + render: function (){ //for now, just brute force //TODO: refactor into sub-views/components var items, catItems, stages; @@ -47,11 +48,14 @@ define(['jquery', if (lessons) { var categoryLessonList = $('