From 58ae7f3727fc2bba4d3f3e9362dfdb728d81b0dd Mon Sep 17 00:00:00 2001 From: Daniel Kvist Date: Thu, 31 Mar 2016 22:56:17 +0200 Subject: [PATCH] Move loading of developer controls so they do not reload every time. Also reload current lesson after reloading labels. Ref webgoat/webgoat#93. --- .../webapp/js/goatApp/controller/LessonController.js | 3 --- .../webapp/js/goatApp/view/DeveloperControlsView.js | 2 +- .../src/main/webapp/js/goatApp/view/GoatRouter.js | 11 +++++++---- 3 files changed, 8 insertions(+), 8 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 0276fd79d..318127936 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js +++ b/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js @@ -11,7 +11,6 @@ define(['jquery', 'goatApp/view/CookieView', 'goatApp/view/ParamView', 'goatApp/model/ParamModel', - 'goatApp/view/DeveloperControlsView', 'goatApp/support/GoatUtils', 'goatApp/view/UserAndInfoView', 'goatApp/view/MenuButtonView', @@ -31,7 +30,6 @@ define(['jquery', CookieView, ParamView, ParamModel, - DeveloperControlsView, GoatUtils, UserAndInfoView, MenuButtonView, @@ -118,7 +116,6 @@ define(['jquery', this.sourceView = new SourceView(); this.lessonHintView = new HintView(); this.cookieView = new CookieView(); - this.developerControlsView = new DeveloperControlsView(); //TODO: instantiate model with values (not sure why was not working before) var paramModel = new ParamModel({}); diff --git a/webgoat-container/src/main/webapp/js/goatApp/view/DeveloperControlsView.js b/webgoat-container/src/main/webapp/js/goatApp/view/DeveloperControlsView.js index 1230113b6..ddd8b9f2d 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/DeveloperControlsView.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/DeveloperControlsView.js @@ -22,9 +22,9 @@ function( }, onLabelsLoaded: function(model) { - $('#' + model.id).find('td').text('Enabled: ' + model.enabled); this.models[1] = model; this.render(); + Backbone.history.loadUrl(Backbone.history.getFragment()); }, initialize: function(options) { 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 2c6cb502a..1d9e7ad94 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/GoatRouter.js @@ -4,17 +4,20 @@ define(['jquery', 'goatApp/controller/LessonController', 'goatApp/controller/MenuController', 'goatApp/view/LessonContentView', - 'goatApp/view/MenuView' + 'goatApp/view/MenuView', + 'goatApp/view/DeveloperControlsView' ], function ($, _, Backbone, LessonController, MenuController, LessonContentView, - MenuView) { + MenuView, + DeveloperControlsView) { var lessonView = new LessonContentView(); var menuView = new MenuView(); + var developerControlsView = new DeveloperControlsView(); var GoatAppRouter = Backbone.Router.extend({ routes: { @@ -25,11 +28,11 @@ define(['jquery', }, lessonController: new LessonController({ - lessonView:lessonView + lessonView: lessonView }), menuController: new MenuController({ - menuView:menuView + menuView: menuView }), init:function() {