<!DOCTYPE html>
<html lang="ru">
	<head>
		<%- include('templates/head.ejs') %>
		<link rel="stylesheet" href="../css/style.css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" defer></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js" defer></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" defer></script>
	</head>
	<body class="light-mode">
	<%- include('templates/header.ejs') %>
    <%- include('templates/layout_panel.ejs', { activePage: activePage }) %>
        <main class="col-md-9 col-sm-12">
            <h1>General vocabulary</h1>
            <div class="container text-center">
                <div class="row">
                    <div class="col-md-9 mb-3">
                        <div class="input-group">
                            <button class="input-group-text btn btn-outline-secondary" type="button"><i class="bi bi-search"></i> Search</button>
                            <input type="text" class="form-control" id="search-input" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default" placeholder="Enter a request">
                        </div>
                    </div>
                    <div class="col-md-3" id="category-select"></div>
                </div>
            </div>
            <table class="table">
                <tbody>
                    <% for (const [letter, crumbers] of Object.entries(groupedCrumbers)) { %>
                        <tr>
                            <td><b><%= letter %></b></td>
                            <td>
                                <% for (const crumber of crumbers) { %>
                                    <p>
                                        <button
                                            type="button"
                                            title="<%=crumber.word%> от <%=crumber.author%>"
                                            class="btn btn-primary"
                                            id = "<%=crumber.category.replace(/ /g, '-')%>"
                                            data-bs-toggle="modal"
                                            data-bs-target="#modal_<%= crumber.word.replace(/ /g, '_') %>">
                                            <%= crumber.word %>
                                        </button>
                                    </p>
                                    <!-- Modal -->
                                    <div
                                        class="modal fade"
                                        id="modal_<%= crumber.word.replace(/ /g, '_') %>"
                                        tabindex="-1"
                                        aria-labelledby="modalLabel_<%= crumber.word.replace(/ /g, '_') %>"
                                        aria-hidden="true">
                                        <div class="modal-dialog modal-dialog-centered">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="modalLabel_<%= crumber.word.replace(/ /g, '_') %>"><%= crumber.word %></h5>
                                                    <button
                                                        type="button"
                                                        class="btn-close"
                                                        data-bs-dismiss="modal"
                                                        aria-label="Close"></button>
                                                </div>
                                                <div class="modal-body">
                                                    <div
                                                        id="carousel_<%= crumber.word.replace(/ /g, '_') %>"
                                                        class="carousel slide carousel-fade"
                                                        data-bs-ride="carousel">
                                                        <div class="carousel-inner">
                                                            <% for (const slide of crumber.slides) { %>
                                                                <div class="carousel-item <%= slide === crumber.slides[0] ? 'active' : '' %>">
                                                                    <img
                                                                        src="../media/presentations/<%= crumber.author.replace(/ /g, '_') %>/slide_<%= slide %>.jpeg"
                                                                        class="d-block w-100 border border-2"
                                                                        alt="Slide <%= slide %>"
                                                                        loading="lazy"/>
                                                                </div>
                                                            <% } %>
                                                        </div>
                                                        <button
                                                            class="carousel-control-prev"
                                                            type="button"
                                                            data-bs-target="#carousel_<%= crumber.word %>"
                                                            data-bs-slide="prev">
                                                            <span
                                                                class="bi bi-arrow-left-circle"
                                                                style="font-size: 2rem; color: black"
                                                                aria-hidden="true"></span>
                                                                <span class="visually-hidden">Previous</span>
                                                            </button>
                                                            <button
                                                                class="carousel-control-next"
                                                                type="button"
                                                                data-bs-target="#carousel_<%= crumber.word.replace(/ /g, '_') %>"
                                                                data-bs-slide="next">
                                                                <span
                                                                    class="bi bi-arrow-right-circle"
                                                                    style="font-size: 2rem; color: black"
                                                                    aria-hidden="true"></span>
                                                                <span class="visually-hidden">Next</span>
                                                            </button>
                                                        </div>
                                                        <a class="btn btn-secondary mt-2" href="./all_presentations/<%=crumber.author%>" role="button">more  <i class="bi bi-arrows-angle-expand"></i></a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    <% } %>
                                </td>
                            </tr>
                        <% } %>
                    </tbody>
                </table>
            </main>
    	</div>
	</div>
    <script defer src="../js/vocabulary_creator.js"></script>
	</body>
</html>
