Commit 7c2daf66 authored by Jakob Moser's avatar Jakob Moser
Browse files

Handle falsy parameters to startExercise

Closes #45
parent 6ca545bf
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -37,10 +37,18 @@ function initExerciseList() {
}

/**
 * Start an exercise, also updating the currentState
 * Start an exercise, also updating the currentState.
 *
 * If no exercise is given, none is started. In this case the function only has 
 * the effect of marking all exercises as not-current (i.e. collapsing them).
 * @param {Exercise} exercise Exercise to start
 */
function startExercise(exercise) {
    // Display all exercises as non-current, except for this one
    document.querySelectorAll(".exercise").forEach(el => displayAsNonCurrent(el))

    if(!exercise) return
    
    const cardEl = document.querySelector(`.exercise[data-exercise-index='${exercise.index}']`)
    let unusuallyLongTimeoutId = null

@@ -79,9 +87,6 @@ function startExercise(exercise) {
    )

    exercise.start()

    // Display all exercises as non-current, except for this one
    document.querySelectorAll(".exercise").forEach(el => displayAsNonCurrent(el))
    displayAsCurrent(cardEl)
}