var Wick = Wick || {};

Wick.orders = (function () { 
    var currentPage = 0,
    numberOfPages = Number.MAX_VALUE,
    classActiveLoad = 'load-more-wrap--loading',
    loadMoreWrap = $('#loadmorewrap'),
    loadMoreButton = $('#loadmore');

    function triggerLoadMoreResults() {
        loadMoreResults(currentPage + 1);
    }

    function toggleLoad(isLoad) {
        if (isLoad) {
            loadMoreWrap.addClass(classActiveLoad)
        } else {
            setItem()
            loadMoreWrap.removeClass(classActiveLoad)
        }
    }

    function setItem() {
        $('.wismo-hist__table:first').clone().insertBefore(loadMoreWrap)
    }

    function loadMoreResults(page) {
        toggleLoad(true);
        setTimeout(()=>{
            toggleLoad(false);
        }, 1000)
    }

    function initialize() {
        loadMoreButton.click(triggerLoadMoreResults)
    }

    initialize()
})();
