Refactored files to Maven standard Layout
Added plugin to produce executable jar. Now it is easy to run webgoat on all platforms.
This commit is contained in:
73
src/main/webapp/js/goat.js
Normal file
73
src/main/webapp/js/goat.js
Normal file
@ -0,0 +1,73 @@
|
||||
//main goat application file
|
||||
//TODO: reorg
|
||||
|
||||
/* ### GOAT CONTROLLERS ### */
|
||||
|
||||
/** Menu Controller
|
||||
* prepares and updates menu topic items for the view
|
||||
*/
|
||||
goat.controller('goatMenu', function($scope, $http) {
|
||||
//TODO: implement via separate promise and use config for menu
|
||||
$http({method: 'GET', url: 'service/lessonmenu.mvc'}).then(
|
||||
function(menuData) {
|
||||
var menuItems = goat.addMenuClasses(goatConstants.menuPrefix.concat(menuData.data));
|
||||
$scope.menuTopics = menuItems;
|
||||
},
|
||||
function(error) {
|
||||
// TODO - handle this some way other than an alert
|
||||
console.error("Error rendering menu: " + error);
|
||||
}
|
||||
);
|
||||
$scope.renderLesson = function(url) {
|
||||
console.log(url + ' was passed in');
|
||||
// use jquery to render lesson content to div
|
||||
loadLessonContent(url).then(
|
||||
function(reply) {
|
||||
$("#lesson_content").html(reply);
|
||||
// hook forms
|
||||
makeFormsAjax();
|
||||
}
|
||||
);
|
||||
};
|
||||
})
|
||||
.animation('.slideDown', function() {
|
||||
var NgHideClassName = 'ng-hide';
|
||||
return {
|
||||
beforeAddClass: function(element, className, done) {
|
||||
if (className === NgHideClassName) {
|
||||
jQuery(element).slideUp(done);
|
||||
}
|
||||
},
|
||||
removeClass: function(element, className, done) {
|
||||
if (className === NgHideClassName) {
|
||||
jQuery(element).hide().slideDown(done);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//TODO add recursion to handle arr[i].children objects
|
||||
// ... in case lower-level's need classes as well ... don't right now
|
||||
goat.addMenuClasses = function(arr) {
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var menuItem = arr[i];
|
||||
//console.log(menuItem);
|
||||
if (menuItem.type && menuItem.type === 'CATEGORY') {
|
||||
menuItem.class = 'fa-angle-right pull-right';
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
|
||||
function loadLessonContent(_url) {
|
||||
//TODO: switch to $http (angular)
|
||||
return $.get(_url,{},null,"html");
|
||||
}
|
||||
|
||||
function loadMenuData() {
|
||||
return $http({method: 'GET', url: 'service/lessonmenu.mvc'});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user