Skip to content

Commit d35f5e0

Browse files
author
Jason White
committed
Cleanup, class added to handle lesson info. Updates for plan,source and solution. Started work on cookies and params, not functioning quite yet
1 parent d414d1a commit d35f5e0

File tree

7 files changed

+318
-115
lines changed

7 files changed

+318
-115
lines changed

src/main/webapp/WEB-INF/pages/main_new.jsp

Lines changed: 78 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<script type="text/javascript" src="js/goatConstants.js"></script>
5151
<script type="text/javascript" src="js/goatUtil.js"></script>
5252
<script type="text/javascript" src="js/goatData.js"></script>
53+
<script type="text/javascript" src="js/goatLesson.js"></script>
5354
<script type="text/javascript" src="js/goatControllers.js"></script>
5455
<!-- end of JS -->
5556

@@ -59,7 +60,7 @@
5960
<title>WebGoat V6.0</title>
6061
</head>
6162

62-
<body class="animated fadeIn" ng-app="goatApp" ng-controller="goatLesson">
63+
<body class="animated fadeIn" ng-app="goatApp">
6364
<section id="container">
6465
<header id="header">
6566
<!--logo start-->
@@ -83,7 +84,7 @@
8384

8485
<!--sidebar left start-->
8586
<aside class="sidebar">
86-
<div id="leftside-navigation" class="nano" >
87+
<div id="leftside-navigation" class="nano" ng-controller="goatLessonMenu">
8788
<ul class="nano-content">
8889
<li class="sub-menu" ng-repeat="item in menuTopics">
8990
<a ng-click="expanded = !expanded" href=""><i class="fa {{item.class}}"></i><span>{{item.name}}</span></a>
@@ -105,15 +106,29 @@
105106
<!--main content start-->
106107
<section class="main-content-wrapper">
107108

108-
<section id="main-content">
109+
<section id="main-content" ng-controller="lessonHelpController">
109110
<div class="row">
110111
<div class="col-md-12">
111112
<div class="panel" id="buttonPanel">
112-
<button type="button" class="btn btn-primary btn-xs">Params/Cookies</button>
113-
<button type="button" class="btn btn-primary btn-xs">Hints</button>
114-
<button type="button" class="btn btn-primary btn-xs">Lesson Plan</button>
115-
<button type="button" class="btn btn-primary btn-xs" ng-click="showSource('lg')">Java [Source]</button>
116-
<button type="button" class="btn btn-primary btn-xs" ng-click="showSolution('lg')">Solution</button>
113+
<button type="button" id="showParamsCookiesBtn" class="btn btn-primary btn-xs" ng-click="viewCookiesAndParams()">Params/Cookies</button>
114+
<button type="button" id="showHintsBtn" class="btn btn-primary btn-xs lessonHelpBtn">Hints</button>
115+
<button type="button" id="showPlanBtn" class="btn btn-primary btn-xs lessonHelpBtn">Lesson Plan</button>
116+
<button type="button" id="showSourceBtn" class="btn btn-primary btn-xs lessonHelpBtn">Java [Source]</button> <!-- ng-click="showSource('lg') -->
117+
<button type="button" id="showSolutionBtn" class="btn btn-primary btn-xs lessonHelpBtn">Solution</button> <!-- ng-click="showSolution('lg') -->
118+
</div>
119+
120+
<div class="panel" id="cookiesAndParams">
121+
<div class="cookiesView">
122+
-- COOKIES GO HERE --
123+
</div>
124+
<div> <!--class="paramsView"-->
125+
-- PARAMS GO HERE -- <br/>
126+
<ul>
127+
<li ng-repeat="param in params">
128+
{{param.name}} = {{param.value}}
129+
</li>
130+
</ul>
131+
</div>
117132
</div>
118133
<div class="panel" >
119134
<div class="panel-body" id="lesson_content">
@@ -122,55 +137,57 @@
122137

