view_b783ea478f96d3317fdff50750f5cc39.c 9.36 KB
/*
   Generated from client/settings/function/captureSettings.esp
 */
#include "esp.h"

static void view_b783ea478f96d3317fdff50750f5cc39(HttpConn *conn) {
  espRenderBlock(conn, "<!DOCTYPE html>\r\n\
<html>\r\n\
\r\n\
<head>\r\n\
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n\
    <title>抓拍参数设置</title>\r\n\
    <link href=\"../../css/frame.css\" rel=\"stylesheet\" />\r\n\
    <link href=\"../../scripts/easyui/themes/default/easyui.css\" rel=\"stylesheet\" />\r\n\
    <link href=\"../../scripts/easyui/themes/icon.css\" rel=\"stylesheet\" />\r\n\
    <link href=\"../../css/reboot.css\" rel=\"stylesheet\" />\r\n\
    <style type=\"text/css\">\r\n\
        #childPageIframe {\r\n\
            width: 100%;\r\n\
            height: 100%;\r\n\
            border: 0;\r\n\
            padding: 0;\r\n\
            margin: 0;\r\n\
        }\r\n\
\r\n\
        #captureModeForm {\r\n\
            display: inline;\r\n\
        }\r\n\
    </style>\r\n\
</head>\r\n\
\r\n\
<body>\r\n\
    <div class=\"easyui-layout\" data-options=\"fit:true\">\r\n\
        <div data-options=\"region:'north',border:false\" style=\"height: 40px;padding:8px 0 8px 7px;background-color: #F3F5F6;\">\r\n\
            <span>抓拍模式</span>\r\n\
            <form id=\"captureModeForm\">\r\n\
                <select id=\"captureMode\" name=\"220\">\r\n\
                </select>\r\n\
                ", 1089);
inputSecurityToken();   espRenderBlock(conn, "\r\n\
            </form>\r\n\
        </div>\r\n\
        <div data-options=\"region:'center',border:false\" style=\"overflow: hidden;\">\r\n\
            <iframe src=\"\" id=\"childPageIframe\" frameborder=\"0\"></iframe>\r\n\
        </div>\r\n\
    </div>\r\n\
\r\n\
    <script src=\"../../scripts/easyui/jquery.min.js\"></script>\r\n\
    <script src=\"../../scripts/easyui/jquery.easyui.min.js\"></script>\r\n\
    <script src=\"../../scripts/easyui/locale/easyui-lang-zh_CN.js\"></script>\r\n\
    <script src=\"../../scripts/utilities.js\"></script>\r\n\
    <script type=\"text/javascript\">\r\n\
        var parameterAdaptor = new ParameterAdaptor();\r\n\
        var rebootManager = new RebootManager();\r\n\
\r\n\
        // 仅供开发时测试使用\r\n\
        var isDebug = false;\r\n\
\r\n\
        $().ready(function () {\r\n\
            // 加载所有抓拍模式\r\n\
            loadAllCaptureModes();\r\n\
            // 跳转子页面\r\n\
            $(\"#captureMode\").change(confirmCaptureModeChange);\r\n\
\r\n\
            if (isDebug) {\r\n\
                $(\"#childPageIframe\").attr(\"src\", \"capture/noMotorVehicleViolation.esp\");\r\n\
            }\r\n\
        });\r\n\
\r\n\
        // 加载相机抓拍模式,首先加载所有可用的模式,然后再加载当前的模式,并显示对应的页面\r\n\
        function loadAllCaptureModes() {\r\n\
            var url = \"/do/trafficController/configVal?t=\" + new Date().getTime();\r\n\
            if (isDebug) {\r\n\
                url = \"../advanced/xml/VasconfigInfo.xml\";\r\n\
            }\r\n\
            $.get(url, null, function (xmlData) {\r\n\
                var xmlDoc = null;\r\n\
                try {\r\n\
                    var xmlDoc = $.parseXML(xmlData);\r\n\
\r\n\
                } catch (error) {\r\n\
                    $.messager.alert(\"错误\", \"解释参数XML错误!(XML格式不正确)\", \"error\");\r\n\
                    if (window.console) {\r\n\
                        console.error(\"解析参数XML失败!\");\r\n\
                    }\r\n\
                    return;\r\n\
                }\r\n\
                // 从中解析出抓拍参数\r\n\
                var captureModePath = \"root>功能配置>抓拍参数配置>抓拍模式>AttribRange\";\r\n\
                var modeTextObjs = $(xmlDoc).find(captureModePath);\r\n\
                if (modeTextObjs.length === 0) {\r\n\
                    $.messager.alert(\"错误\", \"获取相机抓拍模式失败!\", \"error\");\r\n\
                    if (window.console) {\r\n\
                        console.error(\"从xml中未能解析到节点:/root/功能配置/抓拍参数配置/抓拍模式/AttribRange\");\r\n\
                    }\r\n\
                    return;\r\n\
                }\r\n\
                var allModes = modeTextObjs[0].textContent ? modeTextObjs[0].textContent : modeTextObjs[0].text;\r\n\
                var comboboxData = getComboboxData(allModes);\r\n\
                // 填充到下拉框\r\n\
                $(\"#captureMode\").html(\"\");\r\n\
                var options = [];\r\n\
                for (var index = 0; index < comboboxData.length; index++) {\r\n\
                    var element = comboboxData[index];\r\n\
                    options.push(\"<option value='\" + element.id + \"'>\" + element.text + \"</option>\");\r\n\
                }\r\n\
                $(\"#captureMode\").html(options.join(\"\"));\r\n\
                // 调用加载当前相机模式的方法\r\n\
                loadActiveCaptureMode();\r\n\
            }, \"text\");\r\n\
        }\r\n\
\r\n\
        function getComboboxData(pRangeString) {\r\n\
            var enumRegex = /(-?\\d+)-(([0-9a-zA-Z\\u4e00-\\u9faf]+)(&amp;)?)?/g;//枚举类型的正则表达式\r\n\
            var comboboxData = [];\r\n\
            var match = enumRegex.exec(pRangeString);\r\n\
            while (match != null) {\r\n\
                comboboxData.push({\r\n\
                    id: match[1],\r\n\
                    text: match.length >= 4 ? match[3] : \"\"\r\n\
                });\r\n\
                match = enumRegex.exec(pRangeString);\r\n\
            }\r\n\
            return comboboxData;\r\n\
        }\r\n\
\r\n\
        //加载抓拍模式\r\n\
        function loadActiveCaptureMode() {\r\n\
            var refererInfo = \"cameraSettings\";\r\n\
            parameterAdaptor.getParameters(refererInfo, function (data) {\r\n\
                if (data && data.feedback) {\r\n\
                    $(\"#captureModeForm\").form(\"load\", data.feedback);\r\n\
                }\r\n\
                //显示对应的页面\r\n\
                showChildPage();\r\n\
            });\r\n\
        }\r\n\
\r\n\
        //显示对应的子页面\r\n\
        function showChildPage() {\r\n\
            // 获取模式下拉框的值\r\n\
            var modeValue = $(\"#captureMode\").find(\"option:selected\").val();\r\n\
            var pageUrl = \"\";\r\n\
            switch (modeValue) {\r\n\
                //路口电警\r\n\
                case \"0\":\r\n\
                    pageUrl = \"capture/intersection.esp\";\r\n\
                    break;\r\n\
                // 路段电警,视频卡口\r\n\
                case \"1\":\r\n\
                case \"2\":\r\n\
                    pageUrl = \"capture/videoBayonet.esp\";\r\n\
                    break;\r\n\
                // 移动公交\r\n\
                case \"3\":\r\n\
                    pageUrl = \"capture/busSetting.esp\";\r\n\
                    break;\r\n\
                // 非机动车违法\r\n\
                case \"4\":\r\n\
                    pageUrl = \"capture/noMotorVehicleViolation.esp\";\r\n\
                    break;\r\n\
                default:\r\n\
            }\r\n\
            if (pageUrl) {\r\n\
                $(\"#childPageIframe\").attr(\"src\", pageUrl);\r\n\
            }\r\n\
        }\r\n\
\r\n\
        //向用户确认抓拍模式变更,保存参数并重启相机\r\n\
        function confirmCaptureModeChange() {\r\n\
            var captureMode = $(\"#captureMode\").find(\"option:selected\").val();\r\n\
            // debug模式 直接显示对应的页面\r\n\
            if (isDebug) {\r\n\
                showChildPage();\r\n\
                return;\r\n\
            }\r\n\
            //隐藏ROIOcx\r\n\
            hideRoiOcx();\r\n\
\r\n\
            $.messager.confirm(\"提示\", \"变更抓拍模式需要重启相机,确认变更吗?\", function (isConfirm) {\r\n\
                if (isConfirm) {\r\n\
                    //确认变更,保存参数\r\n\
                    var formObj = $(\"#captureModeForm\");\r\n\
                    parameterAdaptor.saveParameters(formObj, function (data) {\r\n\
                        if (data.error) {\r\n\
                            $(\"#childPageIframe\").hide();\r\n\
                            rebootManager.sendRebootCmd();\r\n\
                        } else {\r\n\
                            $.messager.alert(\"提示\", \"切换抓拍模式失败!\", \"error\");\r\n\
                        }\r\n\
                    }, \"GET\");\r\n\
                }\r\n\
                //显示RoiOcx\r\n\
                showRoiOcx();\r\n\
            });\r\n\
        }\r\n\
\r\n\
        function hideRoiOcx() {\r\n\
            var ocx = childPageIframe.document.getElementById(\"roiOcxObject\");\r\n\
            if (ocx) {\r\n\
                ocx.style.display = \"none\";\r\n\
            }\r\n\
        }\r\n\
\r\n\
        function showRoiOcx() {\r\n\
            var ocx = childPageIframe.document.getElementById(\"roiOcxObject\");\r\n\
            if (ocx) {\r\n\
                ocx.style.display = \"block\";\r\n\
            }\r\n\
        }\r\n\
\r\n\
    </script>\r\n\
</body>\r\n\
\r\n\
</html>", 7028);
}

ESP_EXPORT int esp_view_b783ea478f96d3317fdff50750f5cc39(HttpRoute *route, MprModule *module) {
   espDefineView(route, "client/settings/function/captureSettings.esp", view_b783ea478f96d3317fdff50750f5cc39);
   return 0;
}