diff --git a/src/main/webapp/WEB-INF/pages/main_new.jsp b/src/main/webapp/WEB-INF/pages/main_new.jsp
index 5b2c3e2c8..67598f88d 100644
--- a/src/main/webapp/WEB-INF/pages/main_new.jsp
+++ b/src/main/webapp/WEB-INF/pages/main_new.jsp
@@ -139,6 +139,7 @@
+
@@ -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();
}
diff --git a/src/main/webapp/js/goatConstants.js b/src/main/webapp/js/goatConstants.js
index 707b8cbc1..ae38ed3ee 100644
--- a/src/main/webapp/js/goatConstants.js
+++ b/src/main/webapp/js/goatConstants.js
@@ -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.'
diff --git a/src/main/webapp/js/goatControllers.js b/src/main/webapp/js/goatControllers.js
index 4d1f89336..88f4535ac 100644
--- a/src/main/webapp/js/goatControllers.js
+++ b/src/main/webapp/js/goatControllers.js
@@ -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({
diff --git a/src/main/webapp/js/goatData.js b/src/main/webapp/js/goatData.js
index a1d113a38..b01f0f873 100644
--- a/src/main/webapp/js/goatData.js
+++ b/src/main/webapp/js/goatData.js
@@ -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})
}
+
};
diff --git a/src/main/webapp/js/goatUtil.js b/src/main/webapp/js/goatUtil.js
index cfba7c35a..826e8c208 100644
--- a/src/main/webapp/js/goatUtil.js
+++ b/src/main/webapp/js/goatUtil.js
@@ -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);
+ }
+ )
+ }
+ );
}
};