admin.html 6.2 KB
Newer Older
H
hjdhnx 已提交
1 2 3
<!DOCTYPE html>
<html lang="en">
<head>
H
hjdhnx 已提交
4
    <meta charset="utf-8">
H
hjdhnx 已提交
5
  <title>管理员操作中心-{{rules.count}}条规则</title>
H
hjdhnx 已提交
6 7 8
  <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
  <meta name="author" content="道长"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
H
hjdhnx 已提交
9
    <link rel="stylesheet" media="screen" href="/static/css/admin.css">
H
hjdhnx 已提交
10
  <link rel="icon" href="/static/img/logo.png" type="image/x-icon">
H
hjdhnx 已提交
11
    <script src="/static/js/jquery.min.js"></script>
H
hjdhnx 已提交
12
</head>
H
hjdhnx 已提交
13 14 15 16 17 18 19
<style>
    .red {
        color:red;
        font-weight: bold;
        padding-left:10px;
        /*padding-top:10px;*/
        margin-left:10px;
H
hjdhnx 已提交
20
        width: 360px;
H
hjdhnx 已提交
21 22 23 24 25 26 27 28
        height: 30px;
    }
    .green {
        color:forestgreen;
        font-weight: bold;
        padding-left:10px;
        /*padding-top:10px;*/
        margin-left:10px;
H
hjdhnx 已提交
29
        width: 360px;
H
hjdhnx 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
        height: 30px;
    }
    .btn{
        color:#FFFFFF;
        background-color: #1379cb;
    }
    .clear{
        /*word-spacing:2px;*/
        letter-spacing:5px;
        margin-left:20px;
        width: 120px;
        height: 30px;
        text-align: center;
        border-style: solid;
        /*border-color: #8CD4F5;*/
        border-color: #1379cb;
        text-decoration:none;
        color:#FFFFFF;
        background-color: #1379cb;
    }
H
hjdhnx 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62
    .view_home{
        letter-spacing:5px;
        margin-left:20px;
        width: 150px;
        height: 30px;
        text-align: center;
        border-style: solid;
        /*border-color: #8CD4F5;*/
        border-color: #17af30;
        text-decoration:none;
        color:#FFFFFF;
        background-color: #17af30;
    }
H
hjdhnx 已提交
63 64 65 66
    /*li a {*/
    /*    display: block !important;*/
    /*}*/
</style>
H
hjdhnx 已提交
67
<body>
H
hjdhnx 已提交
68 69 70 71 72 73 74 75
<script>
    $(document).ready(function(){
        $(".view").click(function(){
            // location.reload();
            let rule = this.innerText.trim();
            location.href = '/admin/view/'+rule+'.js';
        });

H
hjdhnx 已提交
76 77 78 79 80 81
        $(".view_home").click(function(){
            // location.reload();
            let rule = this.getAttribute('value').trim();
            location.href = '/vod?rule='+rule;
        });

H
hjdhnx 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
        $(".clear").click(function(){
            // location.reload();
            // let rule = this.innerText.trim();
            let rule = this.getAttribute('value').trim();
            if(confirm('确认删除内置规则:'+rule+'?')){
            let code = $.ajax({url:'/admin/clear/'+rule+'.js',async:false}).responseText;
            code = typeof(code) === "object"?code:JSON.parse(code);
            if(code.code === 200){
                alert('操作成功!\n'+code.msg);
                location.reload()
            }else{
                alert('操作失败!\n'+code.msg);
            }
            }
            // location.href = '/admin/clear/'+rule;
        });

        $('#upload').click(function(){
            var file_data = $("input[name='file']").prop("files")[0];
            console.log(file_data);
            if(!file_data){
                alert('文件必选');
104 105 106 107 108 109
                return false
            }
            var name = file_data.name;
            if(!name.endsWith('.js')){
                alert('仅支持上传js文件');
                return false
H
hjdhnx 已提交
110 111 112 113
            }
            var form_data = new FormData();
            // 把所有表单信息
            form_data.append("id", "001");
114
            form_data.append("name", name);
H
hjdhnx 已提交
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
            form_data.append("file", file_data);
            $.ajax({
                type: "POST",
                url: "/upload",
                dataType : "json",
                processData: false,  // 注意:让jQuery不要处理数据
                contentType: false,  // 注意:让jQuery不要设置contentType
                data: form_data
            }).success(function(ret) {
                console.log(ret);
                alert(ret.msg);
                location.reload();
            }).fail(function(ret) {
                console.log(ret);
                alert(ret.msg);
            });

        });

});
 function getFileSize(fileObj)
       {
           $('#file_size').text('文件大小为:'+fileObj.files[0].size/1024+'kb');
       }
</script>

<h2 class="title">欢迎使用py_dr管理员界面</h2><h4><a href="/index">返回首页</a></h4>
H
hjdhnx 已提交
142
<p>你可以在此页面在线上传规则文件到js目录或者删除js目录的文件</p>
H
hjdhnx 已提交
143
 <form action = "/upload" method = "POST" enctype = "multipart/form-data">
144 145
<!--     <input type = "file" name = "file" class="btn" accept=".js"  onchange="getFileSize(this)"/>-->
     <input type = "file" name = "file" class="btn" onchange="getFileSize(this)"/>
H
hjdhnx 已提交
146 147
<!--     <input type = "submit" value="上传" class="btn"/>-->
     <input type="button" id="upload" value="上传" class="btn"/>
H
hjdhnx 已提交
148
</form>
H
hjdhnx 已提交
149 150
<p id="file_size"></p>

H
hjdhnx 已提交
151
<h1>内置规则列表-共{{rules.count}}条</h1>
H
hjdhnx 已提交
152 153 154 155 156 157 158
{% if rules.count < 1 %}
<h3>暂无内置的规则</h3>
{% endif %}
{% for rule in rules.list %}
    	{% if rule.name|length > 2 %}
        	<li class="red">
                <a class="view" href="javascript:void(0);">{{ rule.name }}</a>
H
hjdhnx 已提交
159
                <a class="view_home" href="javascript:void(0);" value="{{ rule.name }}">主页数据预览</a>
H
hjdhnx 已提交
160 161 162 163 164
                <a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a>
            </li>
        {% else %}
            <li class="green">
                <a class="view" href="javascript:void(0);">{{ rule.name }}</a>
H
hjdhnx 已提交
165
                <a class="view_home" href="javascript:void(0);" value="{{ rule.name }}">主页数据预览</a>
H
hjdhnx 已提交
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
                <a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a>
            </li>
        {% endif %}
 {% endfor %}
<!--{% if rules.count > 0 %}-->
<!--<h1>删除内置规则</h1>-->
<!--{% for rule in rules.list %}-->
<!--{% if rule|length > 2 %}-->
<!--    <li class="red">-->
<!--        <a class="clear" href="javascript:void(0);">{{ rule.name }}</a>-->
<!--    </li>-->
<!--{% else %}-->
<!--    <li class="yellow">-->
<!--        <a class="clear" href="javascript:void(0);">{{ rule.name }}</a>-->
<!--    </li>-->
<!--{% endif %}-->
<!-- {% endfor %}-->
<!--{% endif %}-->
H
hjdhnx 已提交
184 185
</body>
</html>