Normalize line endings and whitespace
This commit is contained in:
@ -1,248 +1,248 @@
|
||||
/*
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configurable variables. You may need to tweak these to be compatible with
|
||||
* the server-side, but the defaults work in most cases.
|
||||
*/
|
||||
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
||||
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
||||
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
|
||||
|
||||
/*
|
||||
* These are the functions you'll usually want to call
|
||||
* They take string arguments and return either hex or base-64 encoded strings
|
||||
*/
|
||||
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
|
||||
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
|
||||
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length
|
||||
*/
|
||||
function core_md5(x, len)
|
||||
{
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << ((len) % 32);
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
|
||||
var a = 1732584193;
|
||||
var b = -271733879;
|
||||
var c = -1732584194;
|
||||
var d = 271733878;
|
||||
|
||||
for(var i = 0; i < x.length; i += 16)
|
||||
{
|
||||
var olda = a;
|
||||
var oldb = b;
|
||||
var oldc = c;
|
||||
var oldd = d;
|
||||
|
||||
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
|
||||
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
|
||||
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
|
||||
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
|
||||
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
|
||||
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
|
||||
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
|
||||
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
|
||||
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
|
||||
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
|
||||
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
|
||||
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
|
||||
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
|
||||
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
|
||||
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
|
||||
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
|
||||
|
||||
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
|
||||
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
|
||||
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
|
||||
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
|
||||
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
|
||||
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
|
||||
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
|
||||
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
|
||||
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
|
||||
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
|
||||
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
|
||||
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
|
||||
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
|
||||
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
|
||||
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
|
||||
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
|
||||
|
||||
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
|
||||
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
|
||||
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
|
||||
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
|
||||
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
|
||||
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
|
||||
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
|
||||
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
|
||||
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
|
||||
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
|
||||
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
|
||||
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
|
||||
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
|
||||
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
|
||||
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
|
||||
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
|
||||
|
||||
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
|
||||
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
|
||||
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
|
||||
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
|
||||
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
|
||||
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
|
||||
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
|
||||
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
|
||||
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
|
||||
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
|
||||
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
|
||||
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
|
||||
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
|
||||
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
|
||||
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
|
||||
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
|
||||
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
}
|
||||
return Array(a, b, c, d);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions implement the four basic operations the algorithm uses.
|
||||
*/
|
||||
function md5_cmn(q, a, b, x, s, t)
|
||||
{
|
||||
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
|
||||
}
|
||||
function md5_ff(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
|
||||
}
|
||||
function md5_gg(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
|
||||
}
|
||||
function md5_hh(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
function md5_ii(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-MD5, of a key and some data
|
||||
*/
|
||||
function core_hmac_md5(key, data)
|
||||
{
|
||||
var bkey = str2binl(key);
|
||||
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
|
||||
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
|
||||
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
|
||||
return core_md5(opad.concat(hash), 512 + 128);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function bit_rol(num, cnt)
|
||||
{
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a string to an array of little-endian words
|
||||
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
|
||||
*/
|
||||
function str2binl(str)
|
||||
{
|
||||
var bin = Array();
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < str.length * chrsz; i += chrsz)
|
||||
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
|
||||
return bin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a string
|
||||
*/
|
||||
function binl2str(bin)
|
||||
{
|
||||
var str = "";
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < bin.length * 32; i += chrsz)
|
||||
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a hex string.
|
||||
*/
|
||||
function binl2hex(binarray)
|
||||
{
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i++)
|
||||
{
|
||||
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
|
||||
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a base-64 string
|
||||
*/
|
||||
function binl2b64(binarray)
|
||||
{
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i += 3)
|
||||
{
|
||||
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
|
||||
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
|
||||
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
|
||||
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
/*
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configurable variables. You may need to tweak these to be compatible with
|
||||
* the server-side, but the defaults work in most cases.
|
||||
*/
|
||||
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
||||
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
||||
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
|
||||
|
||||
/*
|
||||
* These are the functions you'll usually want to call
|
||||
* They take string arguments and return either hex or base-64 encoded strings
|
||||
*/
|
||||
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
|
||||
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
|
||||
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length
|
||||
*/
|
||||
function core_md5(x, len)
|
||||
{
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << ((len) % 32);
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
|
||||
var a = 1732584193;
|
||||
var b = -271733879;
|
||||
var c = -1732584194;
|
||||
var d = 271733878;
|
||||
|
||||
for(var i = 0; i < x.length; i += 16)
|
||||
{
|
||||
var olda = a;
|
||||
var oldb = b;
|
||||
var oldc = c;
|
||||
var oldd = d;
|
||||
|
||||
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
|
||||
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
|
||||
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
|
||||
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
|
||||
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
|
||||
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
|
||||
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
|
||||
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
|
||||
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
|
||||
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
|
||||
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
|
||||
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
|
||||
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
|
||||
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
|
||||
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
|
||||
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
|
||||
|
||||
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
|
||||
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
|
||||
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
|
||||
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
|
||||
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
|
||||
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
|
||||
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
|
||||
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
|
||||
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
|
||||
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
|
||||
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
|
||||
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
|
||||
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
|
||||
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
|
||||
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
|
||||
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
|
||||
|
||||
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
|
||||
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
|
||||
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
|
||||
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
|
||||
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
|
||||
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
|
||||
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
|
||||
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
|
||||
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
|
||||
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
|
||||
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
|
||||
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
|
||||
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
|
||||
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
|
||||
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
|
||||
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
|
||||
|
||||
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
|
||||
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
|
||||
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
|
||||
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
|
||||
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
|
||||
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
|
||||
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
|
||||
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
|
||||
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
|
||||
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
|
||||
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
|
||||
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
|
||||
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
|
||||
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
|
||||
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
|
||||
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
|
||||
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
}
|
||||
return Array(a, b, c, d);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions implement the four basic operations the algorithm uses.
|
||||
*/
|
||||
function md5_cmn(q, a, b, x, s, t)
|
||||
{
|
||||
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
|
||||
}
|
||||
function md5_ff(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
|
||||
}
|
||||
function md5_gg(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
|
||||
}
|
||||
function md5_hh(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
function md5_ii(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-MD5, of a key and some data
|
||||
*/
|
||||
function core_hmac_md5(key, data)
|
||||
{
|
||||
var bkey = str2binl(key);
|
||||
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
|
||||
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
|
||||
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
|
||||
return core_md5(opad.concat(hash), 512 + 128);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function bit_rol(num, cnt)
|
||||
{
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a string to an array of little-endian words
|
||||
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
|
||||
*/
|
||||
function str2binl(str)
|
||||
{
|
||||
var bin = Array();
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < str.length * chrsz; i += chrsz)
|
||||
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
|
||||
return bin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a string
|
||||
*/
|
||||
function binl2str(bin)
|
||||
{
|
||||
var str = "";
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < bin.length * 32; i += chrsz)
|
||||
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a hex string.
|
||||
*/
|
||||
function binl2hex(binarray)
|
||||
{
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i++)
|
||||
{
|
||||
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
|
||||
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a base-64 string
|
||||
*/
|
||||
function binl2b64(binarray)
|
||||
{
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i += 3)
|
||||
{
|
||||
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
|
||||
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
|
||||
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
|
||||
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
@ -1,421 +1,421 @@
|
||||
opnedtab = -1;
|
||||
var previewPopupWindow;
|
||||
MainInformation = "";
|
||||
var smf_images_url = "http://nican132.com/forum/Themes/halflife_11final/images";
|
||||
var smf_formSubmitted = false;
|
||||
var currentSwap = true;
|
||||
|
||||
function FlipPostSpan(){
|
||||
document.getElementById("postspan").style.display = currentSwap ? "" : "none";
|
||||
currentSwap = !currentSwap;
|
||||
}
|
||||
|
||||
currentLoginSwap = true;
|
||||
|
||||
function FlipLoginBox(){
|
||||
document.getElementById("LoginBox").style.display = currentLoginSwap ? "" : "none";
|
||||
currentLoginSwap = !currentLoginSwap;
|
||||
}
|
||||
|
||||
function myMouseMove(e){
|
||||
if (!e){
|
||||
var e = window.event;
|
||||
}
|
||||
if (e.pageX){
|
||||
myDiv.style.left = (e.pageX + 10) + "px";
|
||||
myDiv.style.top = (e.pageY + 10) + "px";
|
||||
}else{
|
||||
myDiv.style.left = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + 20;
|
||||
myDiv.style.top = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + 20;
|
||||
}
|
||||
}
|
||||
|
||||
function ResetSearch(){
|
||||
document.getElementById("txt1").value="";
|
||||
showHint("");
|
||||
}
|
||||
|
||||
function hideSMFunc(){
|
||||
myDiv = document.getElementById("serverbox");
|
||||
myDiv.style.visibility = "hidden";
|
||||
document.onmousemove = "";
|
||||
}
|
||||
|
||||
function LoadPopUP(html){
|
||||
myDiv = document.getElementById("serverbox");
|
||||
myDiv.innerHTML = html;
|
||||
myDiv.style.visibility = "visible";
|
||||
document.onmousemove = myMouseMove;
|
||||
}
|
||||
|
||||
|
||||
function showSMfunc(id){
|
||||
html = '<div style="background-color: #00AAAA"><b>';
|
||||
html += SMfunctions[id][0];
|
||||
html += '</b></div><div style="padding: 2px;">';
|
||||
html += SMfunctions[id][1];
|
||||
html += '</div>';
|
||||
|
||||
LoadPopUP(html);
|
||||
}
|
||||
|
||||
function showSMconst(id){
|
||||
html = '<div style="background-color: #00AAAA"><b>';
|
||||
html += SMconstant[id][0];
|
||||
html += '</b></div><div style="padding: 2px;"><i>';
|
||||
html += SMconstant[id][1];
|
||||
html += '</i><br/>';
|
||||
html += SMconstant[id][2];
|
||||
html += '</div>';
|
||||
|
||||
LoadPopUP(html);
|
||||
}
|
||||
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^\s*/, "").replace(/\s*$/, "");
|
||||
}
|
||||
|
||||
function PrintMain(x){
|
||||
html = '<div style="margin: 2px;" onclick="SpanArea('+x+')">';
|
||||
html += '<img style="vertical-align: bottom" src="imgs/channel.gif" alt="#" /> ';
|
||||
html += SMfiles[x] + '</div><div id="'+ SMfiles[x] +'"></div>';
|
||||
return html;
|
||||
}
|
||||
|
||||
var xmlHttp
|
||||
var BodyHttp
|
||||
|
||||
function showHint(str){
|
||||
str=str.trim();
|
||||
if (str.length==0){
|
||||
//html = "";
|
||||
//for (x in SMfiles){
|
||||
// html += PrintMain(x);
|
||||
//}
|
||||
document.getElementById("txtHint").innerHTML= MainInformation;
|
||||
return
|
||||
}
|
||||
|
||||
xmlHttp=GetXmlHttpObject()
|
||||
|
||||
if (xmlHttp==null){
|
||||
alert ("Browser does not support HTTP Request")
|
||||
return
|
||||
}
|
||||
|
||||
document.getElementById("txtHint").innerHTML="<i>Loading...</i>"
|
||||
|
||||
var url="index.php?action=gethint&id="+str;
|
||||
xmlHttp.onreadystatechange=stateChanged
|
||||
xmlHttp.open("GET",url,true)
|
||||
xmlHttp.send(null)
|
||||
}
|
||||
|
||||
function stateChanged(){
|
||||
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
|
||||
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
|
||||
}
|
||||
}
|
||||
|
||||
function LoadMainPage(url){
|
||||
BodyHttp=GetXmlHttpObject()
|
||||
|
||||
if (BodyHttp==null){
|
||||
alert ("Browser does not support HTTP Request")
|
||||
return
|
||||
}
|
||||
ShowLoading()
|
||||
|
||||
BodyHttp.onreadystatechange=MainStateChanged
|
||||
BodyHttp.open("GET",url,true)
|
||||
BodyHttp.send(null)
|
||||
}
|
||||
|
||||
function MainStateChanged(){
|
||||
if (BodyHttp.readyState==4 || BodyHttp.readyState=="complete"){
|
||||
HideLoading()
|
||||
document.getElementById("MainBody").innerHTML=BodyHttp.responseText
|
||||
}
|
||||
}
|
||||
|
||||
function ShowCustomLink(page){
|
||||
LoadMainPage("index.php?" + page);
|
||||
}
|
||||
|
||||
function ShowFunction(id){
|
||||
hideSMFunc()
|
||||
LoadMainPage("index.php?action=show&id="+id);
|
||||
}
|
||||
|
||||
function ShowFileInfo(id){
|
||||
LoadMainPage("index.php?action=file&id="+id);
|
||||
}
|
||||
function ShowLoading(){
|
||||
ly = document.getElementById("AdminPopUP");
|
||||
|
||||
ly.style.zindex = "100";
|
||||
ly.style.display = "block";
|
||||
}
|
||||
|
||||
function HideLoading(){
|
||||
document.getElementById("AdminPopUP").style.display = "none";
|
||||
}
|
||||
|
||||
function SpanArea(id, hashtml){
|
||||
if(opnedtab >= 0){
|
||||
document.getElementById( SMfiles[opnedtab] ).innerHTML="";
|
||||
if(opnedtab == id){
|
||||
opnedtab = -1;
|
||||
return
|
||||
}
|
||||
}
|
||||
opnedtab = id;
|
||||
ShowFileInfo(id);
|
||||
|
||||
if(!SMfiledata[id])
|
||||
return;
|
||||
|
||||
html = "";
|
||||
arycount = SMfiledata[id].length -1
|
||||
|
||||
for (x in SMfiledata[id]){
|
||||
html += '<img style="vertical-align: bottom" src="imgs/tree_';
|
||||
if(x == arycount) html+= 'end'; else html+= 'mid';
|
||||
html += '.gif" alt="├" /><a onclick="ShowFunction('+ SMfiledata[id][x] +')" onmouseout="hideSMFunc()" onmouseover="showSMfunc('+ SMfiledata[id][x] +')">';
|
||||
html += SMfunctions[ SMfiledata[id][x] ][0] + "</a><br>";
|
||||
|
||||
}
|
||||
if(html != "")
|
||||
document.getElementById( SMfiles[id] ).innerHTML=html
|
||||
|
||||
}
|
||||
|
||||
function getHTMLDocument(url, callback)
|
||||
{
|
||||
if (!window.XMLHttpRequest)
|
||||
return false;
|
||||
|
||||
var myDoc = new XMLHttpRequest();
|
||||
if (typeof(callback) != "undefined")
|
||||
{
|
||||
myDoc.onreadystatechange = function ()
|
||||
{
|
||||
if (myDoc.readyState != 4)
|
||||
return;
|
||||
|
||||
if (myDoc.responseText != null && myDoc.status == 200){
|
||||
callback(myDoc.responseText);
|
||||
}
|
||||
};
|
||||
}
|
||||
myDoc.open('GET', url, true);
|
||||
myDoc.send(null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SubmitLoginInfo(){
|
||||
ShowLoading();
|
||||
|
||||
var url = "index.php?action=login&user=" + document.getElementById("user").value;
|
||||
url += "&pw=" + hex_md5(document.getElementById("pw").value);
|
||||
if(document.getElementById("forever").checked)
|
||||
url += "&forever=1";
|
||||
else
|
||||
url += "&forever=0";
|
||||
|
||||
getHTMLDocument(url, Revivelogin);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function Revivelogin(html){
|
||||
HideLoading();
|
||||
if(html == "ok"){
|
||||
window.location="index.php"
|
||||
return;
|
||||
}
|
||||
|
||||
alert(html);
|
||||
}
|
||||
|
||||
// Send a post form to the server using XMLHttpRequest.
|
||||
function senHTMLDocument(url, content, callback)
|
||||
{
|
||||
if (!window.XMLHttpRequest)
|
||||
return false;
|
||||
|
||||
var sendDoc = new window.XMLHttpRequest();
|
||||
if (typeof(callback) != "undefined")
|
||||
{
|
||||
sendDoc.onreadystatechange = function ()
|
||||
{
|
||||
if (sendDoc.readyState != 4)
|
||||
return;
|
||||
|
||||
if (sendDoc.responseText != null && sendDoc.status == 200)
|
||||
callback(sendDoc.responseText);
|
||||
else
|
||||
callback(false);
|
||||
};
|
||||
}
|
||||
sendDoc.open('POST', url, true);
|
||||
if (typeof(sendDoc.setRequestHeader) != "undefined")
|
||||
sendDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
sendDoc.send(content);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetXmlHttpObject(){
|
||||
var xmlHttp=null;
|
||||
try{
|
||||
// Firefox, Opera 8.0+, Safari
|
||||
xmlHttp=new XMLHttpRequest();
|
||||
}
|
||||
catch (e){
|
||||
// Internet Explorer
|
||||
try{
|
||||
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
|
||||
}
|
||||
catch (e){
|
||||
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
}
|
||||
return xmlHttp;
|
||||
}
|
||||
|
||||
function surroundText(text1, text2, textarea)
|
||||
{
|
||||
// Can a text range be created?
|
||||
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
|
||||
{
|
||||
var caretPos = textarea.caretPos, temp_length = caretPos.text.length;
|
||||
|
||||
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
|
||||
|
||||
if (temp_length == 0)
|
||||
{
|
||||
caretPos.moveStart("character", -text2.length);
|
||||
caretPos.moveEnd("character", -text2.length);
|
||||
caretPos.select();
|
||||
}
|
||||
else
|
||||
textarea.focus(caretPos);
|
||||
}
|
||||
// Mozilla text range wrap.
|
||||
else if (typeof(textarea.selectionStart) != "undefined")
|
||||
{
|
||||
var begin = textarea.value.substr(0, textarea.selectionStart);
|
||||
var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
|
||||
var end = textarea.value.substr(textarea.selectionEnd);
|
||||
var newCursorPos = textarea.selectionStart;
|
||||
var scrollPos = textarea.scrollTop;
|
||||
|
||||
textarea.value = begin + text1 + selection + text2 + end;
|
||||
|
||||
if (textarea.setSelectionRange)
|
||||
{
|
||||
if (selection.length == 0)
|
||||
textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
|
||||
else
|
||||
textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
|
||||
textarea.focus();
|
||||
}
|
||||
textarea.scrollTop = scrollPos;
|
||||
}
|
||||
// Just put them on the end, then.
|
||||
else
|
||||
{
|
||||
textarea.value += text1 + text2;
|
||||
textarea.focus(textarea.value.length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
function textToEntities(text)
|
||||
{
|
||||
var entities = "";
|
||||
for (var i = 0; i < text.length; i++)
|
||||
{
|
||||
var charcode = text.charCodeAt(i);
|
||||
if ((charcode >= 48 && charcode <= 57) || (charcode >= 65 && charcode <= 90) || (charcode >= 97 && charcode <= 122))
|
||||
entities += text.charAt(i);
|
||||
else
|
||||
entities += "&#" + charcode + ";";
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
function bbc_highlight(something, mode){
|
||||
something.style.backgroundImage = "url(" + smf_images_url + (mode ? "/bbc/bbc_hoverbg.gif)" : "/bbc/bbc_bg.gif)");
|
||||
}
|
||||
|
||||
function PreviewPost(){
|
||||
x = new Array();
|
||||
var textFields = ["message"];
|
||||
|
||||
ShowLoading();
|
||||
|
||||
for (i in textFields)
|
||||
if (document.forms.postmodify.elements[textFields[i]])
|
||||
x[x.length] = textFields[i] + "=" + escape(textToEntities(document.forms.postmodify[textFields[i]].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
|
||||
|
||||
senHTMLDocument("index.php?action=previewpost", x.join("&"), PreviewPostSent);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function PreviewPostSent(html){
|
||||
if (previewPopupWindow)
|
||||
previewPopupWindow.close();
|
||||
|
||||
HideLoading();
|
||||
|
||||
thespan = document.getElementById("previewspan");
|
||||
|
||||
thespan.style.display = "";
|
||||
thespan.innerHTML = "Preview: <br/> <div style=\"padding: 5px\">" + html + "</div>";
|
||||
}
|
||||
|
||||
function submitThisOnce(form,id,post)
|
||||
{
|
||||
if (typeof(form.form) != "undefined")
|
||||
form = form.form;
|
||||
|
||||
for (var i = 0; i < form.length; i++)
|
||||
if (typeof(form[i]) != "undefined" && form[i].tagName.toLowerCase() == "textarea")
|
||||
form[i].readOnly = true;
|
||||
|
||||
x = new Array();
|
||||
var textFields = ["message","poster"];
|
||||
|
||||
ShowLoading();
|
||||
|
||||
|
||||
for (i in textFields)
|
||||
if (document.forms.postmodify.elements[textFields[i]])
|
||||
x[x.length] = textFields[i] + "=" + escape(textToEntities(document.forms.postmodify[textFields[i]].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
|
||||
|
||||
senHTMLDocument("index.php?action=post&id=" + id + "&type=" + post, x.join("&"), SentPost);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function SentPost(html){
|
||||
HideLoading();
|
||||
html=html.trim();
|
||||
|
||||
if(html == "0")
|
||||
return alert("Invalid data.")
|
||||
else if (html == "1")
|
||||
return alert("No body data.")
|
||||
else if (html == "2")
|
||||
return alert("Please at least wait 15 secs between each post.");
|
||||
else if (html == "3")
|
||||
return alert("Please login before posting.");
|
||||
else
|
||||
document.getElementById("MainBody").innerHTML= html;
|
||||
|
||||
}
|
||||
|
||||
opnedtab = -1;
|
||||
var previewPopupWindow;
|
||||
MainInformation = "";
|
||||
var smf_images_url = "http://nican132.com/forum/Themes/halflife_11final/images";
|
||||
var smf_formSubmitted = false;
|
||||
var currentSwap = true;
|
||||
|
||||
function FlipPostSpan(){
|
||||
document.getElementById("postspan").style.display = currentSwap ? "" : "none";
|
||||
currentSwap = !currentSwap;
|
||||
}
|
||||
|
||||
currentLoginSwap = true;
|
||||
|
||||
function FlipLoginBox(){
|
||||
document.getElementById("LoginBox").style.display = currentLoginSwap ? "" : "none";
|
||||
currentLoginSwap = !currentLoginSwap;
|
||||
}
|
||||
|
||||
function myMouseMove(e){
|
||||
if (!e){
|
||||
var e = window.event;
|
||||
}
|
||||
if (e.pageX){
|
||||
myDiv.style.left = (e.pageX + 10) + "px";
|
||||
myDiv.style.top = (e.pageY + 10) + "px";
|
||||
}else{
|
||||
myDiv.style.left = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + 20;
|
||||
myDiv.style.top = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + 20;
|
||||
}
|
||||
}
|
||||
|
||||
function ResetSearch(){
|
||||
document.getElementById("txt1").value="";
|
||||
showHint("");
|
||||
}
|
||||
|
||||
function hideSMFunc(){
|
||||
myDiv = document.getElementById("serverbox");
|
||||
myDiv.style.visibility = "hidden";
|
||||
document.onmousemove = "";
|
||||
}
|
||||
|
||||
function LoadPopUP(html){
|
||||
myDiv = document.getElementById("serverbox");
|
||||
myDiv.innerHTML = html;
|
||||
myDiv.style.visibility = "visible";
|
||||
document.onmousemove = myMouseMove;
|
||||
}
|
||||
|
||||
|
||||
function showSMfunc(id){
|
||||
html = '<div style="background-color: #00AAAA"><b>';
|
||||
html += SMfunctions[id][0];
|
||||
html += '</b></div><div style="padding: 2px;">';
|
||||
html += SMfunctions[id][1];
|
||||
html += '</div>';
|
||||
|
||||
LoadPopUP(html);
|
||||
}
|
||||
|
||||
function showSMconst(id){
|
||||
html = '<div style="background-color: #00AAAA"><b>';
|
||||
html += SMconstant[id][0];
|
||||
html += '</b></div><div style="padding: 2px;"><i>';
|
||||
html += SMconstant[id][1];
|
||||
html += '</i><br/>';
|
||||
html += SMconstant[id][2];
|
||||
html += '</div>';
|
||||
|
||||
LoadPopUP(html);
|
||||
}
|
||||
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^\s*/, "").replace(/\s*$/, "");
|
||||
}
|
||||
|
||||
function PrintMain(x){
|
||||
html = '<div style="margin: 2px;" onclick="SpanArea('+x+')">';
|
||||
html += '<img style="vertical-align: bottom" src="imgs/channel.gif" alt="#" /> ';
|
||||
html += SMfiles[x] + '</div><div id="'+ SMfiles[x] +'"></div>';
|
||||
return html;
|
||||
}
|
||||
|
||||
var xmlHttp
|
||||
var BodyHttp
|
||||
|
||||
function showHint(str){
|
||||
str=str.trim();
|
||||
if (str.length==0){
|
||||
//html = "";
|
||||
//for (x in SMfiles){
|
||||
// html += PrintMain(x);
|
||||
//}
|
||||
document.getElementById("txtHint").innerHTML= MainInformation;
|
||||
return
|
||||
}
|
||||
|
||||
xmlHttp=GetXmlHttpObject()
|
||||
|
||||
if (xmlHttp==null){
|
||||
alert ("Browser does not support HTTP Request")
|
||||
return
|
||||
}
|
||||
|
||||
document.getElementById("txtHint").innerHTML="<i>Loading...</i>"
|
||||
|
||||
var url="index.php?action=gethint&id="+str;
|
||||
xmlHttp.onreadystatechange=stateChanged
|
||||
xmlHttp.open("GET",url,true)
|
||||
xmlHttp.send(null)
|
||||
}
|
||||
|
||||
function stateChanged(){
|
||||
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
|
||||
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
|
||||
}
|
||||
}
|
||||
|
||||
function LoadMainPage(url){
|
||||
BodyHttp=GetXmlHttpObject()
|
||||
|
||||
if (BodyHttp==null){
|
||||
alert ("Browser does not support HTTP Request")
|
||||
return
|
||||
}
|
||||
ShowLoading()
|
||||
|
||||
BodyHttp.onreadystatechange=MainStateChanged
|
||||
BodyHttp.open("GET",url,true)
|
||||
BodyHttp.send(null)
|
||||
}
|
||||
|
||||
function MainStateChanged(){
|
||||
if (BodyHttp.readyState==4 || BodyHttp.readyState=="complete"){
|
||||
HideLoading()
|
||||
document.getElementById("MainBody").innerHTML=BodyHttp.responseText
|
||||
}
|
||||
}
|
||||
|
||||
function ShowCustomLink(page){
|
||||
LoadMainPage("index.php?" + page);
|
||||
}
|
||||
|
||||
function ShowFunction(id){
|
||||
hideSMFunc()
|
||||
LoadMainPage("index.php?action=show&id="+id);
|
||||
}
|
||||
|
||||
function ShowFileInfo(id){
|
||||
LoadMainPage("index.php?action=file&id="+id);
|
||||
}
|
||||
function ShowLoading(){
|
||||
ly = document.getElementById("AdminPopUP");
|
||||
|
||||
ly.style.zindex = "100";
|
||||
ly.style.display = "block";
|
||||
}
|
||||
|
||||
function HideLoading(){
|
||||
document.getElementById("AdminPopUP").style.display = "none";
|
||||
}
|
||||
|
||||
function SpanArea(id, hashtml){
|
||||
if(opnedtab >= 0){
|
||||
document.getElementById( SMfiles[opnedtab] ).innerHTML="";
|
||||
if(opnedtab == id){
|
||||
opnedtab = -1;
|
||||
return
|
||||
}
|
||||
}
|
||||
opnedtab = id;
|
||||
ShowFileInfo(id);
|
||||
|
||||
if(!SMfiledata[id])
|
||||
return;
|
||||
|
||||
html = "";
|
||||
arycount = SMfiledata[id].length -1
|
||||
|
||||
for (x in SMfiledata[id]){
|
||||
html += '<img style="vertical-align: bottom" src="imgs/tree_';
|
||||
if(x == arycount) html+= 'end'; else html+= 'mid';
|
||||
html += '.gif" alt="├" /><a onclick="ShowFunction('+ SMfiledata[id][x] +')" onmouseout="hideSMFunc()" onmouseover="showSMfunc('+ SMfiledata[id][x] +')">';
|
||||
html += SMfunctions[ SMfiledata[id][x] ][0] + "</a><br>";
|
||||
|
||||
}
|
||||
if(html != "")
|
||||
document.getElementById( SMfiles[id] ).innerHTML=html
|
||||
|
||||
}
|
||||
|
||||
function getHTMLDocument(url, callback)
|
||||
{
|
||||
if (!window.XMLHttpRequest)
|
||||
return false;
|
||||
|
||||
var myDoc = new XMLHttpRequest();
|
||||
if (typeof(callback) != "undefined")
|
||||
{
|
||||
myDoc.onreadystatechange = function ()
|
||||
{
|
||||
if (myDoc.readyState != 4)
|
||||
return;
|
||||
|
||||
if (myDoc.responseText != null && myDoc.status == 200){
|
||||
callback(myDoc.responseText);
|
||||
}
|
||||
};
|
||||
}
|
||||
myDoc.open('GET', url, true);
|
||||
myDoc.send(null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SubmitLoginInfo(){
|
||||
ShowLoading();
|
||||
|
||||
var url = "index.php?action=login&user=" + document.getElementById("user").value;
|
||||
url += "&pw=" + hex_md5(document.getElementById("pw").value);
|
||||
if(document.getElementById("forever").checked)
|
||||
url += "&forever=1";
|
||||
else
|
||||
url += "&forever=0";
|
||||
|
||||
getHTMLDocument(url, Revivelogin);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function Revivelogin(html){
|
||||
HideLoading();
|
||||
if(html == "ok"){
|
||||
window.location="index.php"
|
||||
return;
|
||||
}
|
||||
|
||||
alert(html);
|
||||
}
|
||||
|
||||
// Send a post form to the server using XMLHttpRequest.
|
||||
function senHTMLDocument(url, content, callback)
|
||||
{
|
||||
if (!window.XMLHttpRequest)
|
||||
return false;
|
||||
|
||||
var sendDoc = new window.XMLHttpRequest();
|
||||
if (typeof(callback) != "undefined")
|
||||
{
|
||||
sendDoc.onreadystatechange = function ()
|
||||
{
|
||||
if (sendDoc.readyState != 4)
|
||||
return;
|
||||
|
||||
if (sendDoc.responseText != null && sendDoc.status == 200)
|
||||
callback(sendDoc.responseText);
|
||||
else
|
||||
callback(false);
|
||||
};
|
||||
}
|
||||
sendDoc.open('POST', url, true);
|
||||
if (typeof(sendDoc.setRequestHeader) != "undefined")
|
||||
sendDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
sendDoc.send(content);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetXmlHttpObject(){
|
||||
var xmlHttp=null;
|
||||
try{
|
||||
// Firefox, Opera 8.0+, Safari
|
||||
xmlHttp=new XMLHttpRequest();
|
||||
}
|
||||
catch (e){
|
||||
// Internet Explorer
|
||||
try{
|
||||
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
|
||||
}
|
||||
catch (e){
|
||||
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
}
|
||||
return xmlHttp;
|
||||
}
|
||||
|
||||
function surroundText(text1, text2, textarea)
|
||||
{
|
||||
// Can a text range be created?
|
||||
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
|
||||
{
|
||||
var caretPos = textarea.caretPos, temp_length = caretPos.text.length;
|
||||
|
||||
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
|
||||
|
||||
if (temp_length == 0)
|
||||
{
|
||||
caretPos.moveStart("character", -text2.length);
|
||||
caretPos.moveEnd("character", -text2.length);
|
||||
caretPos.select();
|
||||
}
|
||||
else
|
||||
textarea.focus(caretPos);
|
||||
}
|
||||
// Mozilla text range wrap.
|
||||
else if (typeof(textarea.selectionStart) != "undefined")
|
||||
{
|
||||
var begin = textarea.value.substr(0, textarea.selectionStart);
|
||||
var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
|
||||
var end = textarea.value.substr(textarea.selectionEnd);
|
||||
var newCursorPos = textarea.selectionStart;
|
||||
var scrollPos = textarea.scrollTop;
|
||||
|
||||
textarea.value = begin + text1 + selection + text2 + end;
|
||||
|
||||
if (textarea.setSelectionRange)
|
||||
{
|
||||
if (selection.length == 0)
|
||||
textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
|
||||
else
|
||||
textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
|
||||
textarea.focus();
|
||||
}
|
||||
textarea.scrollTop = scrollPos;
|
||||
}
|
||||
// Just put them on the end, then.
|
||||
else
|
||||
{
|
||||
textarea.value += text1 + text2;
|
||||
textarea.focus(textarea.value.length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
function textToEntities(text)
|
||||
{
|
||||
var entities = "";
|
||||
for (var i = 0; i < text.length; i++)
|
||||
{
|
||||
var charcode = text.charCodeAt(i);
|
||||
if ((charcode >= 48 && charcode <= 57) || (charcode >= 65 && charcode <= 90) || (charcode >= 97 && charcode <= 122))
|
||||
entities += text.charAt(i);
|
||||
else
|
||||
entities += "&#" + charcode + ";";
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
function bbc_highlight(something, mode){
|
||||
something.style.backgroundImage = "url(" + smf_images_url + (mode ? "/bbc/bbc_hoverbg.gif)" : "/bbc/bbc_bg.gif)");
|
||||
}
|
||||
|
||||
function PreviewPost(){
|
||||
x = new Array();
|
||||
var textFields = ["message"];
|
||||
|
||||
ShowLoading();
|
||||
|
||||
for (i in textFields)
|
||||
if (document.forms.postmodify.elements[textFields[i]])
|
||||
x[x.length] = textFields[i] + "=" + escape(textToEntities(document.forms.postmodify[textFields[i]].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
|
||||
|
||||
senHTMLDocument("index.php?action=previewpost", x.join("&"), PreviewPostSent);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function PreviewPostSent(html){
|
||||
if (previewPopupWindow)
|
||||
previewPopupWindow.close();
|
||||
|
||||
HideLoading();
|
||||
|
||||
thespan = document.getElementById("previewspan");
|
||||
|
||||
thespan.style.display = "";
|
||||
thespan.innerHTML = "Preview: <br/> <div style=\"padding: 5px\">" + html + "</div>";
|
||||
}
|
||||
|
||||
function submitThisOnce(form,id,post)
|
||||
{
|
||||
if (typeof(form.form) != "undefined")
|
||||
form = form.form;
|
||||
|
||||
for (var i = 0; i < form.length; i++)
|
||||
if (typeof(form[i]) != "undefined" && form[i].tagName.toLowerCase() == "textarea")
|
||||
form[i].readOnly = true;
|
||||
|
||||
x = new Array();
|
||||
var textFields = ["message","poster"];
|
||||
|
||||
ShowLoading();
|
||||
|
||||
|
||||
for (i in textFields)
|
||||
if (document.forms.postmodify.elements[textFields[i]])
|
||||
x[x.length] = textFields[i] + "=" + escape(textToEntities(document.forms.postmodify[textFields[i]].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
|
||||
|
||||
senHTMLDocument("index.php?action=post&id=" + id + "&type=" + post, x.join("&"), SentPost);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function SentPost(html){
|
||||
HideLoading();
|
||||
html=html.trim();
|
||||
|
||||
if(html == "0")
|
||||
return alert("Invalid data.")
|
||||
else if (html == "1")
|
||||
return alert("No body data.")
|
||||
else if (html == "2")
|
||||
return alert("Please at least wait 15 secs between each post.");
|
||||
else if (html == "3")
|
||||
return alert("Please login before posting.");
|
||||
else
|
||||
document.getElementById("MainBody").innerHTML= html;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user