From ab29afec3c6386eb0b536941fce30c6413a57b2f Mon Sep 17 00:00:00 2001 From: Jason White Date: Sat, 24 Oct 2015 13:15:14 -0500 Subject: [PATCH] code cleanup --- .../main/webapp/js/goatApp/controller/LessonController.js | 7 +++---- .../src/main/webapp/js/goatApp/model/LessonInfoModel.js | 3 +-- .../src/main/webapp/js/goatApp/view/LessonContentView.js | 3 +++ .../src/main/webapp/js/goatApp/view/TitleView.js | 1 + 4 files changed, 8 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 94214a97f..1d14179f5 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js +++ b/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js @@ -88,19 +88,18 @@ define(['jquery', this.onContentLoaded = function(loadHelps) { this.lessonInfoModel = new LessonInfoModel(); - this.listenTo(this.lessonInfoModel,'info:loaded',this.onInfoLoaded); //TODO onInfoLoaded function to handle title view and helpview + this.listenTo(this.lessonInfoModel,'info:loaded',this.onInfoLoaded); if (loadHelps) { this.helpControlsView = null; this.lessonView.model = this.lessonContent; this.lessonView.render(); - //load title view (initially hidden) << //TODO: currently handled via menu click but need to be able to handle via routed request + this.planView = new PlanView(); this.solutionView = new SolutionView(); this.sourceView = new SourceView(); this.lessonHintView = new HintView(); this.cookieView = new CookieView(); - // parameter model & view //TODO: instantiate model with values (not sure why was not working before) var paramModel = new ParamModel({}); paramModel.set('screenParam',this.lessonContent.get('screenParam')); @@ -109,7 +108,7 @@ define(['jquery', this.paramView = new ParamView({model:paramModel}); $('.lesson-help').hide(); - } + } this.trigger('menu:reload'); }; diff --git a/webgoat-container/src/main/webapp/js/goatApp/model/LessonInfoModel.js b/webgoat-container/src/main/webapp/js/goatApp/model/LessonInfoModel.js index edbf3daff..83419e336 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/model/LessonInfoModel.js +++ b/webgoat-container/src/main/webapp/js/goatApp/model/LessonInfoModel.js @@ -13,9 +13,8 @@ define(['jquery', }, infoLoaded: function(data) { - console.log (data); this.trigger('info:loaded',this,data); } }); -}); \ No newline at end of file +});6 \ No newline at end of file diff --git a/webgoat-container/src/main/webapp/js/goatApp/view/LessonContentView.js b/webgoat-container/src/main/webapp/js/goatApp/view/LessonContentView.js index 26e3c507d..94d5176bc 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/LessonContentView.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/LessonContentView.js @@ -10,15 +10,18 @@ define(['jquery', JQueryForm) { return Backbone.View.extend({ el:'#lesson-content-wrapper', //TODO << get this fixed up in DOM + initialize: function(options) { options = options || {}; }, + render: function() { this.$el.html(this.model.get('content')); this.makeFormsAjax(); this.ajaxifyAttackHref(); $(window).scrollTop(0); //work-around til we get the scroll down sorted out }, + //TODO: reimplement this in custom fashion maybe? makeFormsAjax: function () { var options = { diff --git a/webgoat-container/src/main/webapp/js/goatApp/view/TitleView.js b/webgoat-container/src/main/webapp/js/goatApp/view/TitleView.js index 5df9353f0..f1698b9ec 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/view/TitleView.js +++ b/webgoat-container/src/main/webapp/js/goatApp/view/TitleView.js @@ -4,6 +4,7 @@ define(['jquery', function($,_,Backbone) { return Backbone.View.extend({ el:'#header #lesson-title-wrapper', + render:function(title) { var lessonTitleEl = $('

',{id:'lesson-title',text:title}); this.$el.html(lessonTitleEl);