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:
|
item.style.visibility = "visible"; |
|
if (post !== undefined) { |
|
post.style.visibility = "visible"; |
|
} |
|
item.style.visibility = "visible"; |
|
if (post !== undefined) { |
|
post.style.visibility = "visible"; |
|
} |
I've noticed that it takes a bit of fiddling to reproduce issues on specific exercises. Would you accept a PR that adds a
showLessonByNumberfunction 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:
learnrx/assets/app/show_answers.js
Lines 18 to 21 in 4a1599c
learnrx/assets/app/main.js
Lines 31 to 34 in 4a1599c