{{ define "admin/upload.html" }}
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>SIF 小助手</title>
    {{ template "admin/nav/css.html" . }}
    <style>
        .upload-help li {
            list-style-type: decimal !important;
            margin-left: 10px;
        }
    </style>
</head>

<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        {{ template "admin/nav/header.html" . }}
        {{ template "admin/nav/side.html" . }}

        <div class="layui-body">
            <form class="layui-form layui-col-md6" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <textarea name="content" id="card-content" placeholder="每行一个，格式：卡片ID,技能等级&#10;例如：3885,8"
                            class="layui-textarea" style="min-height: 220px;"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-block">
                        <div class="layui-collapse">
                            <div class="layui-colla-item">
                                <h2 class="layui-colla-title">使用帮助</h2>
                                <div class="layui-colla-content">
                                    <ol class="upload-help">
                                        <li>从 <a href="https://card.niconi.co.ni/" target="_blank">LLSIF
                                                查卡器</a> 查询需要导入的卡片 ID，卡片信息上的 No.xxx 数字。
                                        </li>
                                        <li>在输入框中按<b>卡片 ID,技能等级</b>的格式（例如 SDS 果，技能 8 级则填入
                                            3885,8）填写需要导入的卡片，每张卡片单独一行。</li>
                                        <li>分隔符逗号为<b>半角 ,</b> 而非<b>全角 ，</b>。</li>
                                        <li>仅需要设置技能等级，卡片默认等级MAX，宝石请在游戏内设置。</li>
                                        <li>仅支持导入UR卡片。</li>
                                        <li>仅支持导入国服拥有的卡片。</li>
                                    </ol>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" id="test9">开始导入</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script src="/static/js/layui.js"></script>
    <script>
        layui.use(['layer'], function () {
            var $ = layui.jquery
                , layer = layui.layer;

            $("#test9").click(function () {
                const content = $("#card-content").val();
                $.post("/admin/upload", { content: content }, function (res) {
                    layer.msg(res.msg);
                    if (res.error == 0) {
                        $("#card-content").val("");
                    }
                }).fail(function () {
                    layer.msg("请求失败，请稍后再试");
                });
            });
        });
    </script>
</body>

</html>
{{ end }}
