@{
    Layout = null;
    bool Done = false;
    bool VersionError = ViewBag.VersionError;
    if (ViewBag.Done != null) { Done = ViewBag.Done; }
}

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>证书更新</title>
    <link href="/Content/Themes/Base/Css/bootstrap.css" type="text/css" rel="stylesheet" />
    <style type="text/css">
        #updateTb tr {
            height: 42px;
        }

        #loading {
            display: none;
        }
    </style>
</head>
<body>
    <div style="width: 600px;">
        @using (Html.BeginForm("UpdateCert", "License", FormMethod.Post))
            {
            @Html.AntiForgeryToken();
            <table width="100%" border="0" cellspacing="3" cellpadding="3" id="updateTb">
                <tbody>
                    <tr>
                        <td style="width: 120px; text-align: right;">当前证书版本：</td>
                        <td>
                            @ViewBag.CertType V@(ViewBag.CertVersion)
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top; text-align: right;">更新方式：</td>
                        <td style="vertical-align: top;">
                            <input type="radio" id="activeType1" name="activeType" checked="checked" disabled="disabled" value="true" class="input_cade" /><label for="activeType1">在线</label>
                            <div style="clear: both; height: 10px;"></div>
                            <b>联网更新证书需要一到五分钟，视您的网络速度而定。</b>
                        </td>
                    </tr>
                    @if (ViewBag.Message != null)
                    {
                        <tr id="updateResultRow">
                            <td colspan="2" style="text-align: center;">
                                <span id="lupdateResult" style="color: #FF3300;">@ViewBag.Message</span>
                            </td>
                        </tr>
                    }
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                            <input type="submit" name="btnSubmit" id="btnSubmit" value="更新证书" class="btn btn-primary" />
                            <span id="loading" style="color: red;">
                                <img style="position: relative; top: 4px;" src="/Content/Themes/Base/Images/uploading.gif" alt="正在等待服务器处理中" />
                                正在等待服务器处理中...    
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
        }
    </div>
    <script type="text/javascript">
        function done() {
            top.location.href = "/Account/Login"
        }
        function showLoad() {
            var btn = document.getElementById("btnSubmit");
            var ld = document.getElementById("loading");
            if (btn) btn.className += " disabled";
            if (ld) ld.style.display = "inline-block";
        }
        function bindSubmit() {
            var btn = document.getElementById("btnSubmit");
            //bind(btn, "click", showLoad);
            bind(btn.form, "submit", showLoad);
        }
        function bind(o, type, fn, b) {
            if (b == null) b = false;
            if (o.addEventListener) {
                o.addEventListener(type, fn, b);
            } else {
                btn["on" + type] = fn;
            }
        }
        bindSubmit();
    </script>
    @if (Done)
    {
        <script type="text/javascript">
            window.setTimeout(function () {
                done();
            }, 1500);
        </script>
    }
    @if (VersionError)
    {
        <script type="text/javascript">
            var btn = document.getElementById("btnSubmit");
            showLoad();
            btn.form.submit();
        </script>
    }
</body>
</html>