123138
</div>
124139
</div>
125-
</div>
126-
<div class="row" id="lesson_cookies_row">
127-
<div class="col-md-12">
128-
<h4>Lesson Parameters and Cookies</h4>
129-
<div class="panel" >
130-
<div class="panel-body" id="lesson_cookies">
131-
132-
</div>
133-
</div>
134-
</div>
135-
</div>
136-
<div class="row" id="lesson_hint_row">
137-
<div class="col-md-12">
138-
<h4>Lesson Hints</h4>
139-
<div class="panel" >
140-
<div class="panel-body" id="lesson_hint">
141-
142-
</div>
143-
</div>
144-
</div>
145-
</div>
146-
<div class="row" id="lesson_plan_row">
147-
<div class="col-md-12">
148-
<h4>Lesson Plan</h4>
149-
<div class="panel" >
150-
<div class="panel-body" id="lesson_plan">
151-
152-
</div>
153-
</div>
154-
</div>
155-
</div>
156-
<div class="row" id="lesson_solution_row">
157-
<div class="col-md-12">
158-
<h4>Lesson Solution</h4>
159-
<div class="panel" >
160-
<div class="panel-body" id="lesson_solution">
161-
</div>
162-
</div>
163-
</div>
164-
</div>
165-
<div class="row" id="lesson_source_row">
166-
<div class="col-md-12">
167-
<h4>Lesson Source Code</h4>
168-
<div class="panel" >
169-
<div class="panel-body" id="lesson_source">
170-
</div>
171-
</div>
172-
</div>
173-
</div>
140+
</div>
141+
<div id="lessonHelpsWrapper">
142+
<div class="row lessonHelp" id="lesson_cookies_row">
143+
<div class="col-md-12">
144+
<h4>Lesson Parameters and Cookies</h4>
145+
<div class="panel" >
146+
<div class="panel-body" id="lesson_cookies">
147+
148+
</div>
149+
</div>
150+
</div>
151+
</div>
152+
<div class="row lessonHelp" id="lesson_hint_row">
153+
<div class="col-md-12">
154+
<h4>Lesson Hints</h4>
155+
<div class="panel" >
156+
<div class="panel-body" id="lesson_hint">
157+
158+
</div>
159+
</div>
160+
</div>
161+
</div>
162+
<div class="row lessonHelp" id="lesson_plan_row">
163+
<div class="col-md-12">
164+
<h4>Lesson Plan</h4>
165+
<div class="panel" >
166+
<div class="panel-body" id="lesson_plan">
167+
168+
</div>
169+
</div>
170+
</div>
171+
</div>
172+
<div class="row lessonHelp" id="lesson_solution_row">
173+
<div class="col-md-12">
174+
<h4>Lesson Solution</h4>
175+
<div class="panel" >
176+
<div class="panel-body" id="lesson_solution">
177+
</div>
178+
</div>
179+
</div>
180+
</div>
181+
<div class="row lessonHelp" id="lesson_source_row">
182+
<div class="col-md-12">
183+
<h4>Lesson Source Code</h4>
184+
<div class="panel" >
185+
<div class="panel-body" id="lesson_source">
186+
</div>
187+
</div>
188+
</div>
189+
</div>
190+
</div>
174191
</section>
175192
</section>
176193

@@ -186,16 +203,17 @@
186203
// set this to true if you want to see form submissions
187204
// set to false once we get all the kinks worked out
188205
var DEBUG_FORM_SUBMISSION = false;
189-
206+
190207
$(document).ready(function() {
191208
// bind to click events on menu links
192-
$('.menu-link').bind('click', function(event) {
209+
/*$('.menu-link').bind('click', function(event) {
193210
event.preventDefault();
194211
$.get(this.href, {}, function(reply) {
195212
$("#lesson_content").html(reply);
196213
goat.utils.showLessonSource();
197214
}, "html");
198-
});
215+
});*/
216+
199217
app.init();
200218
201219
});

src/main/webapp/css/main.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,17 @@ fieldset[disabled] .btn-warning.active {
751751

752752
#topLinks {
753753
float:right;
754-
margin-right:5px;
754+
margin-right:5px;s
755755
margin-top:3px;
756+
}
757+
758+
.lessonHelp, .lessonHelpBtn {
759+
display: none;
760+
}
761+
762+
.paramsView {
763+
float:right;
764+
width 50%;
765+
margin-right:10px;
766+
border-left:2px solid #333;
756767
}

src/main/webapp/js/goatConstants.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ var goatConstants = {
1111
children:null,
1212
class:'fa-bars static'
1313
}],
14+
//services
1415
lessonService: 'service/lessonmenu.mvc',
15-
cookieService: 'service/cookies_widget.mvc',
16-
hintService:'service/hint_widget.mvc',
16+
cookieService: 'service/cookie.mvc', //cookies_widget.mvc
17+
hintService:'service/hint.mvc',
1718
sourceService:'service/source.mvc',
1819
solutionService:'service/solution.mvc',
19-
lessonPlanService:'service/lessonplan.mvc'
20+
lessonPlanService:'service/lessonplan.mvc',
21+
menuService: 'service/lessonmenu.mvc',
22+
paramService: 'service/parms.mvc', //this is a stub .. need to discuss this
23+
// literals
24+
notFound: 'Could not find'
2025
};
2126

27+

