<!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="/static/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/site.css?f2={{g['version']}}" rel="stylesheet">
    <link href="/static/codemirror/lib/codemirror.css" rel="stylesheet">
    <!--[if lte IE 9]>
    <script src="/static/js/requestAnimationFrame.js"></script>
    <![endif]-->
    <style>
        .top-tips {
            height: 50px;
            width: 100%;
            color: red;
            position: fixed;
            top: 0;
            z-index: 999;
            background-color: white;
            text-align: center;
            line-height: 50px;
            font-size: 20px;
            border-bottom: 1px solid #f0f0f0;
            font-weight: bold;
            display: none;
        }
    </style>
</head>
<body>
    <div class="bt-warp bge6">
        <div class="top-tips">{{session['top_tips']}}</div>
        <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()"></div>
                    <h3 class="mypcip"><span class="f14 cw">{{session['address']}}</span></h3>
                    <ul class="menu">
                        {% for menu in session['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 id="newbtpc"></div>
                    <div class="btpc-plus" onclick="bindBTPanel(0,'b')">+</div>
                </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>
            <script src="/static/js/jquery-1.10.2.min.js"></script>
            <script src="/static/js/bootstrap.min.js"></script>
            <script src="/static/language/{{session['lan']}}/lan.js?date={{g['version']}}"></script>
            <script src="/static/layer/layer.js?date={{g['version']}}"></script>
            <script type="text/javascript" src="/static/laydate/laydate.js?date=20180301"></script>
            <script src="/static/js/jquery.fly.min.js"></script>
            <script src="/static/codemirror/lib/codemirror.js"></script>
            <script src="/static/codemirror/addon/edit/editAll.js"></script>
            <script src="/static/codemirror/mode/modeAll.js"></script>
            <script src="/static/codemirror/addon/dialog/dialog.js"></script>
            <script src="/static/codemirror/addon/search/search.js"></script>
            <script src="/static/codemirror/addon/scroll/annotatescrollbar.js"></script>
            <script src="/static/js/jquery.qrcode.min.js"></script>
            <script src="/static/js/socket.io.min.js"></script>
            <link rel="stylesheet" href="/static/build/xterm.min.css" />
            <link rel="stylesheet" href="/static/build/addons/fullscreen/fullscreen.min.css" />
            <script src="/static/build/xterm.min.js"></script>
            <script src="/static/build/addons/attach/attach.min.js"></script>
            <script src="/static/build/addons/fit/fit.min.js"></script>
            <script src="/static/build/addons/fullscreen/fullscreen.min.js"></script>
            <script src="/static/build/addons/search/search.min.js"></script>
            <script src="/static/build/addons/winptyCompat/winptyCompat.js"></script>
            <script type="text/javascript" src="/static/js/clipboard.min.js"></script>
            <script src="/static/js/public.js?v4={{g['version']}}"></script>
            <script src="/static/js/public_backup.js?version={{g['version']}}"></script>
            <script src="/static/js/bt_upload.js?version={{g['version']}}"></script>
            {% block content %}{% endblock %}
            <div class="footer bgw">{{session['brand']}}{{session['product']}} &copy;2014-{{session['yaer']}} {{session['brand']}} (bt.cn)<a style="margin-left:20px;color:#20a53a;" href="http://forum.aapanel.com" target="_blank">{{session['bt_help']}}</a><a style="margin-left:20px;color:#20a53a;" href="http://docs.bt.cn/424204" target="_blank">{{session['manual']}}</a></div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion.split(";")[1].replace(/[ ]/g, "").replace("MSIE", "")) < 9) {
        $(".main-content").css("margin-top", "50px");
        $('.top-tips').show();
    }

    $("#setBox").click(function () {
        if ($(this).prop("checked")) {
            $("input[name=id]").prop("checked", true);
        } else {
            $("input[name=id]").prop("checked", false);
        }
    });
    setCookie('order', 'id desc');
    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='+lan.layout.download+ task_list[i].other + '">'+lan.layout.download+': ' + task_list[i].other + '</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;">Cancel</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"> '+ ToSize(task_list[i].log.used) + '/' + ToSize(task_list[i].log.total) + '</span><span class="speed-size">' + (task_list[i].log.speed==0? lan.layout.connect:ToSize(task_list[i].log.speed)) +'/s</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;">Cancel</span></div>\
                                    <div class="mw-con codebg">\
	                                    <code>'+ task_list[i].log +'</code>\
                                    </div>'

                    }

                } else {
                    if (!is_add) {
                        msg_body += '<div class="mw-title">'+lan.layout.wait_task+'</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: "Real-time task queue",
            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) {
        loadT = layer.msg(lan.layout.cancel_task, { time: 0, icon: 16, shade: [0.3, '#000'] });
        $.post('/task?action=remove_task', { id: id }, function (rdata) {
            layer.close(loadT)
            layer.msg(rdata.msg);
        });
    }
    task_stat();

</script>
<style type="text/css">
    .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>

{% block scripts %}{% endblock %}