<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="referer" content="never" />
  <meta name="renderer" content="webkit">
  <title>{{g.title}}</title>
  <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
  <link href="{{g.cdn_url}}/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
  <link href="{{g.cdn_url}}/codemirror/lib/codemirror.css" rel="stylesheet" />
  <link href="{{g.cdn_url}}/css/site.css?version={{g['version']}}&repair={{data['js_random']}}" rel="stylesheet" />
  {% for css_f in g['other_css'] %}
  <link href="{{css_f}}" rel="stylesheet" />
  {% endfor %}
  <style>
    .contextmenu {
      position: absolute;
      width: 120px;
      background: #FFFFFF;
      border-radius: 5px;
      overflow: hidden;
      z-index: 99999999;
    }

    .contextmenu li {
      border-left: 3px solid transparent;
      transition: ease 0.3s;
    }

    .contextmenu li:hover {
      background: #707070;
      border-left: 3px solid #333;
    }

    .contextmenu li a {
      display: block;
      padding: 5px 10px;
      color: #000000;
      text-decoration: none;
      transition: ease 0.3s;
      cursor: default;
    }

    .contextmenu li:hover a {
      color: #fff;
    }
  </style>
  <script type="text/javascript">
    var ie_version = (function () {
      var userAgent = navigator.userAgent,
        isLessIE11 = userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1,
        isEdge = userAgent.indexOf('Edge') > -1 && !isLessIE11,
        isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf('rv:11.0') > -1;
      if (isLessIE11) {
        var IEReg = new RegExp('MSIE (\\d+\\.\\d+);');
        IEReg.test(userAgent);
        var IEVersionNum = parseFloat(RegExp['$1']);
        if (IEVersionNum === 7) { // IE7
          return 7
        } else if (IEVersionNum === 8) { // IE8
          return 8
        } else if (IEVersionNum === 9) { // IE9
          return 9
        } else if (IEVersionNum === 10) { // IE10
          return 10
        } else {
          return 6
        }
      } else if (isEdge) { // edge
        return 'edge'
      } else if (isIE11) { // IE11
        return 11
      } else { // 不是ie浏览器
        return -1
      }
    }());
    if (ie_version != -1 && ie_version < 10 && ie_version != 'edge') {
      window.location.href = '/tips';
    }
    if(ie_version != -1 && ( ie_version >= 10 || ie_version === 'edge')){
      var title = document.createElement('div');
      title.setAttribute('class', 'content')
      title.setAttribute('style','height: 50px;position: absolute;top: 0;left: 0;right: 0;line-height: 50px;z-index: 9999999;background: rgba(0,0,0,.5);text-align: center;color: #ff922e;font-size: 19px;font-weight: 600;')
      title.innerHTML = '<span>当前浏览器可能存在视图不兼容的情况，推荐使用Chrome/FireFox/国产浏览器急速模式访问</span><span class="compatibility_tips" style="position: absolute;right: 15px;top: 10px;font-size: 14px;display: inline-block; height: 30px;line-height: 28px;padding: 0 12px;font-weight: 500;color: #ffffff; border-radius: 4px;cursor: pointer;border: 2px solid #ffffff;font-weight: 500;">关闭提示</span>'
      title.querySelector('.compatibility_tips').addEventListener('click',function(res){
          var parentNode = this.parentElement;
          parentNode.parentElement.removeChild(parentNode)
      })
      document.querySelector('html').appendChild(title)
    }
    if (!window.location.origin) {
      window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
    }
  </script>
</head>

<body>
  <div class="bt-warp bge6">
    <a style="display:none;" id="panel_debug" data="{{g['debug']}}" data-pyversion="{{g['pyversion']}}"></a>
    <a style="display:none;" id="request_token_head" token="{{session['request_token_head']}}"></a>
    <div id="container" class="container-fluid">
      <div class="sidebar-scroll">
        <div class="sidebar-auto">
          <div id="task" class="task cw" onclick="messagebox()">0</div>
          <h3 class="mypcip"><span class="f14 cw">{{session['address']}}</span></h3>
          <ul class="menu">
            {% for menu in g['menus'] %}
            {% if menu['href'] == g.uri %}
            <li id="{{menu['id']}}" class="current"> <a class="{{menu['class']}}"
                href="{{menu['href']}}">{{menu['title']}}</a></li>
            {% else %}
            <li id="{{menu['id']}}"> <a class="{{menu['class']}}" href="{{menu['href']}}">{{menu['title']}}</a></li>
            {% endif %}
            {% endfor %}
          </ul>
        </div>
      </div>
      <button style="display: none;" id="bt_copys" class="bt_copy" data-clipboard-text=""></button>
      <a style="display: none;" id="defaultPath">{{session['config']['sites_path']}}</a>
      {% block content %}{% endblock %}
      <div class="footer bgw">
        <span style="margin-right: 8px;">{{session['brand']}}{{session['product']}} &copy;2014-{{g['yaer']}} 广东堡塔安全技术有限公司 (bt.cn)</span>
        <a style="margin-right: 8px;color:#20a53a;" href="http://www.bt.cn/bbs" target="_blank">论坛求助</a>|
        <a class="btlink" style="margin: 0 8px;" href="https://www.kancloud.cn/chudong/bt2017/424204" target="_blank">使用手册</a>|
        <a class="btlink bt_wx_qrcode" style="margin: 0 8px;" href="javascript:;">微信公众号<div class="bt_wx_img"></div></a>|
        <a class="btlink" style="margin: 0 8px;" href="https://www.bt.cn/auth" target="_blank">正版查询</a>
        <span class="bt_qq_qun">|<a class="btlink" style="margin: 0 8px;" href="https://jq.qq.com/?_wv=1027&k=12Y6BkLq" target="_blank">售后QQ群：907340327</a></span>
      </div>
    </div>
    {% if g.cdn_url != '/static' %}
    <script type="text/javascript">
      function static_cdn_check(msg, url, line, col, error) {
        if (msg.indexOf('$ is not defined') != -1) {
          var s_url = '/static_cdn/set_state.json';
          http_request = new XMLHttpRequest();
          http_request.open('GET', s_url, true);
          http_request.setRequestHeader("Content-type", "application/json");
          http_request.send();
          http_request.onreadystatechange = function (e) {
            if (e.srcElement.readyState == 4 && e.srcElement.status == 200) {
              if (e.srcElement.responseText.indexOf('true') != -1) {
                alert("检测到【面板静态加速】节点故障，已自动关闭加速功能\n若需要继续使用【面板静态加速】功能，请在软件商店尝试手动重新开启\n\n点击确定刷新页面!")
                window.location.reload();
              }
            }
          }
        }
      }
      window.onerror = static_cdn_check;
    </script>
    {% endif %}
    <script type="text/javascript">
      var recycle_bin_db_open = "{{g['recycle_bin_db_open']}}" === "1",
        recycle_bin_open = "{{g['recycle_bin_open']}}" === "1",
        update_code = "{{data['js_random']}}",
        panel_version = "{{g['version']}}",
        cdn_url = "{{g.cdn_url}}";
    </script>
    {% if request.path == '/btwaf/index' %}
	  <script type="text/javascript" src="{{g.cdn_url}}/js/jquery-2.2.4.min.js"></script>
	  <script type="text/javascript" src="{{g.cdn_url}}/layer/layer.js?version={{g['version']}}"></script>
	  <script type="text/javascript" src="{{g.cdn_url}}/language/{{session['lan']}}/lan.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
	  <script type="text/javascript" src="{{g.cdn_url}}/js/clipboard.min.js" defer></script>
	  <script type="text/javascript" src="{{g.cdn_url}}/laydate/laydate.js" defer></script>
	  <script type="text/javascript" src="{{g.cdn_url}}/js/jquery.qrcode.min.js" defer></script>
	  <script type="text/javascript" src="{{g.cdn_url}}/js/public.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
	  <script type="text/javascript" src="{{g.cdn_url}}/js/public_backup.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
    <script type="text/javascript" src="{{g.cdn_url}}/js/statistics.min.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
    <script type="text/javascript" src="{{g.cdn_url}}/js/tools.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
    {% endif %}

    {% block scripts %}
    <script src="{{g.cdn_url}}/js/jquery-2.2.4.min.js"></script>
    <script src="{{g.cdn_url}}/layer/layer.js?version={{g['version']}}"></script>
      <script src="{{g.cdn_url}}/language/{{session['lan']}}/lan.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
    <script src="{{g.cdn_url}}/js/clipboard.min.js" defer></script>
    <script src="{{g.cdn_url}}/laydate/laydate.js" defer></script>
    <script src="{{g.cdn_url}}/js/jquery.qrcode.min.js" defer></script>

    <!-- 以下文件未来将被剔除 -->
    <script src="{{g.cdn_url}}/js/bootstrap.min.js"></script>
    <script src="{{g.cdn_url}}/js/public.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
    <script src="{{g.cdn_url}}/js/public_backup.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
    <script src="{{g.cdn_url}}/js/statistics.min.js?version={{g['version']}}&repair={{data['js_random']}}"></script>

    <script src="{{g.cdn_url}}/codemirror/lib/codemirror.js" defer></script>
    <!-- End -->
    <script type="text/javascript" src="{{g.cdn_url}}/js/tools.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
    <script type="text/javascript">
      bt.set_cookie('order', 'id desc');
      bt.set_cookie('serverType', "{{session['webserver']}}");
      if (bt.get_cookie('pro_end') >= 0 || bt.get_cookie('ltd_end') > 0) $(".bt_qq_qun").show()
      $("#setBox").click(function () {
        if ($(this).prop("checked")) {
          $("input[name=id]").prop("checked", true);
        } else {
          $("input[name=id]").prop("checked", false);
        }
      });
      var is_files_html = false;
      var task_open = 0;
      var task_close = false;
      if ($(".current").attr("id") == 'memuAfiles') {
        is_files_html = true;
      }

      function task_stat(my_init) {
        if (!my_init) {
          my_init = 0;
          if (task_open) return;
        }
        if (task_close) return;
        $.post('/task?action=get_task_lists', {
          status: -3
        }, function (task_list) {
          if (task_list.length == 0) {
            if (my_init && is_files_html) GetFiles(getCookie('Path'));
            if (task_open) {
              layer.close(task_open);
              task_open = false;
            }
            return;
          }
          var msg_body = '';
          var is_add = false;
          for (var i = 0; i < task_list.length; i++) {
            if (task_list[i]['status'] == -1) {
              if (!task_open || !$(".message-list").attr("class")) {
                show_task();
              }

              if (task_list[i]['type'] == '1') {
                msg_body +=
                  '<div class="mw-con">\
		                                <ul class="waiting-down-list">\
			                                <li>\
				                                <div class="down-filse-name"><span class="fname" style="width:80%;" title="正在下载: ' +
                  task_list[i].shell + '">正在下载: ' + task_list[i].shell +
                  '</span><span style="position: absolute;left: 84%;top: 25px;color: #999;">' + task_list[i].log
                  .pre + '%</span><span class="btlink" onclick="remove_task(' + task_list[i].id + ')" style="position: absolute;top: 25px;right: 20px;">取消</span></div>\
				                                <div class="down-progress"><div class="done-progress" style="width:' + task_list[i]
                  .log.pre + '%"></div></div>\
				                                <div class="down-info"><span class="total-size"> ' + task_list[i].log.used + '/' +
                  ToSize(task_list[i].log.total) + '</span><span class="speed-size">' + (task_list[i].log.speed ==
                    0 ? '正在连接..' : task_list[i].log.speed) + '/s</span><span style="margin-left: 20px;">预计还要: ' +
                  task_list[i].log.time + '</span></div>\
			                                </li>\
	                                        </ul>\
	                                    </div>'
              } else {
                msg_body +=
                  '<div class="mw-title"><span style="max-width: 88%;display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">' +
                  task_list[i].name + ': ' + task_list[i].shell +
                  '</span><span class="btlink" onclick="remove_task(' + task_list[i].id + ')"  style="position: absolute;top: 10px;right: 15px;">取消</span></div>\
	                                    <div class="mw-con codebg">\
		                                    <code>' + task_list[i].log + '</code>\
	                                    </div>'

              }

            } else {
              if (!is_add) {
                msg_body += '<div class="mw-title">等待执行任务</div><div class="mw-con"><ul class="waiting-list">';
                is_add = true;
              }
              msg_body += '<li><span class="wt-list-name" style="width: 90%;">' + task_list[i].name + ': ' +
                task_list[i].shell + '</span><span class="mw-cancel" onclick="remove_task(' + task_list[i].id +
                ')">X</span></li>';
            }
          }
          if (task_open) {
            if (is_add) {
              msg_body += '</ul></div>';
            }
            $(".message-list").html(msg_body);
          }


          if (my_init > 3) {
            if (is_files_html) GetFiles(getCookie('Path'));
            my_init = 1;
          }
          my_init += 1
          setTimeout(function () {
            task_stat(my_init);
          }, 1000);
        });
      }

      function show_task() {
        task_open = layer.open({
          type: 1,
          title: "实时任务队列",
          area: '500px',
          closeBtn: 2,
          shadeClose: false,
          shade: false,
          offset: 'auto',
          content: '<div style="margin: 10px;" class="message-list"></div>',
          cancel: function () {
            task_close = true;
          }
        });
      }

      function remove_task(id) {
				layer.confirm('是否取消当前执行的任务队列？', { title: '取消任务队列', icon: 0 }, function(indexs) {
					layer.close(indexs);
					var loadT = bt.load('正在取消任务...');
					$.post('/task?action=remove_task', {
						id: id
					}, function (rdata) {
						loadT.close();
						layer.msg(rdata.msg);
					});
				});
      }
      task_stat(); 
      {% if data['show_workorder'] %}
        var box = new MessageBox(); 
      {%endif %}
    </script>
    {% endblock %}
    {% for js_f in g['other_js'] %}
    <script type="text/javascript" src="{{js_f}}"></script>
    {% endfor %}
  </div>
</body>

</html>