forked from binux/libMA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.html
60 lines (56 loc) · 1.7 KB
/
bot.html
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>MA Bot</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<meta name="description" content="ma bot">
<meta name="author" content="binux">
</head>
<body>
<section id=login>
<form id=login_form onsubmit="return login(this);">
login_id: <input name=id />
password: <input type=password name=pwd />
area_id: <input name=area />
<input id=submit type=submit value=login />
</form>
</section>
<section id=log>
</section>
</body>
<script>
if (window.WebSocket === undefined) {
submit.disabled = true;
login_form.id.disabled = true;
login_form.pwd.disabled = true;
log.innerHTML += "<br />WebSocket not supported. Using Chrome!";
}
function login(form) {
if (window.ws) {
ws.close();
}
var login_id = form.id.value,
password = form.pwd.value,
area = form.area.value;
ws = new WebSocket("ws://"+location.host+"/bot?id="+login_id+"&password="+password+"&area="+area);
ws.onopen = function() {
log.innerHTML += "<br />connected.";
};
ws.onclose = function() {
log.innerHTML += "<br /><span class=error>disconnected.</span>";
setTimeout(function() { login(form); }, 60*1000);
};
ws.onmessage = function(event) {
log.innerHTML += "<br />"+event.data;
};
submit.disabled = true;
login_form.id.disabled = true;
login_form.pwd.disabled = true;
return false;
}
</script>
</html>
<!-- vim: set et sw=2 ts=2 sts=2 ff=unix fenc=utf8: -->