Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement - Any interest in a helper function to show exercise by number? #176

Open
seanpoulter opened this issue Mar 7, 2019 · 0 comments

Comments

@seanpoulter
Copy link
Contributor

seanpoulter commented Mar 7, 2019

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:

@morenoh149 morenoh149 changed the title Any interested in a helper function to show an exercise by number? Any interest in a helper function to show exercise by number? Mar 7, 2019
@seanpoulter seanpoulter changed the title Any interest in a helper function to show exercise by number? Improvement - Any interest in a helper function to show exercise by number? Mar 7, 2019
@seanpoulter seanpoulter changed the title Improvement - Any interest in a helper function to show exercise by number? Enhancement - Any interest in a helper function to show exercise by number? Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant