
$(document).ready(function() { 
    // $(".custom-tab-year .custom-nav-item .nav-link").click(function (e) { 
    //     $(".custom-tab-year .custom-nav-item .nav-link").removeClass("active")
    //     $(this).addClass("active")
    //     let pageItemID = $(this).attr("id");
    //     $(".year-content").removeClass("active in show")
    //     $('#'+pageItemID+'-content').addClass("active in show")
    // });

    $('.year-contents:first-child').addClass('d-block');
    $('.year-item:first-child').addClass('active');

    $(".year-item").each(function () {
        $(this).on("click", function () {
            var listItems = $(".year-item");

            for (let i = 0; i < listItems.length; i++) {
                if (this != listItems[i]) {
                    listItems[i].classList.remove("active");
                }
            }

            if (this.classList.contains("active")) {
                this.classList.remove("active");
            } else if (!this.classList.contains("active")) {
                this.classList.add("active");
            }

            //console.log($(this).data())
            var count = $(this).attr('data-content-count')
            //console.log('count ' + count)

            // ES5
            $('.year-contents').each(function(index, item)  {
                if (item.getAttribute('data-button-count') != count) {
                    item.classList.remove('d-block')
                }

                // console.log('content count ' + item.getAttribute('data-content-count'))
                if (item.getAttribute('data-button-count') == count) {
                    if (!item.classList.contains('d-block')) {
                        //console.log("add?")
                        item.classList.add('d-block')
                    } else if (item.classList.contains('d-block')) {
                        //console.log("remove?")
                        item.classList.remove('d-block')
                    }
                }
            })
        });
    });
});