document.addEventListener('DOMContentLoaded', function () {
    mangaviewer = new MangaViewer();
    mangaviewer.page_class = ".p-thumb-large";
    //サムネイルクリック時（漫画表示開始）
    document.querySelectorAll("[data-thumbnail]").forEach(function (thumbnail, index) {
        thumbnail.addEventListener('click', function (e) {
            e.preventDefault();
            mangaviewer.init_display(index);

            //const loaderSrc = document.querySelector('.manga-view-loader-src').getAttribute("src");
            //document.querySelector(".manga-view-loader").setAttribute("src", loaderSrc);

            mangaviewer.show_page(index);
            mangaviewer.preload_image(index);
        });
    });

    //プリロード指示
    if (mangaviewer.total_pages > 0) mangaviewer.preload_image(0, false);
    if (mangaviewer.total_pages > 1) mangaviewer.preload_image(1, false);
    if (mangaviewer.total_pages > 2) mangaviewer.preload_image(2, false);

});

