cookies and params modification. Hints update as well
This commit is contained in:
@ -20,7 +20,9 @@ var goatConstants = {
|
||||
lessonPlanService:'service/lessonplan.mvc',
|
||||
menuService: 'service/lessonmenu.mvc',
|
||||
// literals
|
||||
notFound: 'Could not find'
|
||||
notFound: 'Could not find',
|
||||
noHints: 'There are no hints defined.'
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -3,42 +3,152 @@
|
||||
|
||||
/* ### 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) {
|
||||
var menuItems = goat.utils.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);
|
||||
}
|
||||
function(menuData) {
|
||||
var menuItems = goat.utils.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
|
||||
$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.utils.makeFormsAjax();
|
||||
function(reply) {
|
||||
$("#lesson_content").html(reply);
|
||||
//hook forms
|
||||
goat.utils.makeFormsAjax();
|
||||
$('#hintsView').hide();
|
||||
//render lesson title
|
||||
$('#lessonTitle').text(goat.utils.extractLessonTitle($(reply)));
|
||||
// adjust menu to lessonContent size if necssary
|
||||
$('#lessonTitle').text(goat.utils.extractLessonTitle($(reply)));
|
||||
//@KLUGE to remove h1 after extracting and moving it to top
|
||||
$('#lesson_content h1').remove()
|
||||
// adjust menu to lessonContent size if necssary
|
||||
//@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)
|
||||
}
|
||||
if ($('div.panel-body').height() > 400) {
|
||||
$('#leftside-navigation').height($(window).height());
|
||||
}
|
||||
//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();
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
$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 () {
|
||||
|
||||
};
|
||||
|
||||
|
||||
}).animation('.slideDown', function() {
|
||||
var NgHideClassName = 'ng-hide';
|
||||
return {
|
||||
@ -53,53 +163,6 @@ goat.controller('goatLessonMenu', function($scope, $http, $modal, $log, $templat
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
goat.controller('lessonHelpController', function($scope) {
|
||||
$scope.cookies=[];
|
||||
$scope.params=[];
|
||||
$scope.viewCookiesAndParams = function() {
|
||||
$('#hintsView').hide();
|
||||
if (goat.lesson.lessonInfo.cookies && goat.lesson.lessonInfo.cookies.length > 0) {
|
||||
$scope.cookies=goat.lesson.lessonInfo.cookies;
|
||||
console.log($scope.cookies);
|
||||
$scope.params=goat.lesson.lessonInfo.params;
|
||||
}
|
||||
$('#cookiesAndParamsView').show();
|
||||
//@TODO: issue callback to track view
|
||||
};
|
||||
//$scope.watch()
|
||||
});
|
||||
|
||||
/*
|
||||
*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');
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ goat.utils = {
|
||||
*/
|
||||
extractLessonTitle: function(el) {
|
||||
var title = $('h1', el).text();
|
||||
// remove title
|
||||
return title;
|
||||
},
|
||||
displayButton: function(id,show) {
|
||||
@ -44,7 +45,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 +66,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