function logger(msg) {
    document.getElementById("logger").innerHTML = msg;
}
//离开关闭身份证读卡器
function stopidcard() {
    send_command(
        "stopRead",
        "nothing",
        function (receivedData) {
            logger(receivedData);
        });
}

var flg = getUrlParam('flg');
//读取身份证
function readIdInfo() {
    // logger('读取身份证');
    send_command(
        "idReaderReadInfo",
        "nothing",
        function (receivedData) {
            var idInfo = JSON.parse(receivedData);
            if (idInfo.status == 100) {
                function saveInfo() {
                    m_info = receivedData;
                    save_info(m_info);
                    if (flg == "1") {
                        window.location.href = "/PjPy/DeptView";
                    }
                    else {
                        window.location.href = "/PjPy/Project";
                    }
                }
                saveInfo();
            }
            else if (idInfo.status == 200) {
                window.location.href = "/";
            }
        });
}

readIdInfo();

//获取url中的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}

