import $ from "jquery";

const showTimelineYear = () => {
    $(".__timeline-year").not(`#timeline-year-${window.currentTimelineYear}`).addClass("hidden");
    $(`#timeline-year-${window.currentTimelineYear}`).removeClass("hidden");
    $("#timeline-current-year").html(window.currentTimelineYear);

    $("#next-timeline-item").attr(
        "disabled",
        ($(`#timeline-year-${window.currentTimelineYear + 1}`).length === 0)
    );
    $("#previous-timeline-item").attr(
        "disabled",
        ($(`#timeline-year-${window.currentTimelineYear - 1}`).length === 0)
    );
}

$(window).ready(
    () => {
        window.nextTimelineYear = () => {
            window.currentTimelineYear++;
            showTimelineYear();
        }

        window.previousTimelineYear = () => {
            window.currentTimelineYear--;
            showTimelineYear();
        }
    }
)