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