home.ejs 3.4 KB
<% include ./includes/header.ejs %>
    <div style="background-color:lavenderblush;">
        <h2 style="padding: 30px;">Categories</h2>
        <% var count = 0; var collapseCount = 'less';%>
        <center>
        <div class="accordion w-85" id="accordionExample" style="padding-bottom: 20px;">
        <% for (var i in video) { %>
            <div class="accordion-item" style="margin: 20px;">
                <h2 class="accordion-header" id="<%=video[i].category.title%>">
                    <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#<%=collapseCount%>"
                    aria-expanded="true" aria-controls="<%=collapseCount%>" style ="padding-top: 30px">
                        <%=video[i].category.title%>
                    </button>
                </h2>
                <div id="<%=collapseCount%>" data-bs-parent="#accordionExample" class="accordion-collapse collapse" aria-labelledby="<%=video[i].category.title%>">
                    <div class="accordion-body">
                        <% for (var j in video[i].videos) { %>
                            <div class="card" style="width: 55rem; margin-bottom: 15px; margin-top: 15px;">
                                <div class="card-top" id="<%=count%>" vid="<%=video[i].videos[j].video_id%>" style="margin: 30px;">
                                </div>
                                <div class="card-body">
                                    <h5 class="card-title"><%=video[i].videos[j].title%></h5>
                                    <p class="card-text">해당 영상에 대한 메모를 여기에 출력.
                                    </p>
                                </div>
                            </div>
                        <%count++;}; %>
                    </div>
                </div>
            </div>
            <%collapseCount = collapseCount+ "le";%>
        <%};%>
        </div>
        </center>
    </div>

    <style type="text/css">
        .masonry-grid img {
            max-width: 260px;
        }
    </style>
    <script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
    <script type="text/javascript"
        src="https://cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/4.1.1/imagesloaded.pkgd.min.js"></script>
    <script type="text/javascript">
        var $masonry_container = $('#masonry_container');
        $masonry_container.imagesLoaded(function () {
            $masonry_container.masonry({
                itemSelector: '.masonry-grid',
                columnWidth: 270
            });
        });
    </script>
    <script>
        var tag = document.createElement('script');

        tag.src = "https://www.youtube.com/iframe_api";
        var firstScriptTag = document.getElementsByTagName('script')[0];
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
        var player;
        var players = [];
        var videoIds = [];
        for (var i = 0; i < 30; i++) {
            players.push(String(i));
            videoIds.push($('#' + players[i]).attr('vid'));
        }

        function onYouTubeIframeAPIReady() {
            for (var i = 0; i < videoIds.length; i++) {
                player = new YT.Player(players[i], {
                    height: '450',
                    width: '800',
                    videoId: videoIds[i],
                });
            }
        }
    </script>
    <% include ./includes/footer.ejs %>