1
+ − 1
// Some additional DHTML functions
+ − 2
+ − 3
function fetch_offset(obj) {
+ − 4
var left_offset = obj.offsetLeft;
+ − 5
var top_offset = obj.offsetTop;
+ − 6
while ((obj = obj.offsetParent) != null) {
+ − 7
left_offset += obj.offsetLeft;
+ − 8
top_offset += obj.offsetTop;
+ − 9
}
+ − 10
return { 'left' : left_offset, 'top' : top_offset };
+ − 11
}
+ − 12
+ − 13
function fetch_dimensions(o) {
+ − 14
var w = o.offsetWidth;
+ − 15
var h = o.offsetHeight;
+ − 16
return { 'w' : w, 'h' : h };
+ − 17
}
+ − 18
+ − 19
function findParentForm(o)
+ − 20
{
+ − 21
// Not implemented - someone please let me know how to do this, what I need to do is
+ − 22
// find the first parent <form> tag above param 'o', not sure how to do it with DOM
+ − 23
}
+ − 24
+ − 25
function ajaxReverseDNS(o, text)
+ − 26
{
+ − 27
if(text) var ipaddr = text;
+ − 28
else var ipaddr = o.innerHTML;
+ − 29
rDnsObj = o;
+ − 30
rDnsBannerObj = bannerOn('Retrieving reverse DNS info...');
+ − 31
ajaxGet(stdAjaxPrefix+'&_mode=rdns&ip='+ipaddr, function() {
+ − 32
if(ajax.readyState == 4)
+ − 33
{
+ − 34
off = fetch_offset(rDnsObj);
+ − 35
dim = fetch_dimensions(rDnsObj);
+ − 36
right = off['left'] + dim['w'];
+ − 37
top = off['top'] + dim['h'];
+ − 38
var thediv = document.createElement('div');
+ − 39
thediv.className = 'info-box';
+ − 40
thediv.style.margin = '0';
+ − 41
thediv.style.position = 'absolute';
+ − 42
thediv.style.top = top + 'px';
+ − 43
thediv.style.display = 'none';
+ − 44
thediv.style.zIndex = getHighestZ() + 2;
+ − 45
thediv.id = 'mdgDynamic_rDnsInfoDiv_'+Math.floor(Math.random() * 1000000);
+ − 46
thediv.innerHTML = '<b>Reverse DNS:</b><br />'+ajax.responseText+' <a href="#" onclick="elem = document.getElementById(\''+thediv.id+'\'); elem.innerHTML = \'\'; elem.style.display = \'none\';return false;">Close</a>';
+ − 47
var body = document.getElementsByTagName('body');
+ − 48
body = body[0];
+ − 49
bannerOff(rDnsBannerObj);
+ − 50
body.appendChild(thediv);
+ − 51
thediv.style.display = 'block';
+ − 52
left = fetch_dimensions(thediv);
+ − 53
thediv.style.display = 'none';
+ − 54
left = right - left['w'];
+ − 55
thediv.style.left = left + 'px';
+ − 56
thediv.style.display = 'block';
+ − 57
fadeInfoBoxes();
+ − 58
}
+ − 59
});
+ − 60
}
+ − 61
+ − 62
function bannerOn(text)
+ − 63
{
+ − 64
darken(true);
+ − 65
var thediv = document.createElement('div');
+ − 66
thediv.className = 'mdg-comment';
+ − 67
thediv.style.padding = '0';
+ − 68
thediv.style.marginLeft = '0';
+ − 69
thediv.style.position = 'absolute';
+ − 70
thediv.style.display = 'none';
+ − 71
thediv.style.padding = '4px';
+ − 72
thediv.style.fontSize = '14pt';
+ − 73
thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000);
+ − 74
thediv.innerHTML = text;
+ − 75
+ − 76
var body = document.getElementsByTagName('body');
+ − 77
body = body[0];
+ − 78
body.appendChild(thediv);
+ − 79
body.style.cursor = 'wait';
+ − 80
+ − 81
thediv.style.display = 'block';
+ − 82
dim = fetch_dimensions(thediv);
+ − 83
thediv.style.display = 'none';
+ − 84
bdim = { 'w' : getWidth(), 'h' : getHeight() };
+ − 85
so = getScrollOffset();
+ − 86
40
+ − 87
var left = (bdim['w'] / 2) - ( dim['w'] / 2 );
+ − 88
+ − 89
var top = (bdim['h'] / 2);
+ − 90
top = top - ( dim['h'] / 2 );
+ − 91
+ − 92
top = top + so;
1
+ − 93
+ − 94
thediv.style.top = top + 'px';
+ − 95
thediv.style.left = left + 'px';
+ − 96
+ − 97
thediv.style.display = 'block';
+ − 98
+ − 99
return thediv.id;
+ − 100
}
+ − 101
+ − 102
function bannerOff(id)
+ − 103
{
+ − 104
e = document.getElementById(id);
+ − 105
if(!e) return;
+ − 106
e.innerHTML = '';
+ − 107
e.style.display = 'none';
+ − 108
var body = document.getElementsByTagName('body');
+ − 109
body = body[0];
+ − 110
body.style.cursor = 'default';
+ − 111
enlighten(true);
+ − 112
}
+ − 113
+ − 114
function disableUnload(message)
+ − 115
{
+ − 116
if(typeof message != 'string') message = 'You may want to save your changes first.';
+ − 117
var body = document.getElementsByTagName('body');
+ − 118
body = body[0];
+ − 119
body.onbeforeunload='return unescape(\''+escape(message)+'\')';
+ − 120
}
+ − 121
+ − 122
function enableUnload()
+ − 123
{
+ − 124
var body = document.getElementsByTagName('body');
+ − 125
body = body[0];
+ − 126
body.onbeforeunload = null;
+ − 127
}
+ − 128
+ − 129
/**
+ − 130
* Gets the highest z-index of all divs in the document
+ − 131
* @return integer
+ − 132
*/
+ − 133
function getHighestZ()
+ − 134
{
+ − 135
z = 0;
+ − 136
var divs = document.getElementsByTagName('div');
+ − 137
for(var i = 0; i < divs.length; i++)
+ − 138
{
+ − 139
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex;
+ − 140
}
+ − 141
return z;
+ − 142
}
+ − 143
+ − 144
function isKeyPressed(event)
+ − 145
{
+ − 146
if (event.shiftKey==1)
+ − 147
{
+ − 148
shift = true;
+ − 149
}
+ − 150
else
+ − 151
{
+ − 152
shift = false;
+ − 153
}
+ − 154
}
+ − 155
+ − 156
function moveDiv(div, newparent)
+ − 157
{
+ − 158
var backup = div;
+ − 159
var oldparent = div.parentNode;
+ − 160
oldparent.removeChild(div);
+ − 161
newparent.appendChild(backup);
+ − 162
}
+ − 163
+ − 164
function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}
+ − 165
function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}
+ − 166
function eraseCookie(name) {createCookie(name,"",-1);}
+ − 167
+ − 168
var busyBannerID;
+ − 169
function goBusy(msg)
+ − 170
{
+ − 171
if(!msg) msg = 'Please wait...';
+ − 172
body = document.getElementsByTagName('body');
+ − 173
body = body[0];
+ − 174
body.style.cursor = 'wait';
+ − 175
busyBannerID = bannerOn(msg);
+ − 176
}
+ − 177
+ − 178
function unBusy()
+ − 179
{
+ − 180
body = document.getElementsByTagName('body');
+ − 181
body = body[0];
+ − 182
body.style.cursor = 'default';
+ − 183
bannerOff(busyBannerID);
+ − 184
}
+ − 185
+ − 186
function setAjaxLoading()
+ − 187
{
+ − 188
if ( document.getElementById('ajaxloadicon') )
+ − 189
{
+ − 190
document.getElementById('ajaxloadicon').src=scriptPath + '/images/loading.gif';
+ − 191
}
+ − 192
}
+ − 193
+ − 194
function unsetAjaxLoading()
+ − 195
{
+ − 196
if ( document.getElementById('ajaxloadicon') )
+ − 197
{
+ − 198
document.getElementById('ajaxloadicon').src=scriptPath + '/images/spacer.gif';
+ − 199
}
+ − 200
}
+ − 201
+ − 202
/*
+ − 203
* Search boxes
+ − 204
*/
+ − 205
+ − 206
function buildSearchBoxes()
+ − 207
{
+ − 208
var divs = document.getElementsByTagName('*');
+ − 209
var boxes = new Array();
+ − 210
for ( var i = 0; i < divs.length; i++ )
+ − 211
{
+ − 212
if ( divs[i].className)
+ − 213
{
+ − 214
if ( divs[i].className.substr(0, 9) == 'searchbox' )
+ − 215
{
+ − 216
boxes.push(divs[i]);
+ − 217
}
+ − 218
}
+ − 219
}
+ − 220
for ( var i = 0; i < boxes.length; i++ )
+ − 221
{
+ − 222
if ( boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/) )
+ − 223
{
+ − 224
var width = boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/);
+ − 225
width = parseInt(width[1]);
+ − 226
}
+ − 227
else
+ − 228
{
+ − 229
var width = 120;
+ − 230
}
+ − 231
createSearchBox(boxes[i], width);
+ − 232
}
+ − 233
}
+ − 234
+ − 235
function createSearchBox(parent, width)
+ − 236
{
+ − 237
if ( typeof(parent) != 'object')
+ − 238
{
+ − 239
alert('BUG: createSearchBox(): parent is not an object');
+ − 240
return false;
+ − 241
}
+ − 242
//parent.style.padding = '0px';
+ − 243
//parent.style.textAlign = 'center';
+ − 244
parent.style.width = width + 'px';
+ − 245
var submit = document.createElement('div');
+ − 246
submit.onclick = function() { searchFormSubmit(this); };
+ − 247
submit.className = 'js-search-submit';
+ − 248
var input = document.createElement('input');
+ − 249
input.className = 'js-search-box';
+ − 250
input.value = 'Search';
+ − 251
input.name = 'q';
+ − 252
input.style.width = ( width - 28 ) + 'px';
+ − 253
input.onfocus = function() { if ( this.value == 'Search' ) this.value = ''; };
+ − 254
input.onblur = function() { if ( this.value == '' ) this.value = 'Search'; };
+ − 255
parent.appendChild(input);
+ − 256
var off = fetch_offset(input);
+ − 257
var top = off['top'] + 'px';
+ − 258
var left = ( parseInt(off['left']) + ( width - 24 ) ) + 'px';
+ − 259
submit.style.top = top;
+ − 260
submit.style.left = left;
+ − 261
parent.appendChild(submit);
+ − 262
}
+ − 263
+ − 264
function searchFormSubmit(obj)
+ − 265
{
+ − 266
var input = obj.previousSibling;
+ − 267
if ( input.value == 'Search' || input.value == '' )
+ − 268
return false;
+ − 269
var p = obj;
+ − 270
while(true)
+ − 271
{
+ − 272
p = p.parentNode;
+ − 273
if ( !p )
+ − 274
break;
+ − 275
if ( typeof(p.tagName) != 'string' )
+ − 276
break;
+ − 277
else if ( p.tagName.toLowerCase() == 'form' )
+ − 278
{
+ − 279
p.submit();
+ − 280
}
+ − 281
else if ( p.tagName.toLowerCase() == 'body' )
+ − 282
{
+ − 283
break;
+ − 284
}
+ − 285
}
+ − 286
}
+ − 287
+ − 288
/*
+ − 289
* AJAX login box (experimental)
+ − 290
*/
+ − 291
+ − 292
var ajax_auth_prompt_cache = false;
+ − 293
var ajax_auth_mb_cache = false;
+ − 294
var ajax_auth_level_cache = false;
+ − 295
+ − 296
function ajaxPromptAdminAuth(call_on_ok, level)
+ − 297
{
+ − 298
if ( typeof(call_on_ok) == 'function' )
+ − 299
{
+ − 300
ajax_auth_prompt_cache = call_on_ok;
+ − 301
}
+ − 302
if ( !level )
+ − 303
level = 2;
+ − 304
ajax_auth_level_cache = level;
+ − 305
var loading_win = '<div align="center" style="text-align: center;"> \
+ − 306
<p>Fetching an encryption key...</p> \
+ − 307
<p><small>Not working? Use the <a href="'+makeUrlNS('Special', 'Login/' + title)+'">alternate login form</a>.</p> \
+ − 308
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \
+ − 309
</div>';
+ − 310
ajax_auth_mb_cache = new messagebox(MB_OKCANCEL|MB_ICONLOCK, 'Please enter your username and password to continue.', loading_win);
+ − 311
ajax_auth_mb_cache.onbeforeclick['OK'] = ajaxValidateLogin;
+ − 312
ajaxAuthLoginInnerSetup();
+ − 313
}
+ − 314
+ − 315
function ajaxAuthLoginInnerSetup()
+ − 316
{
+ − 317
ajaxGet(makeUrlNS('Special', 'Login', 'act=getkey'), function() {
+ − 318
if ( ajax.readyState == 4 )
+ − 319
{
40
+ − 320
var response = String(ajax.responseText);
1
+ − 321
if ( response.substr(0,1) != '{' )
+ − 322
{
+ − 323
alert('Invalid JSON response from server: ' + response);
+ − 324
return false;
+ − 325
}
+ − 326
response = parseJSON(response);
+ − 327
var form_html = ' \
+ − 328
<table border="0" align="center"> \
+ − 329
<tr> \
+ − 330
<td>Username:</td><td><input tabindex="1" id="ajaxlogin_user" type="text" size="25" /> \
+ − 331
</tr> \
+ − 332
<tr> \
+ − 333
<td>Password:</td><td><input tabindex="2" id="ajaxlogin_pass" type="password" size="25" /> \
+ − 334
</tr> \
+ − 335
<tr> \
+ − 336
<td colspan="2" style="text-align: center;"> \
+ − 337
<br /><small>Trouble logging in? Try the <a href="'+makeUrlNS('Special', 'Login/' + title)+'">full login form</a>.<br /> \
+ − 338
Did you <a href="'+makeUrlNS('Special', 'PasswordReset')+'">forget your password</a>?<br /> \
+ − 339
Maybe you need to <a href="'+makeUrlNS('Special', 'Register')+'">create an account</a>.</small> \
+ − 340
</td> \
+ − 341
</tr> \
+ − 342
</table> \
+ − 343
<input type="hidden" id="ajaxlogin_crypt_key" value="' + response.key + '" /> \
+ − 344
<input type="hidden" id="ajaxlogin_crypt_challenge" value="' + response.challenge + '" /> \
+ − 345
</form>';
+ − 346
ajax_auth_mb_cache.updateContent(form_html);
+ − 347
$('messageBox').object.nextSibling.firstChild.tabindex = '3';
+ − 348
$('ajaxlogin_user').object.focus();
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 349
$('ajaxlogin_pass').object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); };
40
+ − 350
$('ajaxlogin_pass').object.onkeypress = function(e) { if ( !e && IE ) return true; if ( e.keyCode == 13 ) $('messageBox').object.nextSibling.firstChild.click(); };
1
+ − 351
}
+ − 352
});
+ − 353
}
+ − 354
+ − 355
function ajaxValidateLogin()
+ − 356
{
+ − 357
var username,password,auth_enabled,crypt_key,crypt_data,challenge_salt,challenge_data;
+ − 358
username = document.getElementById('ajaxlogin_user');
+ − 359
if ( !username )
+ − 360
return false;
+ − 361
username = document.getElementById('ajaxlogin_user').value;
+ − 362
password = document.getElementById('ajaxlogin_pass').value;
+ − 363
auth_enabled = false;
+ − 364
+ − 365
disableJSONExts();
+ − 366
+ − 367
//
+ − 368
// Encryption test
+ − 369
//
+ − 370
+ − 371
var str = '';
+ − 372
for(i=0;i<keySizeInBits/4;i++)
+ − 373
{
+ − 374
str+='0';
+ − 375
}
+ − 376
str = hexToByteArray(str);
+ − 377
var ct = rijndaelEncrypt(str, str, 'ECB');
+ − 378
ct = byteArrayToHex(ct);
+ − 379
var v;
+ − 380
switch(keySizeInBits)
+ − 381
{
+ − 382
case 128:
+ − 383
v = '66e94bd4ef8a2c3b884cfa59ca342b2e';
+ − 384
break;
+ − 385
case 192:
+ − 386
v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7';
+ − 387
break;
+ − 388
case 256:
+ − 389
v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087';
+ − 390
break;
+ − 391
}
+ − 392
auth_enabled = ( ct == v && md5_vm_test() );
+ − 393
if ( !auth_enabled )
+ − 394
{
+ − 395
alert('Login error: encryption sanity check failed\n');
+ − 396
return true;
+ − 397
}
+ − 398
+ − 399
crypt_key = document.getElementById('ajaxlogin_crypt_key').value;
+ − 400
challenge_salt = document.getElementById('ajaxlogin_crypt_challenge').value;
+ − 401
+ − 402
var crypt_key_md5 = hex_md5(crypt_key);
+ − 403
+ − 404
challenge_data = hex_md5(password + challenge_salt) + challenge_salt;
+ − 405
+ − 406
password = stringToByteArray(password);
+ − 407
crypt_key = hexToByteArray(crypt_key);
+ − 408
+ − 409
crypt_data = rijndaelEncrypt(password, crypt_key, 'ECB');
+ − 410
crypt_data = byteArrayToHex(crypt_data);
+ − 411
+ − 412
var json_data = {
+ − 413
'username' : username,
+ − 414
'crypt_key' : crypt_key_md5,
+ − 415
'challenge' : challenge_data,
+ − 416
'crypt_data' : crypt_data,
+ − 417
'level' : ajax_auth_level_cache
+ − 418
};
+ − 419
+ − 420
json_data = toJSONString(json_data);
+ − 421
json_data = ajaxEscape(json_data);
+ − 422
+ − 423
var loading_win = '<div align="center" style="text-align: center;"> \
+ − 424
<p>Logging in...</p> \
+ − 425
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \
+ − 426
</div>';
+ − 427
+ − 428
ajax_auth_mb_cache.updateContent(loading_win);
+ − 429
+ − 430
ajaxPost(makeUrlNS('Special', 'Login', 'act=ajaxlogin'), 'params=' + json_data, function() {
+ − 431
if ( ajax.readyState == 4 )
+ − 432
{
+ − 433
var response = ajax.responseText;
+ − 434
if ( response.substr(0,1) != '{' )
+ − 435
{
+ − 436
alert('Invalid JSON response from server: ' + response);
+ − 437
ajaxAuthLoginInnerSetup();
+ − 438
return false;
+ − 439
}
+ − 440
response = parseJSON(response);
+ − 441
switch(response.result)
+ − 442
{
+ − 443
case 'success':
+ − 444
if ( typeof(ajax_auth_prompt_cache) == 'function' )
+ − 445
{
+ − 446
ajax_auth_prompt_cache(response.key);
+ − 447
}
+ − 448
break;
+ − 449
case 'success_reset':
+ − 450
var conf = confirm('You have logged in using a temporary password. Before you can log in, you must finish resetting your password. Do you want to reset your real password now?');
+ − 451
if ( conf )
+ − 452
{
+ − 453
var url = makeUrlNS('Special', 'PasswordReset/stage2/' + response.user_id + '/' + response.temppass);
+ − 454
window.location = url;
+ − 455
}
+ − 456
else
+ − 457
{
+ − 458
ajaxAuthLoginInnerSetup();
+ − 459
}
+ − 460
break;
+ − 461
case 'error':
+ − 462
alert(response.error);
+ − 463
ajaxAuthLoginInnerSetup();
+ − 464
break;
+ − 465
default:
+ − 466
alert(ajax.responseText);
+ − 467
break;
+ − 468
}
+ − 469
}
+ − 470
});
+ − 471
+ − 472
return true;
+ − 473
+ − 474
}
+ − 475
+ − 476
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/
+ − 477
function sprintf()
+ − 478
{
+ − 479
if (!arguments || arguments.length < 1 || !RegExp)
+ − 480
{
+ − 481
return;
+ − 482
}
+ − 483
var str = arguments[0];
+ − 484
var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
+ − 485
var a = b = [], numSubstitutions = 0, numMatches = 0;
+ − 486
while (a = re.exec(str))
+ − 487
{
+ − 488
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
+ − 489
var pPrecision = a[5], pType = a[6], rightPart = a[7];
+ − 490
+ − 491
//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);
+ − 492
+ − 493
numMatches++;
+ − 494
if (pType == '%')
+ − 495
{
+ − 496
subst = '%';
+ − 497
}
+ − 498
else
+ − 499
{
+ − 500
numSubstitutions++;
+ − 501
if (numSubstitutions >= arguments.length)
+ − 502
{
+ − 503
alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
+ − 504
}
+ − 505
var param = arguments[numSubstitutions];
+ − 506
var pad = '';
+ − 507
if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
+ − 508
else if (pPad) pad = pPad;
+ − 509
var justifyRight = true;
+ − 510
if (pJustify && pJustify === "-") justifyRight = false;
+ − 511
var minLength = -1;
+ − 512
if (pMinLength) minLength = parseInt(pMinLength);
+ − 513
var precision = -1;
+ − 514
if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
+ − 515
var subst = param;
+ − 516
if (pType == 'b') subst = parseInt(param).toString(2);
+ − 517
else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
+ − 518
else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
+ − 519
else if (pType == 'u') subst = Math.abs(param);
+ − 520
else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
+ − 521
else if (pType == 'o') subst = parseInt(param).toString(8);
+ − 522
else if (pType == 's') subst = param;
+ − 523
else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
+ − 524
else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
+ − 525
}
+ − 526
str = leftpart + subst + rightPart;
+ − 527
}
+ − 528
return str;
+ − 529
}
+ − 530
+ − 531
function paginator_goto(parentobj, this_page, num_pages, perpage, url_string)
+ − 532
{
+ − 533
var height = $(parentobj).Height();
+ − 534
var width = $(parentobj).Width();
+ − 535
var left = $(parentobj).Left();
+ − 536
var top = $(parentobj).Top();
+ − 537
var left_pos = left + width ;
+ − 538
var top_pos = height + top;
+ − 539
var div = document.createElement('div');
+ − 540
div.style.position = 'absolute';
+ − 541
div.style.top = top_pos + 'px';
+ − 542
div.className = 'question-box';
+ − 543
div.style.margin = '1px 0 0 2px';
+ − 544
var vtmp = 'input_' + Math.floor(Math.random() * 1000000);
+ − 545
div.innerHTML = 'Go to page:<br /><input type="text" size="2" style="padding: 1px; font-size: 8pt;" value="'+(parseInt(this_page)+1)+'" id="'+vtmp+'" /> <a href="#" onclick="paginator_submit(this, '+num_pages+', '+perpage+', unescape(\'' + escape(url_string) + '\')); return false;" style="font-size: 14pt; text-decoration: none;">»</a> <a href="#" onclick="fly_out_top(this.parentNode, false, true); return false;" style="font-size: 14pt; text-decoration: none;">×</a>';
+ − 546
+ − 547
var body = document.getElementsByTagName('body')[0];
+ − 548
body.appendChild(div);
+ − 549
+ − 550
document.getElementById(vtmp).onkeypress = function(e){if(e.keyCode==13)this.nextSibling.nextSibling.onclick();};
+ − 551
document.getElementById(vtmp).focus();
+ − 552
+ − 553
// fade the div
+ − 554
/*
+ − 555
if(!div.id) div.id = 'autofade_'+Math.floor(Math.random() * 100000);
+ − 556
var from = '#33FF33';
+ − 557
Fat.fade_element(div.id,30,2000,from,Fat.get_bgcolor(div.id));
+ − 558
*/
+ − 559
fly_in_bottom(div, false, true);
+ − 560
+ − 561
var divh = $(div).Width();
+ − 562
left_pos = left_pos - divh;
+ − 563
div.style.left = left_pos + 'px';
+ − 564
}
+ − 565
+ − 566
function paginator_submit(obj, max, perpage, formatstring)
+ − 567
{
+ − 568
var userinput = obj.previousSibling.previousSibling.value;
+ − 569
userinput = parseInt(userinput);
+ − 570
var offset = ( userinput - 1 ) * perpage;
+ − 571
if ( userinput > max || isNaN(userinput) || userinput < 1 )
+ − 572
{
+ − 573
new messagebox(MB_OK|MB_ICONSTOP, 'Invalid entry', 'Please enter a page number between 1 and ' + max + '.');
+ − 574
return false;
+ − 575
}
+ − 576
var url = sprintf(formatstring, String(offset));
+ − 577
fly_out_top(obj.parentNode, false, true);
+ − 578
window.location = url;
+ − 579
}
+ − 580