Skip to content

Commit

Permalink
fix lesson number detection in url hash, in lesson page
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomontefuscolo committed Nov 8, 2013
1 parent 98f4fb2 commit 5fb2f37
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lesson/static/js/lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ function initialize_code_mirror($scope, data, expected) {

app.controller('LessonMainCtrl', ['$scope', 'LessonData',
function ($scope, LessonData) {
$scope.currentUnitPos = parseInt( /#\/(\d+)/.extract(location.hash, 1), 10);
$scope.currentUnitPos = Math.max($scope.currentUnitPos, 1);
var match = location.hash.match(/^#\/(\d+)/);
if(match) {
$scope.currentUnitPos = parseInt( match[1], 10);
} else {
$scope.currentUnitPos = 1;
}

$scope.isSelected = function(i){
return ($scope.currentUnitPos-1) === i;
Expand Down Expand Up @@ -73,7 +77,7 @@ function initialize_code_mirror($scope, data, expected) {
$location.path('/' + $main.currentUnitPos);
};
$scope.replayVideo = function() {
$location.path('/'+$main.currentUnitPos);
$location.path('/' + $main.currentUnitPos);
};

$scope.sendOrNext = function() {
Expand Down

0 comments on commit 5fb2f37

Please sign in to comment.