function logger(msg) {
    document.getElementById("logger").innerHTML = msg;
}

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

/*function post(URL, PARAMS) {
    var temp = document.createElement("form");
    temp.action = URL;
    temp.method = "post";
    temp.style.display = "none";
    for (var x in PARAMS) {
        var opt = document.createElement("textarea");
        opt.name = x;
        opt.value = PARAMS[x];
        // alert(opt.name)
        temp.appendChild(opt);
    }
    document.body.appendChild(temp);
    temp.submit();
    return temp;
}*/

//读取身份证
function readIdInfo() {
    // logger('读取身份证');
    send_command(
        "idReaderReadInfo",
        "nothing",
        function (receivedData) {
            var idInfo = JSON.parse(receivedData);
            // logger(receivedData);
            // logger(idInfo.name);
            // base64="data:image/jpeg;base64," + idInfo.idImg;
            // document.getElementById("idPhoto").src = base64;

            //alert(idInfo.status);
            if (idInfo.status = 100) {
                
            function saveInfo(){
                m_info=receivedData;
                save_info(m_info);
                //window.location.href = "idcardinfo.html";
                window.location.href = "/IdCardInfo/Index";
            }
            saveInfo();
            }
            else if (idInfo.status=200){
                //window.location.reload('idreader.html');
                window.location.href = "/Home/Index";
            }
            // post('test.php',{receivedData:receivedData});
        });
}
readIdInfo();
