restart Lesson button implemented and attack link modification for CSRF lesson

This commit is contained in:
Jason White
2014-09-20 16:03:52 -06:00
parent e8a273efb2
commit 4ff73d0215
5 changed files with 34 additions and 3 deletions

View File

@ -139,6 +139,7 @@
<button type="button" id="showSolutionBtn" class="btn btn-primary btn-xs" ng-click="showLessonSolution()">Solution</button>
<button type="button" id="showPlanBtn" class="btn btn-primary btn-xs" ng-click="showLessonPlan()">Lesson Plan</button>
<button type="button" id="showHintsBtn" class="btn btn-primary btn-xs" ng-click="viewHints()">Hints</button>
<button type="button" id="restartLessonBtn" class="btn btn-xs" ng-click="restartLesson()">Restart Lesson</button>
</div>
</div>
<div class="lessonHelp" id="lesson_hint_row">
@ -351,6 +352,7 @@
// make any embedded forms ajaxy
goat.utils.showLessonCookiesAndParams();
goat.utils.makeFormsAjax();
goat.utils.ajaxifyAttackHref(); //TODO find some way to hook scope for current menu. Likely needs larger refactor which is already started/stashed
//refresh menu
angular.element($('#leftside-navigation')).scope().renderMenu();
}

View File

@ -23,6 +23,7 @@ var goatConstants = {
lessonPlanService:'service/lessonplan.mvc',
menuService: 'service/lessonmenu.mvc',
lessonTitleService: 'service/lessontitle.mvc',
restartLessonService: 'service/restartlesson.mvc',
// literals
notFound: 'Could not find',
noHints: 'There are no hints defined.'

View File

@ -85,7 +85,8 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
//TODO encode html or get angular js portion working
$("#lesson_content").html(reply.data);
//hook forms
goat.utils.makeFormsAjax();
goat.utils.makeFormsAjax();// inject form?
goat.utils.ajaxifyAttackHref();
$('#leftside-navigation').height($('#main-content').height()+15)//TODO: get ride of fixed value (15)here
//notifies goatLesson Controller of the less change
$scope.$emit('lessonUpdate',{params:curScope.parameters});
@ -234,6 +235,14 @@ var goatLesson = function($scope,$http,$log) {
$scope.hideHints = function() {
};
$scope.restartLesson = function () {
goat.data.loadRestart($http).then(
function(resp) {
angular.element($('#leftside-navigation')).scope().renderLesson(null,resp.data);
}
)
}
$scope.showAbout = function() {
$('#aboutModal').modal({

View File

@ -36,5 +36,9 @@ goat.data = {
},
loadLessonTitle: function ($http) {
return $http({method: 'GET', url: goatConstants.lessonTitleService});
},
loadRestart: function ($http) {
return $http({method: 'GET', url:goatConstants.restartLessonService})
}
};

View File

@ -91,8 +91,23 @@ goat.utils = {
makeId: function (lessonName) {
return lessonName.replace(/\s|\(|\)|\!|\:|\;|\@|\#|\$|\%|\^|\&|\*/g,'');//TODO move the replace routine into util function
},
ajaxifyAttackHREF: function () {
// stub for dealing with CSRF lesson link issues and other similar issues
ajaxifyAttackHref: function () {
$.each($('a[href^="attack?"]'),
function(i,el) {
var url = $(el).attr('href');
$(el).attr('href','#');
$(el).attr('link',url);
//TODO pull currentMenuId
$(el).click(
function() {
var _url = $(el).attr('link');
$.get(_url, {success:showResponse});
//return $.get(_url, {}, null, "html");
//angular.element($('#leftside-navigation')).scope().renderLesson(curMenuItem,url);
}
)
}
);
}
};