</div>
<footer class="footer">
<div class="container">
<div class="panel panel-default">
<div class="panel-body">
    <table style="border-collapse: collapse; width: 100%; background: none">
    <tbody>
    <tr>
        <td style="padding: 0; vertical-align: middle; text-align: left; width: 100%" class="text-normal">
            &copy; <?= date("Y") ?> <?= htmlentities(env("MYSTIC_FORUM_COPYRIGHT") ?? env("MYSTIC_FORUM_TITLE") ?? "Forum") ?>.
            Powered by <a href="https://git.jkohl.link/mystic-forum.git/tag/?h=v<?= htmlentities(urlencode(MYSTICBB_VERSION)) ?>">mysticBB v<?= htmlentities(MYSTICBB_VERSION) ?></a>.
        </td>
        <td style="padding: 0; vertical-align: middle; text-align: right; white-space: nowrap" class="text-normal">
            <form action="?_action=settheme" class="form-inline seamless-inline" method="post">
                <input type="hidden" name="next" value="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>">
                <div class="form-group">
                    <label for="theme-select"><?= __("Theme:") ?></label>
                    <select class="form-control input-sm auto-submit" id="theme-select" name="theme">
                        <?php foreach ($availableThemes as $themeKey => $themeInfo): ?>
                            <option value="<?= htmlentities($themeKey) ?>" <?= $themeKey === $currentTheme ? " selected" : "" ?>><?= htmlentities($themeInfo->name) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </form>
            &nbsp;&nbsp;&nbsp;
            <form action="?_action=setlang" class="form-inline seamless-inline" method="post">
                <input type="hidden" name="next" value="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>">
                <div class="form-group">
                    <label for="lang-select"><?= __("Language:") ?></label>
                    <select class="form-control input-sm auto-submit" id="lang-select" name="lang">
                        <?php foreach ($availableLangs as $langKey => $langName): ?>
                            <option value="<?= htmlentities($langKey) ?>" <?= $langKey === $currentLang ? " selected" : "" ?>><?= htmlentities($langName) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </form>
        </td>
    </tr>
    </tbody>
    </table>
</div>
</div>
</div>
</footer>

<script type="text/javascript">
    $(function() {
        function insertAroundSelection(textarea, before, after) {
            var start = textarea.selectionStart;
            var end = textarea.selectionEnd;
            var text = textarea.value;
            var pre = text.substring(0, start);
            var inner = text.substring(start, end);
            var post = text.substring(end);
            start += before.length;
            end += before.length;
            text = pre + before + inner + after + post;
            textarea.value = text;
            textarea.focus();
            textarea.selectionStart = start;
            textarea.selectionEnd = end;
        }

        function getTextarea(btn) {
            return $($(btn).attr("data-area"))[0];
        }

        var commands = {
            bold: function(textarea) {
                insertAroundSelection(textarea, "[b]", "[/b]");
            },
            italic: function(textarea) {
                insertAroundSelection(textarea, "[i]", "[/i]");
            },
            underline: function(textarea) {
                insertAroundSelection(textarea, "[u]", "[/u]");
            },
            strikethrough: function(textarea) {
                insertAroundSelection(textarea, "[s]", "[/s]");
            },
            sup: function(textarea) {
                insertAroundSelection(textarea, "[^]", "[/^]");
            },
            sub: function(textarea) {
                insertAroundSelection(textarea, "[_]", "[/_]");
            },
            quote: function(textarea) {
                insertAroundSelection(textarea, "> ", "");
            },
            spoiler: function(textarea) {
                insertAroundSelection(textarea, "[spoiler]", "[/spoiler]");
            }
        }

        $("button[data-editor-command]").attr("data-toggle", "tooltip").attr("data-placement", "bottom").click(function() {
            var command = $(this).attr("data-editor-command");
            var textarea = getTextarea(this);
            commands[command](textarea);
        }).tooltip();
    });
</script>

<script>
$(function() {
    var _messages = <?= json_encode([
        "selectFiles" => [
            ___("Select file", "Select files", 1),
            ___("Select file", "Select files", 2),
        ],
        "filesSelected" => [
            ___("%n% file selected", "No files selected", 0),
            ___("%n% file selected", "%n% files selected", 1),
            ___("%n% file selected", "%n% files selected", 2),
        ],
    ]) ?>

    $(".auto-submit").on("change", function() {
        $(this)[0].form.submit();
    });

    $("._time").each(function(i, e) {
        var date = new Date($(e).text());
        $(e).text(date.toLocaleString());
    });
    $("._date").each(function(i, e) {
        var date = new Date($(e).text());
        $(e).text(date.toLocaleDateString());
    });
    $("._time-only").each(function(i, e) {
        var date = new Date($(e).text());
        $(e).text(date.toLocaleTimeString());
    });

    $("input[type=file]").each(function(i, e) {
        var isMultiple = !!$(e).prop("multiple");
        var isSmall = !!$(e).hasClass("small");
        var $input = $('<input type="text" readonly class="form-control" />').attr("placeholder", _messages.filesSelected[0]).css("text-overflow", "ellipsis");
        var $btn = $('<button class="btn btn-default" type="button"></button>');
        if (isSmall) {
            $input.addClass("input-sm");
            $btn.addClass("btn-sm");
        }
        $(e).after($('<div class="input-group file-input-group"></div>').append(
            $input,
            $('<span class="input-group-btn"></span>').append(
                $btn.text(_messages.selectFiles[isMultiple ? 1 : 0]).click(function() {
                    $(e).click();
                })
            )
        )).addClass("sr-only");
        $(e).on("change", function() {
            var files = $(e)[0].files;
            if (files.length < 1)
                $input.val("");
            else if (files.length === 1)
                $input.val(files[0].name);
            else
                $input.val(_messages.filesSelected[2].replace("%n%", files.length));
        });
    })
});
</script>

</body>
</html>