<link rel="stylesheet" href="<?php echo base_url();?>public/js/date/datedropper.min.css">
<!--<link rel="stylesheet" href="--><?php //echo base_url();?><!--public/js/time/timedropper.css">-->
<script src="<?php echo base_url();?>public/js/date/datedropper.min.js"></script>
<!--<script src="--><?php //echo base_url();?><!--public/js/time/timedropper.js"></script>-->

<div class="content_wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>推送消息</header>
                    <header><i class="fa fa-street-view"></i>推送队列长度：<?php echo $size;?></header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="btn-group" style="margin-bottom:20px;">
                                        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#actionCode">新增推送</button>
                                    </div>
                                    <div class="btn-group" style="margin-bottom:20px;">
                                        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#actionExchangeCode">新增兑换码推送</button>
                                    </div>
                                    <div class="btn-group" style="margin-bottom:20px;">
                                        <a type="button" class="btn btn-success" href="/#push/log">推送记录</a>
                                    </div>
                                    <div class="table-responsive">
                                        <table id="example" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>类型</th>
                                                <th>标题</th>
                                                <th>内容</th>
                                                <th>玩家</th>
                                                <th>备注</th>
                                                <th>推送时间</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php foreach($list as $v) { ?>
                                                <tr>
                                                    <td><?php echo $v['id'];?></td>

                                                    <td>
                                                        <?php
                                                        if($v['pn_type'] == 0){
                                                            echo "立即推送";
                                                        }else if($v['pn_type'] == 1){
                                                            echo "单次推送";
                                                        }else if($v['pn_type'] == 2){
                                                            echo "循环推送";
                                                        }
                                                        ?>
                                                    </td>
                                                    <td>
                                                        <textarea readonly="readonly" class="form-control show" rows="5"><?php echo $v['pn_title'];?></textarea>
                                                    </td>
                                                    <td>
                                                        <textarea readonly="readonly" class="form-control show" rows="5"><?php echo $v['pn_content'];?></textarea>
                                                    </td>
                                                    <td>
                                                  <textarea readonly="readonly" class="form-control" rows="5"><?php
                                                      if($v['pn_player_type'] == 2){
                                                          echo $v['pn_player'];
                                                      }else if($v['pn_player_type'] == 1){
                                                          echo '设备：'.($v['pn_devicetype'] == 1)?'安卓':'IOS';
                                                          echo '<br>';

                                                          if($v['pn_accounttype'] == 2){
                                                              echo '账号类型：全部';
                                                          }else{
                                                              echo '账号类型：'.($v['pn_accounttype'] == 1)?'游客':'FB';
                                                          }
                                                      }
                                                      ?>
                                                    </textarea>
                                                    </td>
                                                    <td><textarea readonly="readonly" class="form-control show" rows="5"><?php echo $v['pn_remark'];?></textarea></td>
                                                    <td><?php echo $v['pn_time'];?></td>
                                                    <?php if(in_array($v['id'],$running)) {?>
                                                        <td><button type="button" class="btn btn-success">等待推送中</button><button type="button" class="btn btn-danger" onclick="deleteTask(<?php echo $v['id'];?>)">停止</button></td>
                                                    <?php }else{?>
                                                        <td><button type="button" class="btn btn-danger" onclick="deleteTask(<?php echo $v['id'];?>)">删除</button></td>
                                                    <?php }?>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <nav>
                                        <ul class="pagination">
                                            <li class="disabled"><a href="#">共<span class="pagetotal"><?php echo $total;?></span>条</a></li>
                                            <?php echo $pageurl;?>
                                        </ul>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>

<div class="modal fade" id="actionCode" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">新建推送</h4>
            </div>
            <form class="form-horizontal J_ajaxForm" role="form" method="post" action="push/actionAddNews" data-callBack="message">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">推送类型</label>
                        <div class="col-sm-9">
                            <select class="form-control" id="select" name="type" onchange="selectChange()">
                                <option value="0">立即推送</option>
                                <option value="1">单次推送</option>
                                <option value="2">循环推送</option>
                            </select>
                        </div>
                    </div>
                    <style>
                        .time{
                            height: 34px;
                            padding: 6px 12px;
                            font-size: 14px;
                            line-height: 1.42857143;
                            color: #555;
                            background-color: #fff;
                            background-image: none;
                            border: 1px solid #ccc;
                            border-radius: 4px;
                        }

                    </style>
                    <div class="form-group" id="divTime" style="display: none">
                        <label class="col-sm-3 control-label">开始时间</label>
                        <div class="col-sm-9">
                            <input type="text" class="time" value="<?php echo date('Y-m-d');?>" id="test-limit2" name="date"/>
                            <input type="text" class="time" name="time" value="00:00:00" id="test-limit3" />
                        </div>
                    </div>

                    <div class="form-group" id="intervalTime" style="display: none">
                        <label class="col-sm-3 control-label">间隔时间（分）</label>
                        <div class="col-sm-9">
                            <input type="number" class="time" name="intervalTime" value="1" min="1"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">玩家类型:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                                <input type="radio" name="usertype" value="2" checked="checked"> 少数(填UID)
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="usertype" value="1"> 全服
                            </label>
                        </div>
                    </div>
                    <div class="form-group hide devicetype">
                        <label class="col-sm-3 control-label">设备:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                                <input type="radio" name="devicetype" value="0" checked="checked"> 全部
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="devicetype" value="1" > 安卓
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="devicetype" value="2"> 苹果
                            </label>
                        </div>
                    </div>
                    <div class="form-group hide accounttype">
                        <label class="col-sm-3 control-label">账号类型:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                                <input type="radio" name="accounttype" value="2" checked="checked">全部
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="accounttype" value="0"> 游客
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="accounttype" value="1"> FB
                            </label>
                        </div>
                    </div>

                    <div class="form-group vip hide">
                        <label class="col-sm-3 control-label">vip等级</label>
                        <div class="col-sm-1">
                            <input type="checkbox" name="1" value="vip" class="form-control" />
                        </div>
                        <div class="col-sm-3">
                            <input type="number" class="form-control" name="vipMin" value="1" min="1" placeholder=""/>
                        </div>
                        <div class="col-sm-3">
                            <input type="number" class="form-control" name="vipMax" value="1" min="1" placeholder=""/>
                        </div>
                    </div>

                    <div class="form-group level hide">
                        <label class="col-sm-3 control-label">等级范围</label>
                        <div class="col-sm-1">
                            <input type="checkbox" name="level" value="1" class="form-control" />
                        </div>
                        <div class="col-sm-3">
                            <input type="number" class="form-control" name="levelMin" value="1" min="1" placeholder=""/>
                        </div>
                        <div class="col-sm-3">
                            <input type="number" class="form-control" name="levelMax" value="1" min="1" placeholder=""/>
                        </div>
                    </div>

                    <div class="form-group userGroup hide">
                        <label class="col-sm-3 control-label">推送分组</label>
                        <div class="col-sm-9">
                            <label class="radio-inline" style="padding-left: 0;">
                                <input type="checkbox" class="checkboxNot" name="userGroup" checked value="0">不限定
                            </label>
                            <?php foreach ($userGroup as $k=>$v) { ?>
                                <label class="radio-inline" style="padding-left: 0;">
                                    <input type="checkbox" class="checkboxInput" name="userGroup[]" value="<?php echo $v['id'];?>"><?php echo $v['name'];?>
                                </label>
                            <?php }?>

                        </div>
                    </div>

                    <div class="form-group uiddiv">
                        <label class="col-sm-3 control-label">UID列表:</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="5" placeholder="UID(一行一个UID)" name="uidlist"></textarea>
                        </div>
                    </div>

                    <div id="langDiv" >
                        <?php foreach ($langList as $k=>$v) { ?>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><?php echo $v;?></label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control <?php echo $k.'_title';?>" value="" name="title[<?php echo $k;?>]"/>
                                    <textarea  rows="7" cols="50" class="form-control <?php echo $k.'_content';?>" name="content[<?php echo $k;?>]"></textarea>
                                </div>
                            </div>
                        <?php }?>
                    </div>

                    <div class="form-group uiddiv">
                        <label class="col-sm-3 control-label">备注:</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="5" placeholder="备注" name="remark"></textarea>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>


<div class="modal fade" id="actionExchangeCode" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">新建兑换码推送</h4>
            </div>
            <form class="form-horizontal J_ajaxForm" role="form" method="post" action="push/actionAddNewsExchange" data-callBack="message">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">推送类型</label>
                        <div class="col-sm-9">
                            <select class="form-control" id="select2" name="type" onchange="selectChange2()">
                                <option value="0">立即推送</option>
                                <option value="1">单次推送</option>
                                <option value="2">循环推送</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">兑换码数量</label>
                        <div class="col-sm-9">
                            <input type="number" class="time" id="num" name="num" value="1" min="1" placeholder="数量"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">兑换码过期</label>
                        <div class="col-sm-9">
                            <input type="text" class="time" id="exchangeDay" name="exchangeDay"  value="<?php echo date('Y-m-d');?>"/>
                            <input type="text" class="time" id="exchangeTime" name="exchangeTime" value="00:00:00" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">金币&体力</label>
                        <div class="col-sm-9">
                            <input type="text" class="time" value="0" min="0" name="coins" placeholder="金币"/>
                            <input type="text" class="time" value="0" min="0" name="spins" placeholder="体力"/>
                        </div>
                    </div>
                    <div class="form-group addOrDelControl" id="vipDiv">
                        <label class="col-sm-3 control-label">奖励道具:</label>
                        <div class="col-sm-9">
                            <div class="col-sm-12" style="margin-top: 1rem;">
                                <button type="button" class="btn btn-success addParent" >新增道具</button>
                            </div>
                        </div>
                    </div>
                    <style>
                        .time{
                            height: 34px;
                            padding: 6px 12px;
                            font-size: 14px;
                            line-height: 1.42857143;
                            color: #555;
                            background-color: #fff;
                            background-image: none;
                            border: 1px solid #ccc;
                            border-radius: 4px;
                        }

                    </style>
                    <div class="form-group" id="divTime2" style="display: none">
                        <label class="col-sm-3 control-label">开始时间</label>
                        <div class="col-sm-9">
                            <input type="text" class="time" value="<?php echo date('Y-m-d');?>" id="test-limit4" name="date"/>
                            <input type="text" class="time" id="test-limit5" name="time" value="00:00:00" />
                        </div>
                    </div>

                    <div class="form-group" id="intervalTime2" style="display: none">
                        <label class="col-sm-3 control-label">间隔时间（分）</label>
                        <div class="col-sm-9">
                            <input type="number" class="time" name="intervalTime" value="1" min="1"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">玩家类型:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                                <input type="radio" name="usertype" value="2" checked="checked"> 少数(填UID)
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="usertype" value="1"> 全服
                            </label>
                        </div>
                    </div>
                    <div class="form-group hide devicetype">
                        <label class="col-sm-3 control-label">设备:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                                <input type="radio" name="devicetype" value="0" checked="checked"> 全部
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="devicetype" value="1" > 安卓
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="devicetype" value="2"> 苹果
                            </label>
                        </div>
                    </div>
                    <div class="form-group hide accounttype">
                        <label class="col-sm-3 control-label">账号类型:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                                <input type="radio" name="accounttype" value="2" checked="checked">全部
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="accounttype" value="0"> 游客
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="accounttype" value="1"> FB
                            </label>
                        </div>
                    </div>

                    <div class="form-group vip hide">
                        <label class="col-sm-3 control-label">vip等级</label>
                        <div class="col-sm-1">
                            <input type="checkbox" name="1" value="vip" class="form-control" />
                        </div>
                        <div class="col-sm-3">
                            <input type="number" class="form-control" name="vipMin" value="1" min="1" placeholder=""/>
                        </div>
                        <div class="col-sm-3">
                            <input type="number" class="form-control" name="vipMax" value="1" min="1" placeholder=""/>
                        </div>
                    </div>

                    <div class="form-group level hide">
                        <label class="col-sm-3 control-label">等级范围</label>
                        <div class="col-sm-1">
                            <input type="checkbox" name="level" value="1" class="form-control" />
                        </div>
                        <div class="col-sm-3">
                            <input type="number" class="form-control" name="levelMin" value="1" min="1" placeholder=""/>
                        </div>
                        <div class="col-sm-3">
                            <input type="number" class="form-control" name="levelMax" value="1" min="1" placeholder=""/>
                        </div>
                    </div>

                    <div class="form-group userGroup hide">
                        <label class="col-sm-3 control-label">推送分组</label>
                        <div class="col-sm-9">
                            <label class="radio-inline" style="padding-left: 0;">
                                <input type="checkbox" class="checkboxNot" name="userGroup[]" checked value="0">不限定
                            </label>
                            <?php foreach ($userGroup as $k=>$v) { ?>
                                <label class="radio-inline" style="padding-left: 0;">
                                    <input type="checkbox" class="checkboxInput" name="userGroup[]" value="<?php echo $v['id'];?>"><?php echo $v['name'];?>
                                </label>
                            <?php }?>

                        </div>
                    </div>

                    <div class="form-group uiddiv">
                        <label class="col-sm-3 control-label">UID列表:</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="5" placeholder="UID(一行一个UID)" name="uidlist"></textarea>
                        </div>
                    </div>
                    <div id="langDivExchang" >
                        <?php foreach ($langList as $k=>$v) { ?>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><?php echo $v;?></label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control <?php echo $k.'_title';?>"  value="" name="title[<?php echo $k;?>]"/>
                                    <textarea  rows="7" cols="50" class="form-control <?php echo $k.'_content';?>"  name="content[<?php echo $k;?>]"></textarea>
                                </div>
                            </div>
                        <?php }?>
                    </div>
                    <div class="form-group uiddiv">
                        <label class="col-sm-3 control-label">备注:</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="5" placeholder="备注" name="remark"></textarea>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>


<div class="modal fade" id="actionShow" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">推送信息</h4>
            </div>
            <form class="form-horizontal" role="form" method="post" action="#" data-callBack="">
                <div class="modal-body">
                    <div id="langDivShow" >
                        <?php foreach ($langList as $k=>$v) { ?>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><?php echo $v;?></label>
                                <div class="col-sm-9">
                                    <textarea  rows="5" cols="50" class="form-control <?php echo $k.'_data';?>" readonly></textarea>
                                </div>
                            </div>
                        <?php }?>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    laydate.render({
        elem: '#test-limit2'
        ,min: 0
        ,max: 999
    });
    //限定可选时间
    laydate.render({
        elem: '#test-limit3'
        ,type: 'time'
        // ,min: '09:30:00'
        // ,max: '17:30:00'
        ,btns: ['clear', 'confirm']
    });
    laydate.render({
        elem: '#test-limit4'
        ,min: 0
        ,max: 999
    });
    //限定可选时间
    laydate.render({
        elem: '#test-limit5'
        ,type: 'time'
        // ,min: '09:30:00'
        // ,max: '17:30:00'
        ,btns: ['clear', 'confirm']
    });
    laydate.render({
        elem: '#exchangeDay'
        ,min: 0
        ,max: 999
    });
    //限定可选时间
    laydate.render({
        elem: '#exchangeTime'
        ,type: 'time'
        // ,min: '09:30:00'
        // ,max: '17:30:00'
        ,btns: ['clear', 'confirm']
    });
    var idData = JSON.parse('<?php echo json_encode($props); ?>');
    $('.addParent').on("click",function(){
        var str = '<div class="col-sm-12" style="margin-top: 1rem;padding-left:0"><div class="col-sm-5"><select class="form-control typeControl" name="props[id][]">';
        for(var x in idData) {
            str += '<option value="'+x+'">'+idData[x]['msg']+'</option>';
        }
        str +='</select></div><div class="col-sm-5"><input type="number" class="form-control" placeholder="道具数量" name="props[num][]" min="1" value="1"></div><div class="col-sm-1"><button type="button" class="btn btn-danger deleteParent" >删除</button></div></div>';
        $(this).parent().before(str);
    });
    $('.addOrDelControl').on("click",'.deleteParent',function(){
        $(this).parent().parent().remove();
    })
</script>

<script type="text/javascript">
    $("input[name='usertype']").click(function(){
        var usertype = $(this).val(),
            langType = $(".langtype");
        if( usertype == 1 ){//按全服
            $(".uiddiv").addClass('hide');
            $(".devicetype").removeClass('hide');
            $(".accounttype").removeClass('hide');
            $(".alertmsg").removeClass('hide');
            $(".vip").removeClass('hide');
            $(".level").removeClass('hide');
            $(".userGroup").removeClass('hide');
            langType.addClass('hide');
        }else{//按uid
            $(".uiddiv").removeClass('hide');
            $(".devicetype").addClass('hide');
            $(".accounttype").addClass('hide');
            $(".alertmsg").addClass('hide');
            langType.addClass('hide');
            $(".vip").addClass('hide');
            $(".level").addClass('hide');
            $(".userGroup").addClass('hide');
        }
    });
    $(document).ready(function() {
        $("#pickdate").dateDropper({
            animate: true,
            format: 'Y-m-d',
            maxYear: '2025',
            minYear: '2019',
            lang:'zh'
        });
    });

    function message(returnData, $from) {
        if(returnData.state!= 'success'){
            alert(returnData.message);
        }
    }

    function selectChange() {
        var type = $("#select").val();
        if(type != 2){
            $('#intervalTime').hide();
        }
        if(type == 0){
            $('#divTime').hide();
        }else{
            $('#divTime').show();
            if(type == 2){
                $('#intervalTime').show();
            }
        }
    }
    function selectChange2() {
        var type = $("#select2").val();
        if(type != 2){
            $('#intervalTime2').hide();
        }
        if(type == 0){
            $('#divTime2').hide();
        }else{
            $('#divTime2').show();
            if(type == 2){
                $('#intervalTime2').show();
            }
        }
    }

    function deleteTask(id) {
        if(confirm('确定要删除吗')==true){
            $.post('/push/delete',{
                id:id
            },function (data) {
                window.location.reload()
            });
        }
    }

    //添加更新内容
    $('#langContentPri').change(function () {
        var langContent, contentMatch;
        langContent = $('#langContentPri').val();

        //英文更新
        contentMatch = langContent.match(/<en-US>([\s\S]*?)<\/en-US>/);
        showContent(contentMatch, $('#langDiv .en_title'), $('#langDiv  .en_content'));

        //德語更新
        contentMatch = langContent.match(/<de-DE>([\s\S]*?)<\/de-DE>/);
        showContent(contentMatch, $('#langDiv .de_title'), $('#langDiv  .de_content'));

        //西班牙更新
        contentMatch = langContent.match(/<es-ES>([\s\S]*?)<\/es-ES>/);
        showContent(contentMatch, $('#langDiv .es_title'), $('#langDiv  .es_content'));

        //法語更新
        contentMatch = langContent.match(/<fr-FR>([\s\S]*?)<\/fr-FR>/);
        showContent(contentMatch, $('#langDiv .fr_title'), $('#langDiv  .fr_content'));

        //法語更新
        contentMatch = langContent.match(/<pt-PT>([\s\S]*?)<\/pt-PT>/);
        showContent(contentMatch, $('#langDiv .pt_title'), $('#langDiv  .pt_content'));

        //泰文更新
        contentMatch = langContent.match(/<th>([\s\S]*?)<\/th>/);
        showContent(contentMatch, $('#langDiv .th_title'), $('#langDiv  .th_content'));

        //中文更新
        contentMatch = langContent.match(/<zh-CN>([\s\S]*?)<\/zh-CN>/);
        showContent(contentMatch, $('#langDiv .zh_title'), $('#langDiv  .zh_content'));

        //台湾更新
        contentMatch = langContent.match(/<zh-TW>([\s\S]*?)<\/zh-TW>/);
        showContent(contentMatch, $('#langDiv .tw_title'), $('#langDiv  .tw_content'));

        //印地语更新
        contentMatch = langContent.match(/<hi>([\s\S]*?)<\/hi>/);
        showContent(contentMatch, $('#langDiv .hi_title'), $('#langDiv  .hi_content'));

        //俄语更新
        contentMatch = langContent.match(/<ru>([\s\S]*?)<\/ru>/);
        showContent(contentMatch, $('#langDiv .ru_title'), $('#langDiv  .ru_content'));

    });


    //添加更新内容
    $('#langContentPriExchange').change(function () {
        var langContent, contentMatch;
        langContent = $('#langContentPriExchange').val();

        //英文更新
        contentMatch = langContent.match(/<en-US>([\s\S]*?)<\/en-US>/);
        showContent(contentMatch, $('#langDivExchang .en_title'), $('#langDivExchang  .en_content'));

        //德語更新
        contentMatch = langContent.match(/<de-DE>([\s\S]*?)<\/de-DE>/);
        showContent(contentMatch, $('#langDivExchang .de_title'), $('#langDivExchang  .de_content'));

        //西班牙更新
        contentMatch = langContent.match(/<es-ES>([\s\S]*?)<\/es-ES>/);
        showContent(contentMatch, $('#langDivExchang .es_title'), $('#langDivExchang  .es_content'));

        //法語更新
        contentMatch = langContent.match(/<fr-FR>([\s\S]*?)<\/fr-FR>/);
        showContent(contentMatch, $('#langDivExchang .fr_title'), $('#langDivExchang  .fr_content'));

        //法語更新
        contentMatch = langContent.match(/<pt-PT>([\s\S]*?)<\/pt-PT>/);
        showContent(contentMatch, $('#langDivExchang .pt_title'), $('#langDivExchang  .pt_content'));

        //泰文更新
        contentMatch = langContent.match(/<th>([\s\S]*?)<\/th>/);
        showContent(contentMatch, $('#langDivExchang .th_title'), $('#langDivExchang  .th_content'));

        //中文更新
        contentMatch = langContent.match(/<zh-CN>([\s\S]*?)<\/zh-CN>/);
        showContent(contentMatch, $('#langDivExchang .zh_title'), $('#langDivExchang  .zh_content'));

        //台湾更新
        contentMatch = langContent.match(/<zh-TW>([\s\S]*?)<\/zh-TW>/);
        showContent(contentMatch, $('#langDivExchang .tw_title'), $('#langDivExchang  .tw_content'));

        //印地语更新
        contentMatch = langContent.match(/<hi>([\s\S]*?)<\/hi>/);
        showContent(contentMatch, $('#langDivExchang .hi_title'), $('#langDivExchang  .hi_content'));

        //俄语更新
        contentMatch = langContent.match(/<ru>([\s\S]*?)<\/ru>/);
        showContent(contentMatch, $('#langDivExchang .ru_title'), $('#langDivExchang  .ru_content'));

    });

    //是否为空
    function isEmpty(param) {
        if(param == '' || param == 0 || param == undefined) {
            return true;
        }else {
            return false;
        }
    }

    /**
     * 更加输入内容截取显示标题和内容
     * @param contentMatch
     * @param titleElement
     * @param contentElement
     */
    function showContent(contentMatch, titleElement, contentElement) {
        var head = '', content = '', contentArr = [];
        if(!isEmpty(contentMatch)) {
            content = contentMatch[1];
            contentArr = content.trim().split(/[\n]/);
            if(contentArr.length > 0) {//如果截取的数组不为空，则取第一个为标题，其他的为内容
                head = contentArr[0];
                contentArr.splice(0, 1);
                content = contentArr.join('\n');
            }
        }
        console.log(head);
        titleElement.val(head);
        contentElement.val(content);
    }

    $('.show').click(function () {
        var data = $(this).val();
        data = JSON.parse(data);
        for (key in data){
            $("#langDivShow ."+key+"_data").val(data[key]);
        }
        $('#actionShow').modal('show')
    })

    $(".checkboxNot").change(function() {
        console.log("checkboxNot");
        $('.checkboxInput').prop('checked', false);
    });
    $(".checkboxInput").change(function() {
        console.log("checkboxInput");
        $('.checkboxNot').prop('checked', false);
    });
</script>
