forked from andaok/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
168 lines (140 loc) · 5.38 KB
/
test.html
File metadata and controls
168 lines (140 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script>
//生成随机数
var randomnum = getRandom(999);
$(document).ready(function(){
// 点击刷新CDN按钮动作
$("#FlushCDN").click(function(){
$("#ShowCDN").slideDown("slow");
$("#ShowSquid").slideUp("slow");
var textarea_array = ($("#urls").val()).split("\n");
var urlstype = $('input[name="urlstype"]').filter(":checked").val();
$.getJSON("http://192.168.0.111:8087/flushcdn?format=json&jsoncallback=?","urls="+textarea_array+"&urlstype="+urlstype,function(data,status){
if (data.head == "fail")
{
alert(data.body);
}
else
{
Flushing();
}
});
});
//点击刷新squid按钮动作
$("#FlushSquid").click(function(){
$("#ShowSquid").slideDown("slow");
$("#ShowCDN").slideUp("slow");
//传递url给后端shell脚本执行刷新squid
var textarea_array = ($("#urls").val()).split("\n");
var urlstype = $('input[name="urlstype"]').filter(":checked").val();
$.getJSON("http://127.0.0.1:8080/flushsquid?format=json&jsoncallback=?","urls="+textarea_array+"&urlstype="+urlstype+"&key="+randomnum,function(data,status){
if (data.success == "1")
{
//脚本已开始执行,调用函数写终端输出到前端页面
WriteStdoutToFront();
}
else
{
//脚本执行错误,弹出错误信息.
alert(data.text);
}
});
});
});
//---------------
function Flushing(){
$("#FlushingDiv table tbody").html(function(i,origHtml){
return "<tr><td>1</td><td>2</td><td>3</td></tr>" + origHtml;
});
}
//写终端输出到前端页面
function WriteStdoutToFront(){
$.ajax({
type:"GET",
dataType:"jsonp",
url:"http://127.0.0.1:8080/getstdout?jsoncallback=?",
timeout:80000, //ajax请求超时80秒
//data:{time:"80"}, //40秒后无论结果服务器都返回数据
data:{key:randomnum},
success:function(data,textStatus) {
//从服务器得到数据,显示数据并继续查询.
if (data.success == '1'){
$("#ShowSquid pre").append("<br>"+data.text);
WriteStdoutToFront();
}
//未从服务器得到数据,继续查询.
if (data.success == "0") {
$("#ShowSquid pre").append("<br>[NO DATA]");
//WriteStdoutToFront();
}
},
//Ajax请求超时,继续查询.
error:function(XMLHttpRequest,textStatus,errorThrown) {
if (textStatus == "timeout") {
$("#ShowSquid pre").append("<br>[TIMEOUT]");
//WriteStdoutToFront();
}
},
});
}
//随机数函数
function getRandom(n){return Math.floor(Math.random()*n+1)}
</script>
<style type="text/css">
p.title
{
font-size:90%;
}
div.panel
{
margin:0px;
padding:5px;
text-align:left;
background:#e5eecc;
border:solid 1px #c3c3c3;
height:auto;
width:auto;
display:none;
}
div.panel textarea
{
background:#e5eecc;
border:solid 0px #c3c3c3;
}
</style>
</head>
<body>
<input type="radio" name="urlstype" value=0 checked> File
<input type="radio" name="urlstype" value=1> Dir </br>
<textarea id="urls" rows="10" cols="100"></textarea> </br>
<button id="FlushSquid" type="button" data-toggle="modal" data-target="#myModal">FlushSquid</button>
<button id="FlushCDN" type="button">FlushCDN</button>
<div id="ShowSquid" class="panel" >
<pre></pre>
</div>
<div id="ShowCDN" class="panel">
<p class="title">Flushing</p>
<hr width=150 size=2 align=left noshade>
<div id="FlushingDiv">
<table border="1">
<tbody>
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
</tbody>
</table>
<div>
<p class="title">Wait To Flush</p>
<hr width=150 size=2 align=left noshade>
</div>
</body>
</html>