src/main/webapp/js/goatControllers.js

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/** Menu Controller
77
* prepares and updates menu topic items for the view
88
*/
9-
goat.controller('goatLesson', function($scope, $http, $modal, $log, $templateCache) {
9+
goat.controller('goatLessonMenu', function($scope, $http, $modal, $log, $templateCache) {
1010
//TODO: implement via separate promise and use config for menu (goat.data.loadMenuData())
1111
$http({method: 'GET', url: goatConstants.lessonService}).then(
1212
function(menuData) {
@@ -19,51 +19,54 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log, $templateCac
1919
}
2020
);
2121
$scope.renderLesson = function(url) {
22-
console.log(url + ' was passed in');
22+
//console.log(url + ' was passed in');
2323
// use jquery to render lesson content to div
2424
goat.data.loadLessonContent(url).then(
2525
function(reply) {
2626
$("#lesson_content").html(reply);
2727
// hook forms
2828
goat.utils.makeFormsAjax();
29+
//render lesson title
2930
$('#lessonTitle').text(goat.utils.extractLessonTitle($(reply)));
3031
// adjust menu to lessonContent size if necssary
3132
if ($('div.panel-body').height() > 400) {
3233
$('#leftside-navigation').height($(window).height());
3334
}
34-
// hook into our pseudo service calls
35-
// @TODO make these real services during phase 2
36-
// show cookies and params
37-
goat.utils.showLessonCookiesAndParams();
38-
// show hints
39-
goat.utils.showLessonHint();
40-
// show plan
41-
goat.utils.showLessonPlan();
42-
// show solution
43-
goat.utils.showLessonSolution();
44-
// show source
45-
goat.utils.showLessonSource();
35+
goat.lesson.lessonInfo = new goat.lesson.CurLesson(url);
36+
goat.lesson.lessonInfo.loadInfo(); //uses pseudo and actual service calls
37+
// @TODO: convert to real services (and more angularjs, likely ... in phase 2)
4638
}
47-
);
48-
};
49-
}).animation('.slideDown', function() {
50-
var NgHideClassName = 'ng-hide';
51-
return {
52-
beforeAddClass: function(element, className, done) {
53-
if (className === NgHideClassName) {
54-
$(element).slideUp(done);
55-
}
56-
},
57-
removeClass: function(element, className, done) {
58-
if (className === NgHideClassName) {
59-
$(element).hide().slideDown(done);
60-
}
61-
}
62-
};
63-
});
39+
);
40+
};
41+
}).animation('.slideDown', function() {
42+
var NgHideClassName = 'ng-hide';
43+
return {
44+
beforeAddClass: function(element, className, done) {
45+
if (className === NgHideClassName) {
46+
$(element).slideUp(done);
47+
}
48+
},
49+
removeClass: function(element, className, done) {
50+
if (className === NgHideClassName) {
51+
$(element).hide().slideDown(done);
52+
}
53+
}
54+
};
55+
});
6456

57+
goat.controller('lessonHelpController', function($scope) {
58+
$scope.cookies=[];
59+
$scope.params=[];
60+
$scope.viewCookiesAndParams = function($scope) {
61+
$scope.cookies=goat.lesson.lessonInfo.cookies;
62+
$scope.params=goat.lesson.lessonInfo.params;
63+
//@TODO: issue callback to track view
64+
}
65+
});
6566

66-
/* Controllers for modal instances */
67+
/*
68+
*DEPRECATED
69+
//Controllers for modal instances
6770
var showSourceController = function($scope, $modalInstance, lessonSource) {
6871
6972
$scope.lessonSource = lessonSource;
@@ -89,7 +92,7 @@ var showSolutionController = function($scope, $modalInstance, lessonSolutionUrl)
8992
$modalInstance.dismiss('cancel');
9093
};
9194
};
92-
95+
*/
9396

9497

9598

src/main/webapp/js/goatData.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
/* ### GOAT DATA/PROMISES ### */
22

33
goat.data = {
4+
/**** jQuery loads ... ****/
45
loadLessonContent: function (_url) {
56
//TODO: switch to $http (angular) later
67
//return $http({method:'GET', url: _url});
8+
79
return $.get(_url, {}, null, "html");
810
},
11+
loadCookies: function() {
12+
return $.get(goatConstants.cookieService, {});
13+
},
14+
loadHints: function () {
15+
return $.get(goatConstants.hintService, {});
16+
},
17+
loadSource: function() {
18+
return $.get(goatConstants.sourceService, {});
19+
},
20+
loadSolution: function () {
21+
return $.get(goatConstants.solutionService, {})
22+
},
23+
loadPlan: function () {
24+
return $.get(goatConstants.lessonPlanService, {});
25+
},
26+
loadParams: function() {
27+
return $.get(goatConstants.paramsService,{});
28+
},
29+
/*** angular data grabs ***/
930
loadMenuData: function() {
1031
//TODO use goatConstants var for url
11-
return $http({method: 'GET', url: 'service/lessonmenu.mvc'});
32+
return $http({method: 'GET', url: goatConstants.menuService});
1233
}
1334
};

0 commit comments

Comments
 (0)