{include file="header.htm" /}
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;min-width: auto;">
<style>
    body{margin:0px;}
    body,th,td{font: 13px Arial,Tahoma;line-height: 16px;}
    .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#fff;padding:10px 10px 10px 5px;border-right: 1px solid #ddd;}
    .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#fff;padding:10px 10px 10px 5px;border-right: 1px solid #ddd;vertical-align: middle;}
    .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#F4FCFA;padding:10px 10px 10px 5px;border-right: 1px solid #ddd;}
    .head th{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:10px 10px 10px 5px;font-weight:bold;}
    .head th span{font-weight:normal;}
</style>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="flexigrid">
        <!-- 操作说明 -->
        <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); width: 99%; height: 100%; margin-bottom: 10px;">
            <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
                <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
                <span title="收起提示" id="explanationZoom" style="display: block;"></span>
            </div>
            <ul>
                <li>BOM只有在WINDOWS下采用“记事本”存储为UTF-8时才会有。</li>
                <li>在UTF-8编码文件中BOM在文件头部,占用三个字节,以暗码的形式存在,用来标示该文件属于UTF-8编码。</li>
                <li>现在已经有很多软件识别BOM头,但是还有些不能识别BOM头,例如PHP就不能识别BOM头,这也是用记事本编辑UTF-8编码后执行就会出错的原因了。</li>
            </ul>
        </div>
        <div class="mDiv pt0" style="min-height: 22px;">
            <div class="ftitle">
                <div class="fbutton">
                    <a href="javascript:void(0);" onclick="scan();">
                        <div class="add" title="开始扫描">
                            <span>开始扫描</span>
                        </div>
                    </a>
                </div>
                <div class="fbutton">
                    <a href="javascript:void(0);" data-href="{:weapp_url('Systemdoctor/Systemdoctor/bom_conf')}" onclick="openFullframe(this, '功能配置', '510px', '250px');">
                        <div class="adds" title="功能配置">
                            <span>功能配置</span>
                        </div>
                    </a>
                </div>
            </div>
            <div class="sDiv" style="padding-top: 8px;">
                处理方式:
                <div class="sDiv2" style="font-size: 13px;border:0px; margin-right: 5px;">
                    <label><input type="checkbox" name="is_autoclear" value="1" {notempty name="$conf_data.is_autoclear"} checked="checked" {/notempty}>&nbsp;自动清除</label>
                </div>
            </div>
        </div>
        <div style="margin:0px auto;border: 1px solid #ccc;">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tbody>
                    <tr>
                        <th style="vertical-align:middle; padding-left:5px; padding-top: 10px;">模板存放路径:
                            {$tpl_theme}
                            <input type="hidden" name="path" id="path" value="{$tpl_theme}">
                        </th>
                    </tr>
                </tbody>
            </table>
            <br>
            <div id="div_scanlist" style="display: ;">
                <div style="padding:10px; background-color:#F4F4F4">
                    扫描:<span id="span_scanned">0</span>&nbsp;文件&nbsp;&nbsp;
                    |&nbsp;&nbsp;耗时:<span id="span_spent">0</span>&nbsp;&nbsp;
                    {empty name="$conf_data.is_autoclear"}
                    |&nbsp;&nbsp;请管理员手工清理以下带bom头部信息的文件
                    {/empty}
                </div>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr class="head">
                            <th width="30" style="text-align: center;">No.</th>
                            <th>带bom头部信息文件</th>
                            <th width="300">检测结果</th>
                            <th width="80">操作</th>
                        </tr>
                    </thead>
                    <tbody id="tr_scan_html">
                        <tr>
                            <td class="no-data" style="width: auto !important;" align="center" axis="col0" colspan="5">
                                <i class="fa fa-exclamation-circle"></i>请点击<a href="javascript:void(0);" onclick="scan();">开始扫描</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script>
    function scan()
    {
        var timer = '';
        var loading = layer.msg(
'<span id="progress_speed">准备扫描</span>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请勿刷新页面', 
        {
            time: 3600000, //1小时后后自动关闭
            shade: [0.2] //0.1透明度的白色背景
        });
        //loading层
        var index = layer.load(2, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        var is_autoclear = $('input[name=is_autoclear]:checked').val();
        $.ajax({
            type: "POST",
            url: "{:weapp_url('Systemdoctor/Systemdoctor/bom_scan')}",
            data: {is_autoclear:is_autoclear, _ajax:1},
            dataType: 'json',
            beforeSend: function(xhr) {
                var html = '';
                html += '<tr>';
                html += '    <td class="no-data" style="width: auto !important;" align="center" axis="col0" colspan="5">';
                html += '        <i class="fa fa-exclamation-circle"></i>正在扫描中';
                html += '    </td>';
                html += '</tr>';
                $('#tr_scan_html').html(html);
                $('#div_scanlist').show();
                progressd(0);
            },
            success: function (res) {
                if(res.code == 1){
                    $('#progress_speed').html('已扫描<font id="progress_num">100</font>%');
                    setTimeout(function(){
                        layer.closeAll();
                        $('#span_scanned').html(res.data.scanned);
                        $('#span_count').html(res.data.num_ky);
                        $('#span_spent').html(res.data.spent);
                        $('#tr_scan_html').html(res.data.html);
                        showErrorAlert(res.msg, 6);
                    },1000);
                }else{
                    layer.closeAll();
                    showErrorAlert(res.msg);
                }
            },
            error:function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }

    function progressd(init)
    {
        $.ajax({
            type: "POST",
            url: "{:weapp_url('Systemdoctor/Systemdoctor/bom_progressd')}",
            data: {init:init, _ajax:1},
            dataType: 'json',
            success: function (res) {
                if(res.code == 1){
                    if (res.data.progress > 0) {
                        $('#span_scanned').html(res.data.file_num);
                        $('#span_count').html(res.data.file_num_ky);
                        $('#span_spent').html('计时中');
                        $('#tr_scan_html').html(res.data.html);
                        $('#div_scanlist').show();
                        var progress_num = $('#progress_num').val();
                        if (res.data.progress > progress_num || progress_num == undefined) {
                            $('#progress_speed').html('已扫描<font id="progress_num">' + res.data.progress + '</font>%');
                        }
                    }
                    console.log(res.data.progress)
                    if (100 > res.data.progress) {
                        progressd(1);
                    }
                }
            }
        });
    }

    function bom_clear(obj)
    {
        layer.confirm('确认要处理吗?', {
                shade: layer_shade,
                area: ['480px', '190px'],
                move: false,
                title: '提示',
                btnAlign:'r',
                closeBtn: 3,
                btn: ['确定', '取消'], //按钮
                success: function () {
                    $(".layui-layer-content").css('text-align', 'left');
                }
            }, function(){
                // 确定
                layer_loading('正在处理');
                var md5key = $(obj).attr('data-md5key');
                $.ajax({
                    type : 'POST',
                    url : "{:weapp_url('Systemdoctor/Systemdoctor/bom_clear')}",
                    data : {md5key:md5key, _ajax:1},
                    dataType : 'json',
                    success : function(res){
                        layer.closeAll();
                        if(res.code == 1){
                            $('#msg_'+md5key).html("发现bom头部信息");
                            $('#act_'+md5key).html("<a href='javascript:void(0);' data-md5key='"+md5key+"'>已清理</a>");

                            // $('#tr_scan_html').find('a[data-md5key='+md5key+']').each(function(index, item){
                            //     $(item).parent().parent().remove();
                            // });
                            // if ($('#tr_scan_html tr').length == 0) {
                            //     var html = '';
                            //     html += '<tr>';
                            //     html += '    <td class="no-data" style="width: auto !important;" align="center" axis="col0" colspan="5">';
                            //     html += '        <i class="fa fa-exclamation-circle"></i>没有发现bom头部信息';
                            //     html += '    </td>';
                            //     html += '</tr>';
                            //     $('#tr_scan_html').html(html);
                            // }
                            layer.msg(res.msg, {icon: 1, time: 500});
                        }else{
                            showErrorAlert(res.msg);
                        }
                    },
                    error:function(e){
                        layer.closeAll();
                        showErrorAlert(e.responseText);
                    }
                })
            }, function(index){
                layer.close(index);
                return false;// 取消
            }
        );
    }
</script>
{include file="footer.htm" /}