Commit 58bc9141 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add more display methods for exercise cards

parent b018d2d7
Loading
Loading
Loading
Loading
+16 −8
Changes for static/js/yalikejazz.mjs: 16 added lines, 8 removed lines.
Original line number Diff line number Diff line
import { currentState } from "./state.mjs"
import { exercises } from "./exercises.mjs"
import { getHandInToken } from "./snakeoil.mjs"
import { createCard } from "./cards.mjs"
import { createCard, setCardHoverTitle } from "./cards.mjs"
import { createElementWithClass } from "./util.mjs"

function findNextIncompleteExerciseIndex(currentExerciseIndex) {
@@ -23,10 +23,8 @@ function findNextIncompleteExerciseIndex(currentExerciseIndex) {
 * @param {HTMLElement} cardEl The .card element
 */
function displayAsSolved(cardEl) {
    cardEl.querySelector(".icon").classList.replace("bi-square", "bi-check-square")
    const titleEl = cardEl.querySelector(".title")
    titleEl.setAttribute("title", "Diese Aufgabe ist bereits gelöst, du kannst nicht mehr zu ihr springen.")
    titleEl.classList.remove("clickable")
    cardEl.classList.add("solved")
    setCardHoverTitle(cardEl, "Diese Aufgabe ist bereits gelöst, du kannst nicht mehr zu ihr springen.", false)
}

/**
@@ -35,9 +33,19 @@ function displayAsSolved(cardEl) {
 */
function displayAsCurrent(cardEl) {
    cardEl.classList.remove("collapsed")
    const titleEl = cardEl.querySelector(".title")
    titleEl.setAttribute("title", "Du kannst nicht zur aktuellen Aufgabe springen.")
    titleEl.classList.remove("clickable")
    setCardHoverTitle(cardEl, "Du kannst nicht zur aktuellen Aufgabe springen.", false)
}

/**
 * Changes the appearance of the given exercise card so it looks like it is not current
 * @param {HTMLElement} cardEl The .card element
 */
function displayAsNonCurrent(cardEl) {
    cardEl.classList.add("collapsed")

    if(!cardEl.classList.contains("solved")) {
        setCardHoverTitle(cardEl, "Zu dieser Aufgabe springen", true)
    }
}

/**