1
+ − 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
*
86
c162ca39db8f
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
diff
changeset
+ − 12
* For more information about Enano, please visit http://enanocms.org/.
1
+ − 13
* All of the code in these script files may be used freely so long as the above license block is displayed and your
+ − 14
* modified code is distributed under the GPL. See the page Special:About_Enano on this website for more information.
+ − 15
*/
+ − 16
+ − 17
if(typeof title != 'string')
+ − 18
{
+ − 19
alert('Uh-oh! The required dynamic (PHP-generated) Javascript variables don\'t seem to be available. Javascript is going to be seriously broken.');
+ − 20
}
+ − 21
+ − 22
// Run-time variables
+ − 23
+ − 24
var detect = navigator.userAgent.toLowerCase();
+ − 25
var IE;
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
diff
changeset
+ − 26
var is_Safari;
1
+ − 27
+ − 28
// Detect whether the user is running the Evil One or not...
+ − 29
+ − 30
function checkIt(string) {
+ − 31
place = detect.indexOf(string) + 1;
+ − 32
thestring = string;
+ − 33
return place;
+ − 34
}
+ − 35
if (checkIt('msie')) IE = true;
+ − 36
else IE = false;
+ − 37
117
+ − 38
var is_Opera = ( checkIt('opera') ) ? true : false;
+ − 39
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 40
var KILL_SWITCH = false;
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 41
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 42
if ( IE )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 43
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 44
var version = window.navigator.appVersion;
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 45
version = version.substr( ( version.indexOf('MSIE') + 5 ) );
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 46
var rawversion = '';
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 47
for ( var i = 0; i < version.length; i++ )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 48
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 49
var chr = version.substr(i, 1);
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 50
if ( !chr.match(/[0-9\.]/) )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 51
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 52
break;
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 53
}
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 54
rawversion += chr;
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 55
}
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 56
rawversion = parseInt(rawversion);
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 57
if ( rawversion < 6 )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 58
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 59
KILL_SWITCH = true;
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 60
}
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 61
}
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 62
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 63
// dummy tinyMCE object
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 64
var tinyMCE = new Object();
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 65
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
diff
changeset
+ − 66
if ( typeof(DISABLE_MCE) == undefined )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
diff
changeset
+ − 67
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
diff
changeset
+ − 68
var DISABLE_MCE = false;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
diff
changeset
+ − 69
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
diff
changeset
+ − 70
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 71
// Obsolete JSON kill switch
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 72
function disableJSONExts() { };
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 73
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
diff
changeset
+ − 74
is_Safari = checkIt('safari') ? true : false;
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
diff
changeset
+ − 75
1
+ − 76
var cmt_open;
+ − 77
var list;
+ − 78
var edit_open = false;
+ − 79
var catlist = new Array();
+ − 80
var arrDiff1Buttons = new Array();
+ − 81
var arrDiff2Buttons = new Array();
+ − 82
var arrTimeIdList = new Array();
+ − 83
var list;
+ − 84
var unObj;
+ − 85
var unSelectMenuOn = false;
+ − 86
var unObjDivCurrentId = false;
+ − 87
var unObjCurrentSelection = false;
+ − 88
var userlist = new Array();
+ − 89
var submitAuthorized = true;
+ − 90
var rDnsObj;
+ − 91
var rDnsBannerObj;
+ − 92
var ns4 = document.layers;
+ − 93
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1);
+ − 94
var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1);
+ − 95
var agt=navigator.userAgent.toLowerCase();
+ − 96
var mac = (agt.indexOf("mac")!=-1);
+ − 97
var ie = (agt.indexOf("msie") != -1);
+ − 98
var mac_ie = mac && ie;
+ − 99
var mouseX = 0;
+ − 100
var mouseY = 0;
+ − 101
var menuheight;
+ − 102
var inertiabase = 1;
+ − 103
var inertiainc = 1;
+ − 104
var slideintervalinc = 20;
+ − 105
var inertiabaseoriginal = inertiabase;
+ − 106
var heightnow;
+ − 107
var targetheight;
+ − 108
var block;
+ − 109
var slideinterval;
+ − 110
var divheights = new Array();
+ − 111
var __menutimeout = false;
+ − 112
var startmouseX = false;
+ − 113
var startmouseY = false;
+ − 114
var startScroll = false;
+ − 115
var is_dragging = false;
+ − 116
var current_ta = false;
+ − 117
var startwidth = false;
+ − 118
var startheight = false;
+ − 119
var do_width = false;
200
63fddf1335d9
Nothing real special. The AJAX loading icon can be changed using the Javascript variable ajax_load_icon in header.tpl.
Dan
diff
changeset
+ − 120
var ajax_load_icon = scriptPath + '/images/loading.gif';
1
+ − 121
+ − 122
// You have an NSIS coder in your midst...
+ − 123
var MB_OK = 1;
+ − 124
var MB_OKCANCEL = 2;
+ − 125
var MB_YESNO = 4;
+ − 126
var MB_YESNOCANCEL = 8;
+ − 127
var MB_ABORTRETRYIGNORE = 16;
+ − 128
var MB_ICONINFORMATION = 32;
+ − 129
var MB_ICONEXCLAMATION = 64;
+ − 130
var MB_ICONSTOP = 128;
+ − 131
var MB_ICONQUESTION = 256;
+ − 132
var MB_ICONLOCK = 512;
+ − 133
+ − 134
// Syntax:
+ − 135
// messagebox(MB_OK|MB_ICONINFORMATION, 'Title', 'Text');
+ − 136
// :-D
+ − 137
+ − 138
var main_css = document.getElementById('mdgCss').href;
+ − 139
if(main_css.indexOf('?') > -1) {
+ − 140
sep = '&';
+ − 141
} else sep = '?';
+ − 142
var _css = false;
+ − 143
var print_css = main_css + sep + 'printable';
+ − 144
+ − 145
var shift;
+ − 146
+ − 147
function makeUrl(page, query, html_friendly)
+ − 148
{
+ − 149
url = contentPath+page;
+ − 150
if(url.indexOf('?') > 0) sep = '&';
+ − 151
else sep = '?';
+ − 152
if(query)
+ − 153
{
+ − 154
url = url + sep + query;
+ − 155
}
+ − 156
if(html_friendly)
+ − 157
{
+ − 158
url = url.replace('&', '&');
+ − 159
url = url.replace('<', '<');
+ − 160
url = url.replace('>', '>');
+ − 161
}
+ − 162
return url;
+ − 163
}
+ − 164
+ − 165
function makeUrlNS(namespace, page, query, html_friendly)
+ − 166
{
+ − 167
var url = contentPath+namespace_list[namespace]+(page.replace(/ /g, '_'));
+ − 168
if(url.indexOf('?') > 0) sep = '&';
+ − 169
else sep = '?';
+ − 170
if(query)
+ − 171
{
+ − 172
url = url + sep + query;
+ − 173
}
+ − 174
if(html_friendly)
+ − 175
{
+ − 176
url = url.replace('&', '&');
+ − 177
url = url.replace('<', '<');
+ − 178
url = url.replace('>', '>');
+ − 179
}
+ − 180
return append_sid(url);
+ − 181
}
+ − 182
+ − 183
function strToPageID(string)
+ − 184
{
+ − 185
// Convert Special:UploadFile to ['UploadFile', 'Special'], but convert 'Image:Enano.png' to ['Enano.png', 'File']
+ − 186
for(var i in namespace_list)
+ − 187
if(namespace_list[i] != '')
+ − 188
if(namespace_list[i] == string.substr(0, namespace_list[i].length))
+ − 189
return [string.substr(namespace_list[i].length), i];
+ − 190
return [string, 'Article'];
+ − 191
}
+ − 192
+ − 193
function append_sid(url)
+ − 194
{
+ − 195
sep = ( url.indexOf('?') > 0 ) ? '&' : '?';
+ − 196
if(ENANO_SID.length > 10)
+ − 197
{
+ − 198
url = url + sep + 'auth=' + ENANO_SID;
+ − 199
sep = '&';
+ − 200
}
+ − 201
if ( pagepass.length > 0 )
+ − 202
{
+ − 203
url = url + sep + 'pagepass=' + pagepass;
+ − 204
}
+ − 205
return url;
+ − 206
}
+ − 207
+ − 208
var stdAjaxPrefix = append_sid(scriptPath+'/ajax.php?title='+title);
+ − 209
+ − 210
var $_REQUEST = new Object();
+ − 211
if ( window.location.hash )
+ − 212
{
+ − 213
var hash = String(window.location.hash);
+ − 214
hash = hash.substr(1);
+ − 215
var reqobj = hash.split(';');
+ − 216
var a, b;
+ − 217
for ( var i = 0; i < reqobj.length; i++ )
+ − 218
{
+ − 219
a = reqobj[i].substr(0, reqobj[i].indexOf(':'));
+ − 220
b = reqobj[i].substr( ( reqobj[i].indexOf(':') + 1 ) );
+ − 221
$_REQUEST[a] = b;
+ − 222
}
+ − 223
}
+ − 224
117
+ − 225
var onload_hooks = new Array();
+ − 226
+ − 227
function addOnloadHook(func)
+ − 228
{
+ − 229
if ( typeof ( func ) == 'function' )
+ − 230
{
+ − 231
if ( typeof(onload_hooks.push) == 'function' )
+ − 232
{
+ − 233
onload_hooks.push(func);
+ − 234
}
+ − 235
else
+ − 236
{
+ − 237
onload_hooks[onload_hooks.length] = func;
+ − 238
}
+ − 239
}
+ − 240
}
+ − 241
+ − 242
function runOnloadHooks(e)
+ − 243
{
+ − 244
var _errorTrapper = 0;
+ − 245
for ( var _oLc = 0; _oLc < onload_hooks.length; _oLc++ )
+ − 246
{
+ − 247
_errorTrapper++;
+ − 248
if ( _errorTrapper >= 1000 )
+ − 249
break;
+ − 250
var _f = onload_hooks[_oLc];
+ − 251
if ( typeof(_f) == 'function' )
+ − 252
{
+ − 253
_f(e);
+ − 254
}
+ − 255
}
+ − 256
}
+ − 257
1
+ − 258
var head = document.getElementsByTagName('head')[0];
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
diff
changeset
+ − 259
if ( !KILL_SWITCH && !DISABLE_MCE )
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 260
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 261
var script = document.createElement('script');
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 262
script.type="text/javascript";
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 263
script.src=scriptPath+"/includes/clientside/tinymce/tiny_mce.js";
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 264
head.appendChild(script);
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 265
}
1
+ − 266
+ − 267
// Start loading files
+ − 268
var thefiles = [
+ − 269
'misc.js',
+ − 270
'admin-menu.js',
+ − 271
'ajax.js',
+ − 272
'autocomplete.js',
184
+ − 273
'autofill.js',
1
+ − 274
'base64.js',
+ − 275
'dropdown.js',
+ − 276
'faders.js',
+ − 277
'fat.js',
+ − 278
'grippy.js',
+ − 279
'json.js',
+ − 280
'md5.js',
+ − 281
'sliders.js',
+ − 282
'toolbar.js',
+ − 283
'windows.js',
+ − 284
'rijndael.js',
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
diff
changeset
+ − 285
'l10n.js',
1
+ − 286
'template-compiler.js',
+ − 287
'acl.js',
+ − 288
'comments.js',
+ − 289
'editor.js',
+ − 290
'dynano.js',
+ − 291
'flyin.js',
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 292
'paginate.js',
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
diff
changeset
+ − 293
'pwstrength.js',
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 294
'SpryEffects.js',
1
+ − 295
'loader.js'
+ − 296
];
+ − 297
+ − 298
var problem_scripts = {
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 299
'json.js' : true,
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 300
'template-compiler.js' : true
1
+ − 301
};
+ − 302
+ − 303
for(var f in thefiles)
+ − 304
{
+ − 305
if ( typeof(thefiles[f]) != 'string' )
+ − 306
continue;
+ − 307
var script = document.createElement('script');
+ − 308
script.type="text/javascript";
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 309
if ( problem_scripts[thefiles[f]] && KILL_SWITCH )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 310
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 311
// alert('kill switch and problem script');
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 312
continue;
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 313
}
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 314
script.src=scriptPath+"/includes/clientside/static/"+thefiles[f];
1
+ − 315
head.appendChild(script);
+ − 316
}
+ − 317
+ − 318
addOnloadHook(function() {
+ − 319
if ( $_REQUEST['do'] )
+ − 320
{
+ − 321
var act = $_REQUEST['do'];
+ − 322
switch(act)
+ − 323
{
+ − 324
case 'comments':
+ − 325
ajaxComments();
+ − 326
break;
+ − 327
case 'edit':
+ − 328
ajaxEditor();
+ − 329
break;
+ − 330
case 'login':
+ − 331
ajaxStartLogin();
+ − 332
break;
+ − 333
case 'history':
+ − 334
ajaxHistory();
+ − 335
break;
+ − 336
case 'catedit':
+ − 337
ajaxCatEdit();
+ − 338
break;
+ − 339
}
+ − 340
}
+ − 341
});
+ − 342
+ − 343
+ − 344
//*/