Merge branch 'next' of https://github.com/WebGoat/WebGoat into next
Conflicts: .gitignore
This commit is contained in:
@ -19,8 +19,11 @@ var goatConstants = {
|
||||
solutionService:'service/solution.mvc',
|
||||
lessonPlanService:'service/lessonplan.mvc',
|
||||
menuService: 'service/lessonmenu.mvc',
|
||||
lessonTitleService: 'service/lessontitle.mvc',
|
||||
// literals
|
||||
notFound: 'Could not find'
|
||||
notFound: 'Could not find',
|
||||
noHints: 'There are no hints defined.'
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -3,10 +3,12 @@
|
||||
|
||||
/* ### GOAT CONTROLLERS ### */
|
||||
|
||||
/** Menu Controller
|
||||
/** Lesson Controller (includes menu stuff)
|
||||
* prepares and updates menu topic items for the view
|
||||
*/
|
||||
goat.controller('goatLessonMenu', function($scope, $http, $modal, $log, $templateCache) {
|
||||
goat.controller('goatLesson', function($scope, $http, $modal, $log, $templateCache) {
|
||||
$scope.cookies = [];
|
||||
$scope.params = [];
|
||||
//TODO: implement via separate promise and use config for menu (goat.data.loadMenuData())
|
||||
$http({method: 'GET', url: goatConstants.lessonService}).then(
|
||||
function(menuData) {
|
||||
@ -18,85 +20,156 @@ goat.controller('goatLessonMenu', function($scope, $http, $modal, $log, $templat
|
||||
console.error("Error rendering menu: " + error);
|
||||
}
|
||||
);
|
||||
|
||||
$scope.renderLesson = function(url) {
|
||||
//console.log(url + ' was passed in');
|
||||
// use jquery to render lesson content to div
|
||||
$scope.hintIndex = 0;
|
||||
|
||||
var curScope = $scope;
|
||||
|
||||
curScope.parameters = goat.utils.scrapeParams(url);
|
||||
goat.data.loadLessonContent(url).then(
|
||||
function(reply) {
|
||||
$("#lesson_content").html(reply);
|
||||
// hook forms
|
||||
goat.data.loadLessonTitle().then(
|
||||
function(reply) {
|
||||
$("#lessonTitle").text(reply);
|
||||
}
|
||||
);
|
||||
|
||||
//hook forms
|
||||
goat.utils.makeFormsAjax();
|
||||
//render lesson title
|
||||
$('#lessonTitle').text(goat.utils.extractLessonTitle($(reply)));
|
||||
$('#hintsView').hide();
|
||||
// adjust menu to lessonContent size if necssary
|
||||
//@TODO: this is still clunky ... needs some TLC
|
||||
//@TODO: this is still clunky ... needs some TLC
|
||||
if ($('div.panel-body').height() > 400) {
|
||||
$('#leftside-navigation').height($(window).height());
|
||||
}
|
||||
goat.lesson.lessonInfo = new goat.lesson.CurLesson(url);
|
||||
goat.lesson.lessonInfo.loadInfo(); //uses pseudo and actual service calls
|
||||
// @TODO: convert to real services (and more angularjs, likely ... in phase 2)
|
||||
//cookies
|
||||
goat.data.loadCookies().then(
|
||||
function(resp) {
|
||||
curScope.cookies = resp;
|
||||
}
|
||||
);
|
||||
//hints
|
||||
curScope.hintIndex = 0;
|
||||
goat.data.loadHints().then(
|
||||
function(resp) {
|
||||
curScope.hints = resp;
|
||||
if (curScope.hints.length > 0 && curScope.hints[0].hint.indexOf(goatConstants.noHints) === -1) {
|
||||
goat.utils.displayButton('showHintsBtn', true);
|
||||
} else {
|
||||
goat.utils.displayButton('showHintsBtn', false);
|
||||
}
|
||||
}
|
||||
);
|
||||
//source
|
||||
goat.data.loadSource().then(
|
||||
function(resp) {
|
||||
curScope.source = resp;
|
||||
}
|
||||
);
|
||||
//plan
|
||||
goat.data.loadPlan().then(
|
||||
function(resp) {
|
||||
curScope.plan = resp;
|
||||
}
|
||||
);
|
||||
//solution
|
||||
goat.data.loadSolution().then(
|
||||
function(resp) {
|
||||
curScope.solution = resp;
|
||||
}
|
||||
);
|
||||
goat.utils.scrollToTop();
|
||||
}
|
||||
);
|
||||
};
|
||||
}).animation('.slideDown', function() {
|
||||
var NgHideClassName = 'ng-hide';
|
||||
return {
|
||||
beforeAddClass: function(element, className, done) {
|
||||
if (className === NgHideClassName) {
|
||||
$(element).slideUp(done);
|
||||
}
|
||||
},
|
||||
removeClass: function(element, className, done) {
|
||||
if (className === NgHideClassName) {
|
||||
$(element).hide().slideDown(done);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
goat.controller('lessonHelpController', function($scope) {
|
||||
$scope.cookies=[];
|
||||
$scope.params=[];
|
||||
$scope.viewCookiesAndParams = function() {
|
||||
$scope.cookies=goat.lesson.lessonInfo.cookies;
|
||||
console.log($scope.cookies);
|
||||
$scope.params=goat.lesson.lessonInfo.params;
|
||||
|
||||
//@TODO: issue callback to track view
|
||||
);
|
||||
};
|
||||
//$scope.watch()
|
||||
|
||||
$scope.showLessonSource = function() {
|
||||
$('.lessonHelp').hide();
|
||||
$('#lesson_source_row').show();
|
||||
goat.utils.scrollToHelp();
|
||||
}
|
||||
|
||||
$scope.showLessonPlan = function() {
|
||||
$('.lessonHelp').hide();
|
||||
$("#lesson_plan").html($scope.plan);
|
||||
$('#lesson_plan_row').show();
|
||||
goat.utils.scrollToHelp();
|
||||
}
|
||||
|
||||
$scope.showLessonSolution = function() {
|
||||
$('.lessonHelp').hide();
|
||||
$("#lesson_solution").html($scope.solution);
|
||||
$('#lesson_solution_row').show();
|
||||
goat.utils.scrollToHelp();
|
||||
}
|
||||
|
||||
$scope.manageHintButtons = function() {
|
||||
if ($scope.hintIndex === $scope.hints.length - 1) {
|
||||
$('#showNextHintBtn').css('visibility', 'hidden');
|
||||
} else if ($scope.hintIndex < $scope.hints.length - 1) {
|
||||
$('#showNextHintBtn').css('visibility', 'visible');
|
||||
}
|
||||
//
|
||||
if ($scope.hintIndex === 0) {
|
||||
$('#showPrevHintBtn').css('visibility', 'hidden');
|
||||
} else if ($scope.hintIndex > 0) {
|
||||
$('#showPrevHintBtn').css('visibility', 'visible');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.viewHints = function() {
|
||||
if (!$scope.hints) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.lessonHelp').hide();
|
||||
$('#lesson_hint_row').show();
|
||||
goat.utils.scrollToHelp();
|
||||
$scope.curHint = $scope.hints[$scope.hintIndex].hint;
|
||||
$scope.manageHintButtons();
|
||||
};
|
||||
|
||||
$scope.viewNextHint = function() {
|
||||
$scope.hintIndex++;
|
||||
$scope.curHint = $scope.hints[$scope.hintIndex].hint;
|
||||
$scope.manageHintButtons();
|
||||
};
|
||||
|
||||
$scope.viewPrevHint = function() {
|
||||
$scope.hintIndex--;
|
||||
$scope.curHint = $scope.hints[$scope.hintIndex].hint;
|
||||
$scope.manageHintButtons();
|
||||
};
|
||||
|
||||
$scope.hideHints = function() {
|
||||
|
||||
};
|
||||
|
||||
$scope.showAbout = function() {
|
||||
$('#aboutModal').modal({
|
||||
remote: 'about.mvc'
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
}).animation('.slideDown', function() {
|
||||
var NgHideClassName = 'ng-hide';
|
||||
return {
|
||||
beforeAddClass: function(element, className, done) {
|
||||
if (className === NgHideClassName) {
|
||||
$(element).slideUp(done);
|
||||
}
|
||||
},
|
||||
removeClass: function(element, className, done) {
|
||||
if (className === NgHideClassName) {
|
||||
$(element).hide().slideDown(done);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
*DEPRECATED
|
||||
//Controllers for modal instances
|
||||
var showSourceController = function($scope, $modalInstance, lessonSource) {
|
||||
|
||||
$scope.lessonSource = lessonSource;
|
||||
|
||||
$scope.ok = function() {
|
||||
$modalInstance.close();
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
};
|
||||
|
||||
var showSolutionController = function($scope, $modalInstance, lessonSolutionUrl) {
|
||||
|
||||
$scope.lessonSolutionUrl = lessonSolutionUrl;
|
||||
|
||||
$scope.ok = function() {
|
||||
$modalInstance.close();
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ goat.data = {
|
||||
return $.get(goatConstants.sourceService, {});
|
||||
},
|
||||
loadSolution: function () {
|
||||
return $.get(goatConstants.solutionService, {})
|
||||
return $.get(goatConstants.solutionService, {});
|
||||
},
|
||||
loadPlan: function () {
|
||||
return $.get(goatConstants.lessonPlanService, {});
|
||||
@ -30,5 +30,8 @@ goat.data = {
|
||||
loadMenuData: function() {
|
||||
//TODO use goatConstants var for url
|
||||
return $http({method: 'GET', url: goatConstants.menuService});
|
||||
},
|
||||
loadLessonTitle: function () {
|
||||
return $.get(goatConstants.lessonTitleService, {});
|
||||
}
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ goat.lesson = {
|
||||
goat.data.loadHints().then(
|
||||
function(resp) {
|
||||
scope.hints = resp;
|
||||
if (scope.hints.length > 0) {
|
||||
if (scope.hints.length > 0 && scope.hints[0].hint.indexOf(goatConstants.noHints) === -1) {
|
||||
goat.utils.displayButton('showHintsBtn',true);
|
||||
} else {
|
||||
goat.utils.displayButton('showHintsBtn',false);
|
||||
@ -103,7 +103,7 @@ goat.lesson = {
|
||||
);
|
||||
},
|
||||
getParams: function() {
|
||||
this.params = goat.utils.scrapeParams(this.lessonUrl)
|
||||
this.params = goat.utils.scrapeParams(this.lessonUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,14 +15,6 @@ goat.utils = {
|
||||
//console.log("Hooking any lesson forms to make them ajax");
|
||||
$("form").ajaxForm(options);
|
||||
},
|
||||
/**goatApp.extractLessonTitle
|
||||
*pulls lesson title from html fragment returned (looks for it in h1 element)
|
||||
*@param - html rendered to object passed in
|
||||
*/
|
||||
extractLessonTitle: function(el) {
|
||||
var title = $('h1', el).text();
|
||||
return title;
|
||||
},
|
||||
displayButton: function(id,show) {
|
||||
if ($('#'+id)) {
|
||||
if (show) {
|
||||
@ -44,7 +36,7 @@ goat.utils = {
|
||||
},
|
||||
showLessonSource: function(source) {
|
||||
$('.lessonHelp').hide();
|
||||
$('#lesson_source').html("<pre>"+goat.lesson.lessonInfo.source+"</pre>");
|
||||
//$('#lesson_source').html("<pre>"+goat.lesson.lessonInfo.source+"</pre>");
|
||||
$('#lesson_source_row').show();
|
||||
goat.utils.scrollToHelp();
|
||||
},
|
||||
@ -65,6 +57,7 @@ goat.utils = {
|
||||
goat.utils.scrollEasy(target);
|
||||
},
|
||||
scrollToTop: function() {
|
||||
$('.lessonHelp').hide();
|
||||
var target= $('#container');
|
||||
goat.utils.scrollEasy(target);
|
||||
},
|
||||
|
Reference in New Issue
Block a user