582
+ − 1
/*
+ − 2
* Enano - an open source wiki-like CMS
+ − 3
* Copyright (C) 2006-2007 Dan Fuhry
+ − 4
* Javascript client library
+ − 5
*
+ − 6
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
+ − 7
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ − 8
*
+ − 9
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ − 10
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ − 11
*
+ − 12
* For more information about Enano, please visit http://enanocms.org/.
+ − 13
* Unless otherwise noted, all of the code in these script files may be used freely so long as the above license block
+ − 14
* is displayed and your modified code is distributed in compliance with the GPL. See the special page "About Enano" on
+ − 15
* this website for more information.
+ − 16
*/
+ − 17
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 18
if ( typeof(title) != 'string')
582
+ − 19
{
+ − 20
alert('There was a problem loading the PHP-generated Javascript variables that control parameters for AJAX applets. Most on-page functionality will be very badly broken.\n\nTheme developers, ensure that you are using {JS_DYNAMIC_VARS} *before* you include jsres.php.');
+ − 21
}
+ − 22
588
+ − 23
// placeholder for window.console - used if firebug isn't present
+ − 24
// http://getfirebug.com/firebug/firebugx.js
+ − 25
if (!window.console || !console.firebug)
+ − 26
{
+ − 27
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
+ − 28
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
+ − 29
+ − 30
window.console = {};
+ − 31
for (var i = 0; i < names.length; ++i)
+ − 32
window.console[names[i]] = function() {}
+ − 33
}
+ − 34
+ − 35
console.info('Enano::JS runtime: starting system init');
+ − 36
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 37
if ( typeof(ENANO_JSRES_COMPRESSED) == undefined )
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 38
{
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 39
var ENANO_JSRES_COMPRESSED = false;
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 40
}
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 41
582
+ − 42
// Run-time variables
+ − 43
+ − 44
var detect = navigator.userAgent.toLowerCase();
+ − 45
var IE;
+ − 46
var is_Safari;
+ − 47
+ − 48
// Detect whether the user is running the Evil One or not...
+ − 49
+ − 50
function checkIt(string) {
+ − 51
place = detect.indexOf(string) + 1;
+ − 52
thestring = string;
+ − 53
return place;
+ − 54
}
+ − 55
if (checkIt('msie')) IE = true;
+ − 56
else IE = false;
+ − 57
+ − 58
var is_Opera = ( checkIt('opera') ) ? true : false;
+ − 59
var is_iPhone = ( checkIt('iphone') || checkIt('ipod') ) ? true : false;
+ − 60
var is_firefox2 = ( checkIt('firefox/2.') ) ? true : false;
+ − 61
+ − 62
var KILL_SWITCH = false;
+ − 63
+ − 64
if ( IE )
+ − 65
{
+ − 66
var version = window.navigator.appVersion;
+ − 67
version = version.substr( ( version.indexOf('MSIE') + 5 ) );
+ − 68
var rawversion = '';
+ − 69
for ( var i = 0; i < version.length; i++ )
+ − 70
{
+ − 71
var chr = version.substr(i, 1);
+ − 72
if ( !chr.match(/[0-9\.]/) )
+ − 73
{
+ − 74
break;
+ − 75
}
+ − 76
rawversion += chr;
+ − 77
}
+ − 78
rawversion = parseInt(rawversion);
+ − 79
if ( rawversion < 6 )
+ − 80
{
+ − 81
KILL_SWITCH = true;
+ − 82
}
+ − 83
}
+ − 84
588
+ − 85
var tinymce_initted = false;
582
+ − 86
+ − 87
if ( typeof(DISABLE_MCE) == undefined )
+ − 88
{
+ − 89
var DISABLE_MCE = false;
+ − 90
}
+ − 91
+ − 92
is_Safari = checkIt('safari') ? true : false;
+ − 93
+ − 94
var cmt_open;
+ − 95
var editor_open = false;
+ − 96
var list;
+ − 97
var edit_open = false;
+ − 98
var catlist = new Array();
+ − 99
var arrDiff1Buttons = new Array();
+ − 100
var arrDiff2Buttons = new Array();
+ − 101
var arrTimeIdList = new Array();
+ − 102
var list;
+ − 103
var unObj;
+ − 104
var unSelectMenuOn = false;
+ − 105
var unObjDivCurrentId = false;
+ − 106
var unObjCurrentSelection = false;
+ − 107
var userlist = new Array();
+ − 108
var submitAuthorized = true;
+ − 109
var timelist = [];
+ − 110
var rDnsObj;
+ − 111
var rDnsBannerObj;
+ − 112
var ns4 = document.layers;
+ − 113
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1);
+ − 114
var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1);
+ − 115
var agt=navigator.userAgent.toLowerCase();
+ − 116
var mac = (agt.indexOf("mac")!=-1);
+ − 117
var ie = (agt.indexOf("msie") != -1);
+ − 118
var mac_ie = mac && ie;
+ − 119
var mouseX = 0;
+ − 120
var mouseY = 0;
+ − 121
var menuheight;
+ − 122
var inertiabase = 1;
+ − 123
var inertiainc = 1;
+ − 124
var slideintervalinc = 20;
+ − 125
var inertiabaseoriginal = inertiabase;
+ − 126
var heightnow;
+ − 127
var targetheight;
+ − 128
var block;
+ − 129
var slideinterval;
+ − 130
var divheights = new Array();
+ − 131
var __menutimeout = false;
+ − 132
var startmouseX = false;
+ − 133
var startmouseY = false;
+ − 134
var startScroll = false;
+ − 135
var is_dragging = false;
+ − 136
var current_ta = false;
+ − 137
var startwidth = false;
+ − 138
var startheight = false;
+ − 139
var do_width = false;
+ − 140
var ajax_load_icon = scriptPath + '/images/loading.gif';
+ − 141
var editor_use_modal_window = false;
+ − 142
var Spry = {};
+ − 143
+ − 144
// You have an NSIS coder in your midst...
+ − 145
var MB_OK = 1;
+ − 146
var MB_OKCANCEL = 2;
+ − 147
var MB_YESNO = 4;
+ − 148
var MB_YESNOCANCEL = 8;
+ − 149
var MB_ABORTRETRYIGNORE = 16;
+ − 150
var MB_ICONINFORMATION = 32;
+ − 151
var MB_ICONEXCLAMATION = 64;
+ − 152
var MB_ICONSTOP = 128;
+ − 153
var MB_ICONQUESTION = 256;
+ − 154
var MB_ICONLOCK = 512;
+ − 155
+ − 156
// Can be set to true by slow themes (St. Patty)
+ − 157
if ( typeof(pref_disable_js_fx) != 'boolean' )
+ − 158
{
+ − 159
var pref_disable_js_fx = false;
+ − 160
}
+ − 161
var aclDisableTransitionFX = ( is_firefox2 || pref_disable_js_fx ) ? true : false;
+ − 162
+ − 163
// Syntax:
+ − 164
// messagebox(MB_OK|MB_ICONINFORMATION, 'Title', 'Text');
+ − 165
// :-D
+ − 166
+ − 167
var $_REQUEST = new Object();
+ − 168
if ( window.location.hash )
+ − 169
{
+ − 170
var hash = String(window.location.hash);
+ − 171
hash = hash.substr(1);
+ − 172
var reqobj = hash.split(';');
+ − 173
var a, b;
+ − 174
for ( var i = 0; i < reqobj.length; i++ )
+ − 175
{
+ − 176
a = reqobj[i].substr(0, reqobj[i].indexOf(':'));
+ − 177
b = reqobj[i].substr( ( reqobj[i].indexOf(':') + 1 ) );
+ − 178
$_REQUEST[a] = b;
+ − 179
}
+ − 180
}
+ − 181
+ − 182
if ( !onload_hooks )
+ − 183
var onload_hooks = new Array();
+ − 184
+ − 185
function addOnloadHook(func)
+ − 186
{
+ − 187
if ( typeof ( func ) == 'function' )
+ − 188
{
+ − 189
if ( typeof(onload_hooks.push) == 'function' )
+ − 190
{
+ − 191
onload_hooks.push(func);
+ − 192
}
+ − 193
else
+ − 194
{
+ − 195
onload_hooks[onload_hooks.length] = func;
+ − 196
}
+ − 197
}
+ − 198
}
+ − 199
+ − 200
function runOnloadHooks(e)
+ − 201
{
+ − 202
var _errorTrapper = 0;
+ − 203
for ( var _oLc = 0; _oLc < onload_hooks.length; _oLc++ )
+ − 204
{
+ − 205
_errorTrapper++;
+ − 206
if ( _errorTrapper >= 1000 )
+ − 207
break;
+ − 208
var _f = onload_hooks[_oLc];
+ − 209
if ( typeof(_f) == 'function' )
+ − 210
{
+ − 211
_f(e);
+ − 212
}
+ − 213
}
+ − 214
}
+ − 215
+ − 216
var loaded_components = {};
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 217
var _load_component_running = false;
582
+ − 218
function load_component(file)
+ − 219
{
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 220
_load_component_running = true;
585
+ − 221
file = file.replace(/\.js$/, '');
582
+ − 222
585
+ − 223
console.info('Loading component %s via AJAX', file);
582
+ − 224
+ − 225
if ( loaded_components[file] )
+ − 226
{
+ − 227
// already loaded
+ − 228
return true;
+ − 229
}
+ − 230
+ − 231
load_show_win(file);
+ − 232
+ − 233
// get an XHR instance
+ − 234
var ajax = ajaxMakeXHR();
+ − 235
585
+ − 236
file = file + '.js';
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 237
var uri = ( ENANO_JSRES_COMPRESSED ) ? scriptPath + '/includes/clientside/jsres.php?f=' + file : scriptPath + '/includes/clientside/static/' + file;
582
+ − 238
ajax.open('GET', uri, false);
+ − 239
ajax.send(null);
+ − 240
if ( ajax.readyState == 4 && ajax.status == 200 )
+ − 241
{
+ − 242
onload_hooks = new Array();
+ − 243
eval_global(ajax.responseText);
+ − 244
load_hide_win();
+ − 245
runOnloadHooks();
+ − 246
}
+ − 247
+ − 248
loaded_components[file] = true;
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 249
_load_component_running = false;
582
+ − 250
return true;
+ − 251
}
+ − 252
+ − 253
function load_show_win(file)
+ − 254
{
+ − 255
var img = '<img style="margin-right: 5px" src="' + scriptPath + '/images/loading.gif" />';
+ − 256
if ( document.getElementById('_js_load_component') )
+ − 257
{
+ − 258
document.getElementById('_js_load_component').innerHTML = img + msg_loading_component.replace('%component%', file);
+ − 259
return;
+ − 260
}
+ − 261
file = file.replace(/\.js$/, '');
+ − 262
var ld = document.createElement('div');
+ − 263
ld.style.padding = '10px';
+ − 264
ld.style.height = '12px';
+ − 265
ld.style.position = 'fixed';
+ − 266
ld.style.right = '5px';
+ − 267
ld.style.bottom = '0px';
+ − 268
ld.innerHTML = img + msg_loading_component.replace('%component%', file);
+ − 269
ld.id = '_js_load_component';
+ − 270
+ − 271
ld.style.backgroundImage = 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAA1JREFUCNdj+P///xkACcgDypG+nnEAAAAASUVORK5CYII=)';
+ − 272
+ − 273
document.body.appendChild(ld);
+ − 274
}
+ − 275
+ − 276
function load_hide_win()
+ − 277
{
+ − 278
var ld = document.getElementById('_js_load_component');
588
+ − 279
if ( !ld )
+ − 280
return false;
582
+ − 281
ld.parentNode.removeChild(ld);
+ − 282
}
+ − 283
+ − 284
// evaluate a snippet of code in the global context, used for dynamic component loading
+ − 285
// from: http://dean.edwards.name/weblog/2006/11/sandbox/
+ − 286
function eval_global(_jsString)
+ − 287
{
+ − 288
if (typeof _jsString != "string")
+ − 289
{
+ − 290
return false;
+ − 291
}
+ − 292
+ − 293
// Check whether window.eval executes code in the global scope.
+ − 294
window.eval("var __INCLUDE_TEST_1__ = true;");
+ − 295
if (typeof window.__INCLUDE_TEST_1__ != "undefined")
+ − 296
{
+ − 297
delete window.__INCLUDE_TEST_1__;
+ − 298
window.eval(_jsString);
+ − 299
}
+ − 300
else if (typeof window.execScript != "undefined") // IE only
+ − 301
{
+ − 302
window.execScript(_jsString);
+ − 303
}
+ − 304
else
+ − 305
{
+ − 306
// Test effectiveness of creating a new SCRIPT element and adding it to the document.
+ − 307
this._insertScriptTag = function (_jsCode) {
+ − 308
var _script = document.createElement("script");
+ − 309
_script.type = "text/javascript";
+ − 310
_script.defer = false;
+ − 311
_script.text = _jsCode;
+ − 312
var _headNodeSet = document.getElementsByTagName("head");
+ − 313
if (_headNodeSet.length)
+ − 314
{
+ − 315
_script = _headNodeSet.item(0).appendChild(_script);
+ − 316
}
+ − 317
else
+ − 318
{
+ − 319
var _head = document.createElement("head");
+ − 320
_head = document.documentElement.appendChild(_head);
+ − 321
_script = _head.appendChild(_script);
+ − 322
}
+ − 323
return _script;
+ − 324
}
+ − 325
var _testScript = this._insertScriptTag("var __INCLUDE_TEST_2__ = true;");
+ − 326
if (typeof window.__INCLUDE_TEST_2__ == "boolean")
+ − 327
{
+ − 328
_testScript.parentNode.removeChild(_testScript);
+ − 329
this._insertScriptTag(_jsString);
+ − 330
}
+ − 331
else
+ − 332
{
+ − 333
// Check whether window.setTimeout works in real time.
+ − 334
window.setTimeout("var __INCLUDE_TEST_3__ = true;", 0);
+ − 335
if (typeof window.__INCLUDE_TEST_3__ != "undefined")
+ − 336
{
+ − 337
delete window.__INCLUDE_TEST_3__;
+ − 338
window.setTimeout(_jsString, 0);
+ − 339
}
+ − 340
}
+ − 341
}
+ − 342
+ − 343
return true;
+ − 344
}
+ − 345
+ − 346
var head = document.getElementsByTagName('head')[0];
+ − 347
+ − 348
// safari has window.console but not the .debug() method
+ − 349
if ( is_Safari && !window.console.debug )
+ − 350
{
+ − 351
window.console.debug = function() {};
+ − 352
}
+ − 353
+ − 354
// Do not remove the following comments, they are used by jsres.php.
+ − 355
/*!START_INCLUDER*/
+ − 356
+ − 357
// Start loading files
+ − 358
// The string from the [ to the ] needs to be valid JSON, it's parsed by jsres.php.
+ − 359
var thefiles = [
+ − 360
'dynano.js',
+ − 361
'functions.js',
+ − 362
'dropdown.js',
+ − 363
'json.js',
+ − 364
'sliders.js',
588
+ − 365
'tinymce-init.js',
582
+ − 366
'loader.js'
+ − 367
];
+ − 368
+ − 369
for(var f in thefiles)
+ − 370
{
+ − 371
if ( typeof(thefiles[f]) != 'string' )
+ − 372
continue;
+ − 373
var script = document.createElement('script');
+ − 374
script.type="text/javascript";
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 375
if ( thefiles[f] == 'json.js' && KILL_SWITCH )
582
+ − 376
{
+ − 377
// alert('kill switch and problem script');
+ − 378
continue;
+ − 379
}
+ − 380
script.src=scriptPath+"/includes/clientside/static/"+thefiles[f];
+ − 381
head.appendChild(script);
+ − 382
}
+ − 383
+ − 384
// Do not remove the following comment, it is used by jsres.php.
+ − 385
/*!END_INCLUDER*/
+ − 386
+ − 387
addOnloadHook(function() {
+ − 388
if ( $_REQUEST['do'] )
+ − 389
{
+ − 390
var act = $_REQUEST['do'];
+ − 391
switch(act)
+ − 392
{
+ − 393
case 'comments':
+ − 394
ajaxComments();
+ − 395
break;
+ − 396
case 'edit':
+ − 397
ajaxEditor();
+ − 398
break;
+ − 399
case 'login':
+ − 400
ajaxStartLogin();
+ − 401
break;
+ − 402
case 'history':
+ − 403
ajaxHistory();
+ − 404
break;
+ − 405
case 'catedit':
+ − 406
ajaxCatEdit();
+ − 407
break;
+ − 408
case 'rename':
+ − 409
ajaxRename();
+ − 410
break;
+ − 411
}
+ − 412
}
+ − 413
});
+ − 414
+ − 415
function Placeholder(funcname, filename)
+ − 416
{
+ − 417
this.filename = filename;
+ − 418
this.funcname = funcname;
+ − 419
this.go = function()
+ − 420
{
+ − 421
window[funcname] = null;
+ − 422
load_component(filename);
+ − 423
var arglist = [];
+ − 424
for ( var i = 0; i < arguments.length; i++ )
+ − 425
{
+ − 426
arglist[arglist.length] = 'arguments['+i+']';
+ − 427
}
+ − 428
arglist = implode(', ', arglist);
585
+ − 429
return eval(funcname + '(' + arglist + ');');
582
+ − 430
}
+ − 431
}
+ − 432
+ − 433
// list of public functions that need placeholders that fetch the component
+ − 434
var placeholder_list = {
+ − 435
ajaxReset: 'ajax.js',
+ − 436
ajaxComments: 'comments.js',
+ − 437
ajaxEditor: 'editor.js',
+ − 438
ajaxHistory: 'ajax.js',
+ − 439
ajaxRename: 'ajax.js',
+ − 440
ajaxDelVote: 'ajax.js',
+ − 441
ajaxProtect: 'ajax.js',
+ − 442
ajaxClearLogs: 'ajax.js',
+ − 443
ajaxResetDelVotes: 'ajax.js',
+ − 444
ajaxDeletePage: 'ajax.js',
+ − 445
ajaxSetPassword: 'ajax.js',
+ − 446
ajaxChangeStyle: 'ajax.js',
+ − 447
ajaxOpenACLManager: 'acl.js',
+ − 448
ajaxAdminPage: 'login.js',
+ − 449
ajaxInitLogout: 'login.js',
+ − 450
ajaxStartLogin: 'login.js',
+ − 451
ajaxStartAdminLogin: 'login.js',
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 452
ajaxLoginNavTo: 'login.js',
591
2529833a7731
Made $session->private_key protected and added pk_{en,de}crypt methods for encrypting and decrypting data using the private key
Dan
diff
changeset
+ − 453
ajaxLogonToElev: 'login.js',
582
+ − 454
ajaxAdminPage: 'login.js',
+ − 455
mb_logout: 'login.js',
+ − 456
selectButtonMajor: 'toolbar.js',
+ − 457
selectButtonMinor: 'toolbar.js',
+ − 458
unselectAllButtonsMajor: 'toolbar.js',
+ − 459
unselectAllButtonsMinor: 'toolbar.js',
+ − 460
darken: 'fadefilter.js',
+ − 461
enlighten: 'fadefilter.js',
585
+ − 462
autofill_onload: 'autofill.js',
586
234ddd896555
Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
diff
changeset
+ − 463
password_score: 'pwstrength.js',
590
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 464
password_score_field: 'pwstrength.js',
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 465
ajaxEditTheme: 'theme-manager.js',
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 466
ajaxToggleSystemThemes: 'theme-manager.js',
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 467
ajaxInstallTheme: 'theme-manager.js',
628
+ − 468
ajaxInitRankEdit: 'rank-manager.js',
+ − 469
ajaxInitRankCreate: 'rank-manager.js'
589
+ − 470
};
582
+ − 471
+ − 472
var placeholder_instances = {};
+ − 473
+ − 474
for ( var i in placeholder_list )
+ − 475
{
+ − 476
var file = placeholder_list[i];
+ − 477
placeholder_instances[i] = new Placeholder(i, file);
+ − 478
window[i] = placeholder_instances[i].go;
+ − 479
}
+ − 480
583
+ − 481
$lang = {
+ − 482
get: function(a, b)
+ − 483
{
+ − 484
load_component('l10n');
+ − 485
return $lang.get(a, b);
+ − 486
}
+ − 487
}
+ − 488
582
+ − 489
//*/