forked from shinovon/mpgram-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatupdate.orig.js
80 lines (80 loc) · 1.64 KB
/
chatupdate.orig.js
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
function rr(){
if(typeof XMLHttpRequest==='undefined'){
XMLHttpRequest=function(){
try{
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
}catch(e){}
try{
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
}catch(e){}
try{
return new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){}
try{
return new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
return null;
};
}
return new XMLHttpRequest();
}
function ee(e){
if(e.message !== undefined && e.message !== null){
alert(e.message);
} else {alert(e);}
}
var r = null;
var o = "0";
function h() {
if(r.readyState == 4){
try{
var e=r.responseText;
if(e!=null&&e.length>1){
var f=e.indexOf("||");
if(f!=-1){
if(longpoll){
o=e.substring(0,f);
}else{
msg=e.substring(0,f);
}
e=e.substring(f+2);
if(e.length>0){
var msgs=document.getElementById("msgs");
var d=document.createElement("div");
d.innerHTML=e;
for(var i=d.childNodes.length-1;i>=0;i--){
if(reverse){
msgs.appendChild(d.childNodes[i]);
}else{
msgs.insertBefore(d.childNodes[i],msgs.firstChild);
}
}
while(msgs.childNodes.length>msglimit){
msgs.removeChild(reverse ? msgs.firstChild : msgs.lastChild);
}
}
}
if(autoscroll && reverse){
setTimeout("autoScroll(false,false)",500);
}
}
}catch(e){ee(e);}
setTimeout("a();",updint);
}
}
var c=0;
function a(){
c++;
if(c>70)return;
try{
r=rr();
if(r==null)return;
r.onreadystatechange=h;
r.open("GET",url+"&m="+msg+"&o="+o);
r.send(null);
}catch(e){ee(e);}
}
try{
setTimeout("a()",updint);
}catch(e){ee(e);
}