#include("layout.html")
#@layout()
#define content()
<form class="form-horizontal form-setting"
      action="#(CPATH)/install/install" method="post" id="form">
    <div class="form-group">
        <div class="col-sm-12">
            您好，您当前设置的是已经存在数据的 JPress 数据库。
        </div>
    </div>
    <h4 class="page-header" style="margin-top: 20px">重置管理员</h4>

    <div class="form-group">
        <label class="col-sm-2 control-label">新账号</label>
        <div class="col-sm-9">
            <input type="input" class="form-control" placeholder="新管理员账号"
                   name="username">
            <p class="help-block" style="color: red">若想保留之前的管理员账号，请不要填写任何内容。</p>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">密码</label>
        <div class="col-sm-9">
            <input type="password" class="form-control" placeholder="及密码"
                   name="pwd">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">确认密码</label>
        <div class="col-sm-9">
            <input type="password" class="form-control" placeholder="..."
                   name="confirmPwd">
            <p class="help-block">非常重要！请务必要牢记管理员的账号和密码。</p>
        </div>
    </div>

    <div class="row">
        <div class="col-xs-offset-4 col-xs-4 " style="padding-top: 15px">
            <button type="button" id="submit" class="btn btn-primary btn-block btn-flat"> 完成</button>
        </div>
    </div>

</form>
#end

#define script()
<script src="#(CPATH)/static/components/jquery/jquery.min.js"></script>
<script src="#(CPATH)/static/components/jquery/jquery.form.min.js"></script>
<script src="#(CPATH)/static/components/bootstrap/js/bootstrap.min.js"></script>
<script>

    $("#submit").on("click", function () {
        $("#form").ajaxSubmit({
            type: "post",
            success: function (data) {
                if (data.state == "ok") {
                    alert("恭喜您，JPress安装成功！登录后台可以进行更多的设置...");
                    location.href = "#(CPATH)/admin/login";
                } else {
                    alert(data.message);
                }
            },
            error: function () {
                alert("系统错误，请联系管理员。");
            }
        });
    })
</script>
#end