-
Notifications
You must be signed in to change notification settings - Fork 2
/
bbs.js
111 lines (102 loc) · 2.19 KB
/
bbs.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
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
/*
** @author [email protected]
*/
/*
** getCookie(name)
*/
var wwwparams = 'WWWPARAMS';
var defaultStyleFile = 'default.css';
var midStyleFile = 'default-mf.css';
var bigStyleFile = 'default-bf.css';
var smlStyleFile = 'default-sf.css';
var bbsStyle;
function getCookie(name)
{
var cookieFound = false;
var start = 0;
var end = 0;
var cookieString = document.cookie;
var i = 0;
while(i <= cookieString.length){
start = i;
end = start + name.length;
if(cookieString.substring(start,end)==name){
cookieFound = true;
break;
}
i++;
}
if(cookieFound){
start = end + 1;
end = cookieString.indexOf(";",start);
if(end < start)
end = cookieString.length;
return unescape(cookieString.substring(start,end));
}
return false;
}
/*
** getBbsStyle()
*/
function getBbsStyleFile()
{
var bbsStyle = getCookie(wwwparams);
if(!bbsStyle)
return defaultStyleFile;
var styleString = new String(bbsStyle);
switch(styleString.substring(0,1))
{
case "1":
return smlStyleFile;
break;
case "2":
return midStyleFile;
break;
case "3":
return bigStyleFile;
break;
default:
}
return defaultStyleFile;
}
function prints(s) {
document.write(s);
}
var bbsconImg = new Array();
function resizeImg(obj) {
bbsconImg[bbsconImg.length] = obj;
obj.o_width = obj.width;
maxWidth = document.body.clientWidth - 40;
if (obj.width > maxWidth) obj.width = maxWidth;
}
function adjustImg() {
var maxWidth = document.body.clientWidth - 40;
for (var i in bbsconImg) {
obj = bbsconImg[i];
o_width = obj.o_width;
obj.width = (o_width > maxWidth) ? maxWidth : o_width
}
}
window.onresize = adjustImg;
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
function cancelEvent(ev) {
if (is_ie) {
ev.cancelBubble = true;
ev.returnValue = false;
} else {
ev.preventDefault();
ev.stopPropagation();
}
}
function textarea_okd(func, evt) {
evt = (evt) ? evt : ((window.event) ? event : null);
if (evt == null) return;
key = evt.keyCode ? evt.keyCode : evt.charCode;
if ((key == 87 && evt.ctrlKey) || (key == 13 && evt.ctrlKey)) {
cancelEvent(evt);
func();
return false;
}
return true;
}