<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title>修改中间件</title>
    <%--    <link rel="stylesheet" href="${ctx}/css/plugin/bootstrap/bootstrap.css">--%>
    <link rel="stylesheet" href="${ctx}/css/plugin/metroStyle/metroStyle.css">
    <link rel="stylesheet" href="${ctx}/js/plugin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/css/plugin/datatables/buttons.dataTables.min.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/bootstrap/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/bootstrap/bootstrap-datetimepicker.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/bootstrapSwitch/bootstrap-switch.min.css">
    <link rel="stylesheet" href="${ctx}/css/basic.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/iconfont/iconfont.css">
    <style>
        .td {
            text-align: center;
            height: 48px;
            line-height: 48px
        }

        #vdlist {
            width: 1720px;
            min-width: 1720px;
        }

        body {
            overflow: hidden;
        }

        .table > tbody > tr > td {
            padding: 3px;
            line-height: 1.42857143;
            vertical-align: top;
            border-top: 1px solid #ddd;
        }
    </style>
</head>
<body class="mbody pdt5 pdb5" style="text-align: center">
<div class="layui-form-item" style="width: 400px">
    <label style="width: 26%;">中间件名称:</label>
    <input type="text" id="middName" placeholder="请输入名称"
           autocomplete="off" style="width: 62%; margin-top: 10px;height: 30px">
</div>
<div class="layui-form-item" id="ok" style="width: 400px;">
    <label style="width: 26%;" class="ml10">网络参数:</label>
    <input type="text" onkeyup="this.value=this.value.replace(/\D/g,'')"
           onafterpaste="this.value=this.value.replace(/\D/g,'')" id="ipEnd1" autocomplete="off" maxlength="3"
           style="width: 13.5%;margin-top: 12px;height:30px;">.
    <input type="text" onkeyup="this.value=this.value.replace(/\D/g,'')"
           onafterpaste="this.value=this.value.replace(/\D/g,'')" id="ipEnd2" maxlength="3" autocomplete="off"
           style="width: 13.5%; margin-top: 10px;height: 30px">.
    <input type="text" onkeyup="this.value=this.value.replace(/\D/g,'')"
           onafterpaste="this.value=this.value.replace(/\D/g,'')" id="ipEnd3" autocomplete="off" maxlength="3"
           style="width:13.5%; margin-top: 10px;height: 30px">.
    <input type="text" onkeyup="this.value=this.value.replace(/\D/g,'')"
           onafterpaste="this.value=this.value.replace(/\D/g,'')" id="ipEnd4" autocomplete="off" maxlength="3"
           style="width:13.5%; margin-top: 10px;height: 30px">
</div>
<div class="layui-form-item" style="width: 400px" id="noPro">
    <label style="width: 26%;margin-left: 22px;">端口号:</label>
    <input type="text" id="port" onkeyup="this.value=this.value.replace(/\D/g,'')"
           onafterpaste="this.value=this.value.replace(/\D/g,'')" placeholder="请输入端口号" autocomplete="off"
           style="width: 62%; margin-top: 10px;height: 30px">
</div>
<div>
    <button type="button" class="layui-btn themeBGColor"
            id="updateMiddRun"
            style="margin-top: 10px;">提交
    </button>
    <button type="reset" class="layui-btn cancleBGColor"
            style="margin-left: 10%; margin-top: 10px"
            id="close">取消
    </button>
</div>
</body>
<input type="hidden" id="middIndex">
<script src="${ctx}/js/plugin/jquery.min.js"></script>
<script src="${ctx}/js/plugin/ztree/jquery.ztree.core.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap.min.js"></script>
<script src="${ctx}/js/plugin/layui/layer.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap-datetimepicker.min.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${ctx}/js/plugin/bootstrapSwitch/bootstrap-switch.min.js"></script>
<script src="${ctx}/js/basic.js"></script>
<script src="${ctx}/js/color.js"></script>
<script src="${ctx}/jspJS/utils/timeControl.js"></script>
<script src="${ctx}/js/plugin/xss/xss.js"></script>
<script src="${ctx}/jspJS/utils/loading.js"></script>
<script src="${ctx}/jspJS/utils/judgeAjaxStatus.js"></script>
<script>
    var middIndex = parent.$("#middIndex").val();
    $(document).ready(function () {
        //查询用户的信息
        $.ajax({
            type: "POST",
            url: "/pqs9900/middRun/selectMiddRun",
            data: {
                middIndex: middIndex
            },
            success: function (data) {

                $("#middName").val(data.name);
                $("#port").val(data.port);
                var ipEnd = data.ip;
                ipEnd = ipEnd.split(".");
                $("#ipEnd1").val(ipEnd[0]);
                $("#ipEnd2").val(ipEnd[1]);
                $("#ipEnd3").val(ipEnd[2]);
                $("#ipEnd4").val(ipEnd[3]);
            }
        })
    })
    $("#updateMiddRun").click(function () {
        var middName = $("#middName").val();
        middName = middName.replace(/(^\s*)|(\s*$)/g, '');
        middName = filterXSS(middName);
        var re = middNames;// 只能输入中文
        if (!re.test(middName)) {
            layer.tips('名称格式错误', '#middName', {
                tips: [1, 'red'], time: 2000
            });
            $("#middName").val("");
        } else {
            var ipEnd1 = $("#ipEnd1").val();
            var ipEnd2 = $("#ipEnd2").val();
            var ipEnd3 = $("#ipEnd3").val();
            var ipEnd4 = $("#ipEnd4").val();
            var ipEnd = ipEnd1 + "." + ipEnd2 + "." + ipEnd3 + "." + ipEnd4;
            ipEnd = ipEnd.replace(/(^\s*)|(\s*$)/g, '');
            ipEnd = filterXSS(ipEnd);
            var re = ipz;
            if (!re.test(ipEnd)) {
                layer.tips('ip地址格式不正确', "#ipEnd4",
                    {tips: [2, 'red']});
                $("#ipEnd1").val("");
                $("#ipEnd2").val("");
                $("#ipEnd3").val("");
                $("#ipEnd4").val("");
            } else {
                var port = $("#port").val();
                var re = numberz;// 只能输入数字
                port = filterXSS(port);
                if (!re.test(port)) {
                    layer.tips('端口号只能为数字', '#port', {
                        tips: [1, 'red'],
                        time: 2000
                        // 还可配置颜色
                    });
                    $("#port").val("");
                } else {
                    $.ajax({
                        type: "POST",
                        url: "/pqs9900/middRun/updateMiddRun",
                        dataType: "text",
                        data: {
                            middIndex:middIndex,
                            middRunName: middName,
                            ip: ipEnd,
                            port: port
                        },
                        success: function (data) {
                            var info = $.parseJSON(data);
                            if (info.code == 200) {
                                layer.msg(info.message,
                                    {
                                        icon: 6,
                                        time: 2000
                                    }, function () {
                                        parent.layer.closeAll();
                                        parent.getTree();
                                        parent.getMiddRunDetails();
                                    });
                            } else {
                                layer.msg(info.message,
                                    {
                                        icon: 5,
                                        time: 2000
                                    }
                                );
                            }
                        }
                    });
                }
            }
        }
    })
    $("#close").click(function () {
        parent.layer.closeAll();
    })
</script>
</html>
