<%- include("../../partials/header.ejs") %>
<%- include("../../partials/nav.ejs") %>
<% 
    let defaultColour = "#BA2EFF";
    let foreground = "#ffffff";

    if (req.user) {
        defaultColour = req.user.db.preferences.defaultColour || "#BA2EFF"
        foreground = req.user.db.preferences.defaultForegroundColour || "#ffffff"
    }
%>
<%- include("../../partials/isDefaultCSS/pagination.ejs") %>
<%- include("../../partials/isDefaultCSS/button.ejs") %>
<section class="hero is-primary">
    <div class="hero-body">
        <div class="container has-text-centered">
            <br />
            <h1 class="title">
                <span class="icon is-medium iconalign">
                    <i aria-hidden="true" class="fad fa-archive has-text-default fa-1x"></i>
                </span>
                <br />
                <span><%= title %></span>
            </h1>
            <h2 class="subtitle"><%= subtitle %></h2>
        </div>
    </div>
</section>
<div class="container is-fluid">
    <div class="section is-fluid">
        <nav class="pagination is-centered" role="navigation" aria-label="pagination">
            <a class="pagination-previous" <% if (Number(req.query.page) <= 1) { %>disabled<% } else { %>href="/staff/audit?page=<%= Number(req.query.page) - 1 %>"<% } %>><%= __("common.pagination.previous") %></a>
            <a class="pagination-next" <% if (Number(req.query.page) >= pages) { %>disabled<% } else { %>href="/staff/audit?page=<%= Number(req.query.page) + 1 %>"<% } %>><%= __("common.pagination.next") %></a>
            <ul class="pagination-list">
                <% if (Number(req.query.page) <= 3) { %>
                    <li>
                        <% if (Number(req.query.page) === 1) { %>
                            <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "1") %>" aria-current="page">1</a>
                        <% } else { %> 
                            <a class="pagination-link" href="/staff/audit?page=1" aria-label="<%= __("common.pagination.gotoPage", "1") %>">1</a>
                        <% } %>
                    </li>
                    <% if (2 <= pages) { %>
                        <% if (Number(req.query.page) === 2) { %>
                            <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "2") %>" aria-current="page">2</a>
                        <% } else { %> 
                            <a class="pagination-link" href="/staff/audit?page=2" aria-label="<%= __("common.pagination.gotoPage", "2") %>">2</a>
                        <% } %>
                    <% } %>
                    <% if (3 <= pages) { %>
                        <li>
                            <% if (Number(req.query.page) === 3) { %>
                                <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "3") %>" aria-current="page">3</a>
                            <% } else { %> 
                                <a class="pagination-link" href="/staff/audit?page=3" aria-label="<%= __("common.pagination.gotoPage", "3") %>">3</a>
                            <% } %>
                        </li>
                    <% } %>
                    <% if (pages > 3) { %>
                        <li>
                            <span class="pagination-ellipsis">&hellip;</span>
                        </li>
                        <li>
                            <a class="pagination-link" href="/staff/audit?page=<%= pages %>" aria-label="<%= __("common.pagination.gotoPage", pages) %>"><%= pages %></a>
                        </li>
                    <% } %>
                <% } else { %>
                    <li>
                        <a class="pagination-link" href="/staff/audit?page=1" aria-label="<%= __("common.pagination.gotoPage", "1") %>">1</a>
                    </li>
                    <li>
                        <span class="pagination-ellipsis">&hellip;</span>
                    </li>
                    <% if (Number(req.query.page) === pages) { %>
                        <li>
                            <a class="pagination-link" href="/staff/audit?page=<%= Number(req.query.page) - 2 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) - 2) %>"><%= Number(req.query.page) - 2 %></a>
                        </li>
                    <% } %>
                    <li>
                        <a class="pagination-link" href="/staff/audit?page=<%= Number(req.query.page) - 1 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) - 1) %>"><%= Number(req.query.page) - 1 %></a>
                    </li>
                    <li>
                        <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", req.query.page) %>" aria-current="page"><%= req.query.page %></a>
                    </li>
                    <% if (Number(req.query.page) !== pages) { %>
                        <li>
                            <a class="pagination-link" href="/staff/audit?page=<%= Number(req.query.page) + 1 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) + 1) %>"><%= Number(req.query.page) + 1 %></a>
                        </li>
                    <% } %>
                    <% if (Number(req.query.page <= (pages - 2))) { %>
                        <li>
                            <span class="pagination-ellipsis">&hellip;</span>
                        </li>
                        <li>
                            <a class="pagination-link" href="/staff/audit?page=<%= pages %>" aria-label="<%= __("common.pagination.gotoPage", pages) %>"><%= pages %></a>
                        </li>
                    <% } %>
                <% } %>
            </ul>
        </nav>
        <br />
        <% if (logs.length === 0) { %>
            <h2 class="is-size-3"><%= __("common.error.fetchFail.logs") %></h2>
        <% } else { %>
            <% if (logsPgArr.length === 0) { %>
                <h2 class="is-size-3"><%= __("common.error.fetchFail.logs") %></h2>
            <% } else { %>
                <%- logsPgArr.map(log => include("../../partials/cards/log.ejs", { log, defaultColour })).join("") %>
            <% } %> 
        <% } %>
        <br />
        <nav class="pagination is-centered" role="navigation" aria-label="pagination">
            <a class="pagination-previous" <% if (Number(req.query.page) <= 1) { %>disabled<% } else { %>href="/staff/audit?page=<%= Number(req.query.page) - 1 %>"<% } %>><%= __("common.pagination.previous") %></a>
            <a class="pagination-next" <% if (Number(req.query.page) >= pages) { %>disabled<% } else { %>href="/staff/audit?page=<%= Number(req.query.page) + 1 %>"<% } %>><%= __("common.pagination.next") %></a>
            <ul class="pagination-list">
                <% if (Number(req.query.page) <= 3) { %>
                    <li>
                        <% if (Number(req.query.page) === 1) { %>
                            <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "1") %>" aria-current="page">1</a>
                        <% } else { %> 
                            <a class="pagination-link" href="/staff/audit?page=1" aria-label="<%= __("common.pagination.gotoPage", "1") %>">1</a>
                        <% } %>
                    </li>
                    <% if (2 <= pages) { %>
                        <% if (Number(req.query.page) === 2) { %>
                            <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "2") %>" aria-current="page">2</a>
                        <% } else { %> 
                            <a class="pagination-link" href="/staff/audit?page=2" aria-label="<%= __("common.pagination.gotoPage", "2") %>">2</a>
                        <% } %>
                    <% } %>
                    <% if (3 <= pages) { %>
                        <li>
                            <% if (Number(req.query.page) === 3) { %>
                                <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "3") %>" aria-current="page">3</a>
                            <% } else { %> 
                                <a class="pagination-link" href="/staff/audit?page=3" aria-label="<%= __("common.pagination.gotoPage", "3") %>">3</a>
                            <% } %>
                        </li>
                    <% } %>
                    <% if (pages > 3) { %>
                        <li>
                            <span class="pagination-ellipsis">&hellip;</span>
                        </li>
                        <li>
                            <a class="pagination-link" href="/staff/audit?page=<%= pages %>" aria-label="<%= __("common.pagination.gotoPage", pages) %>"><%= pages %></a>
                        </li>
                    <% } %>
                <% } else { %>
                    <li>
                        <a class="pagination-link" href="/staff/audit?page=1" aria-label="<%= __("common.pagination.gotoPage", "1") %>">1</a>
                    </li>
                    <li>
                        <span class="pagination-ellipsis">&hellip;</span>
                    </li>
                    <% if (Number(req.query.page) === pages) { %>
                        <li>
                            <a class="pagination-link" href="/staff/audit?page=<%= Number(req.query.page) - 2 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) - 2) %>"><%= Number(req.query.page) - 2 %></a>
                        </li>
                    <% } %>
                    <li>
                        <a class="pagination-link" href="/staff/audit?page=<%= Number(req.query.page) - 1 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) - 1) %>"><%= Number(req.query.page) - 1 %></a>
                    </li>
                    <li>
                        <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", req.query.page) %>" aria-current="page"><%= req.query.page %></a>
                    </li>
                    <% if (Number(req.query.page) !== pages) { %>
                        <li>
                            <a class="pagination-link" href="/staff/audit?page=<%= Number(req.query.page) + 1 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) + 1) %>"><%= Number(req.query.page) + 1 %></a>
                        </li>
                    <% } %>
                    <% if (Number(req.query.page <= (pages - 2))) { %>
                        <li>
                            <span class="pagination-ellipsis">&hellip;</span>
                        </li>
                        <li>
                            <a class="pagination-link" href="/staff/audit?page=<%= pages %>" aria-label="<%= __("common.pagination.gotoPage", pages) %>"><%= pages %></a>
                        </li>
                    <% } %>
                <% } %>
            </ul>
        </nav>
    </div>
</div>
<style>
    .str {
        color: #ff8d00;
    }
    .kwd {
        color: #1bff2d;
    }
    .clo, .opn, .pun {
        color: #5089ff;
    }
    .lit {
        color: #c395ff;
    }
    code {
        font-family: "Cascadia Code", monospace;
    }
</style>
<script>
    function toggleShowRaw(log) {
        const logDocument = document.getElementById(`rawLOG-${log}`);
        document.getElementById(`rawLOG-${log}`).style.display === "none" ? logDocument.style.display = "block" : logDocument.style.display = "none";
    }
</script>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
<%- include("../../partials/footer.ejs") %>