I've noticed that it takes a bit of fiddling to reproduce issues on specific exercises. Would you accept a PR that adds a showLessonByNumber function like:
/**
* @param {number} n The lesson number starting from 1
*/
function showLessonByNumber(n) {
var item = $(".lesson").get(n - 1);
if (item) {
showLesson(item);
} else {
throw new Error("Exercise " + (n - 1) + " could not be found.");
}
}
Since this would be the third spot we're changing the visibility of a lesson, I'd suggest we extract that function as showLesson:
/**
* @param {Element} lessonElement
*/
function showLesson(lessonElement) {
var post = $(".post", lessonElement)[0];
lessonElement.style.visibility = "visible";
if (post !== undefined) {
post.style.visibility = "visible";
}
}
We could call this function in these two spots as well:
I've noticed that it takes a bit of fiddling to reproduce issues on specific exercises. Would you accept a PR that adds a
showLessonByNumber
function like:Since this would be the third spot we're changing the visibility of a lesson, I'd suggest we extract that function as
showLesson
:We could call this function in these two spots as well: