(function ($) {
    "use strict";
    /*--/ Star Typed /--*/
    if ($('.text-slider').length == 1) {
        var typed_strings = $('.text-slider-items').text();
        var typed = new Typed('.text-slider', {
            strings: typed_strings.split(','),
            typeSpeed: 80,
            loop: true,
            backDelay: 1100,
            backSpeed: 30
        });
    }

    function initParallax() {
        $('#masthead').parallax("100%", 0.3);
        $('#content').parallax("20%", 0.7);
    }

    initParallax();

    let counter;
    counter = 0;
    let loading = true
    $(window).scroll(function () {
        if ($(window).scrollTop() + $(window).height() == $(document).height()) {
            console.log(counter)
            function see_more() {
                if (loading) {
                    counter = counter + 20;
                    var csrftoken = $.cookie('csrftoken')
                    let info;
                    info = {'counter': counter, 'csrfmiddlewaretoken': csrftoken,'flag':'home'}
                    $.ajax({
                        type: "POST",
                        url: 'article/article_list_call/',
                        data: info,
                        datatype: 'json',
                        headers: {"X-CSRFToken": csrftoken},
                        success: function (data) {
                            if (data.indexOf('已经到底了') === -1) {
                                $("#articles_list").append(data);
                            } else {
                                loading = false;
                            }
                        }
                    })
                }
            }

            see_more();

        }
    })

})(jQuery);

