From 1351f0e6a2117f5d969aa725644e844291ab07e1 Mon Sep 17 00:00:00 2001 From: Jason White Date: Thu, 13 Aug 2015 21:46:13 -0400 Subject: [PATCH] cookie view re-enabled --- .../main/webapp/WEB-INF/pages/main_new.jsp | 17 ++-------- .../src/main/webapp/css/main.css | 2 +- .../js/goatApp/controller/LessonController.js | 3 ++ .../goatApp/model/LessonCookieCollection.js | 13 ++++++++ .../js/goatApp/model/LessonCookieModel.js | 9 +++++ .../main/webapp/js/goatApp/view/CookieView.js | 33 +++++++++++++++++++ 6 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 webgoat-container/src/main/webapp/js/goatApp/model/LessonCookieCollection.js create mode 100644 webgoat-container/src/main/webapp/js/goatApp/model/LessonCookieModel.js create mode 100644 webgoat-container/src/main/webapp/js/goatApp/view/CookieView.js diff --git a/webgoat-container/src/main/webapp/WEB-INF/pages/main_new.jsp b/webgoat-container/src/main/webapp/WEB-INF/pages/main_new.jsp index 3448a872e..cf00d7d8b 100644 --- a/webgoat-container/src/main/webapp/WEB-INF/pages/main_new.jsp +++ b/webgoat-container/src/main/webapp/WEB-INF/pages/main_new.jsp @@ -126,23 +126,10 @@
-
+

Cookies

-
-
+

Params

diff --git a/webgoat-container/src/main/webapp/css/main.css b/webgoat-container/src/main/webapp/css/main.css index 1eb57dd5d..ee8e1c71a 100644 --- a/webgoat-container/src/main/webapp/css/main.css +++ b/webgoat-container/src/main/webapp/css/main.css @@ -738,7 +738,7 @@ cookie-container { .cookie-table tr td, .params-table tr td { padding: 3px; - max-width: 200px; + max-width: 220px; font-size: x-small; word-wrap: break-word; } 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 959200343..5b9ce38fc 100644 --- a/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js +++ b/webgoat-container/src/main/webapp/js/goatApp/controller/LessonController.js @@ -8,6 +8,7 @@ define(['jquery', 'goatApp/view/SolutionView', 'goatApp/view/LessonHintView', 'goatApp/view/HelpControlsView', + 'goatApp/view/CookieView', 'goatApp/support/GoatUtils' ], function($, @@ -20,6 +21,7 @@ define(['jquery', SolutionView, LessonHintView, HelpControlsView, + CookieView, GoatUtils ) { 'use strict' @@ -77,6 +79,7 @@ define(['jquery', this.lessonHintView = new LessonHintView(); this.listenToOnce(this.lessonHintView,'hints:loaded',this.areHelpsReady); // + this.cookieView = new CookieView(); this.hideShowHelps(null); }; diff --git a/webgoat-container/src/main/webapp/js/goatApp/model/LessonCookieCollection.js b/webgoat-container/src/main/webapp/js/goatApp/model/LessonCookieCollection.js new file mode 100644 index 000000000..9ab2d7aa7 --- /dev/null +++ b/webgoat-container/src/main/webapp/js/goatApp/model/LessonCookieCollection.js @@ -0,0 +1,13 @@ +define(['jquery', + 'underscore', + 'backbone', + 'goatApp/model/LessonCookieModel'], + function($, + _, + Backbone, + LessonCookieModel) { + return Backbone.Collection.extend({ + url:'service/cookie.mvc', + model:LessonCookieModel + }); +}); \ No newline at end of file diff --git a/webgoat-container/src/main/webapp/js/goatApp/model/LessonCookieModel.js b/webgoat-container/src/main/webapp/js/goatApp/model/LessonCookieModel.js new file mode 100644 index 000000000..dcd5f2690 --- /dev/null +++ b/webgoat-container/src/main/webapp/js/goatApp/model/LessonCookieModel.js @@ -0,0 +1,9 @@ +define(['jquery', + 'underscore', + 'backbone'], + function($, + _, + Backbone) { + return Backbone.Model.extend({ + }); +}); \ No newline at end of file diff --git a/webgoat-container/src/main/webapp/js/goatApp/view/CookieView.js b/webgoat-container/src/main/webapp/js/goatApp/view/CookieView.js new file mode 100644 index 000000000..f67cb190c --- /dev/null +++ b/webgoat-container/src/main/webapp/js/goatApp/view/CookieView.js @@ -0,0 +1,33 @@ +define(['jquery', + 'underscore', + 'backbone', + 'goatApp/model/LessonCookieCollection'], +function($, + _, + Backbone, + LessonCookieCollection) { + return Backbone.View.extend({ + el:'#cookies-view', + + initialize: function() { + this.collection = new LessonCookieCollection(); + this.listenTo(this.collection,'reset',this.render) + this.collection.fetch({reset:true}); + }, + + render: function() { + this.$el.html('') + var cookieTable; + this.collection.each(function(model) { + cookieTable = $('',{'class':'cookie-table table-striped table-nonfluid'}); + _.each(model.keys(), function(attribute) { + var newRow = $(''); + newRow.append($('
',{text:_.escape(attribute)})) + newRow.append($('',{text:_.escape(model.get(attribute))})); + cookieTable.append(newRow); + }); + }); + this.$el.append(cookieTable); + } + }); +}); \ No newline at end of file