<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="bootstrap/css/style.min.css" rel="stylesheet">
</head>
  
<body>
<div class="container-fluid p-t-15">
  <div class="row">
    <div class="col-lg-6">
      <div class="card">
        <header class="card-header"><div class="card-title"> <code>handlergen</code> 代码生成工具</div></header>
        <div class="card-body">
          <div class="callout callout-warning mb-3">注意：请在 <code>Mac</code> 或 <code>Linux</code> 环境执行。</div>

          <div class="form-group">
            <label for="exampleFormControlInput1">handler 名称，例如：<code>user_handler</code></label>
            <input type="text" class="form-control" id="handlerName" placeholder="请输入 handler 名称">
          </div>

          <p>
            <button type="button" id="btnOk" class="btn btn-primary">确认</button>
            <button type="button" id="btnLoading" class="btn btn-primary" disabled style="display: none">
              <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
              执行中...
            </button>
          </p>

        </div>
      </div>
    </div>

    <div class="col-lg-6">
      <div class="card">
        <header class="card-header"><div class="card-title">执行结果</div></header>
        <div class="card-body">
          <pre id="resultDiv"></pre>
        </div>
      </div>
    </div>

  </div>
</div>

<script type="text/javascript" src="bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $("#btnOk").click(function(){
      var handlerName = $("#handlerName").val();
      if (!handlerName) {
        $.alert({
          title: '温馨提示',
          icon: 'mdi mdi-alert',
          type: 'orange',
          content: '请输入 handler 名称。',
        });
        return false;
      }

      $("#resultDiv").text("");
      $(this).hide();
      $("#btnLoading").show();

      $.post("/handlergen_exec",{name:handlerName},function (data) {
        $("#resultDiv").text(data);
        $("#btnLoading").hide();
        $("#btnOk").show();
      })

    })
  })
</script>
</body>
</html>
