author | Dan |
Wed, 25 Jul 2007 18:06:34 -0400 | |
changeset 74 | 68469a95658d |
parent 59 | 7c4a851fb5c5 |
child 85 | 7c68a18a27be |
permissions | -rw-r--r-- |
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 |
* |
|
12 |
* For more information about Enano, please visit http://www.enanocms.org/. |
|
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
parents:
1
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 |
||
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
parents:
40
diff
changeset
|
38 |
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
parents:
40
diff
changeset
|
39 |
|
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
parents:
40
diff
changeset
|
40 |
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
parents:
40
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
parents:
40
diff
changeset
|
42 |
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
parents:
40
diff
changeset
|
43 |
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
parents:
40
diff
changeset
|
44 |
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
parents:
40
diff
changeset
|
45 |
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
parents:
40
diff
changeset
|
46 |
{ |
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
parents:
40
diff
changeset
|
47 |
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
parents:
40
diff
changeset
|
48 |
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
parents:
40
diff
changeset
|
49 |
{ |
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
parents:
40
diff
changeset
|
50 |
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
parents:
40
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
parents:
40
diff
changeset
|
52 |
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
parents:
40
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
parents:
40
diff
changeset
|
54 |
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
parents:
40
diff
changeset
|
55 |
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
parents:
40
diff
changeset
|
56 |
{ |
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
parents:
40
diff
changeset
|
57 |
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
parents:
40
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
parents:
40
diff
changeset
|
59 |
} |
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
parents:
40
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
parents:
40
diff
changeset
|
61 |
// 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
parents:
40
diff
changeset
|
62 |
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
parents:
40
diff
changeset
|
63 |
|
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
parents:
40
diff
changeset
|
64 |
// 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
parents:
40
diff
changeset
|
65 |
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
parents:
40
diff
changeset
|
66 |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
67 |
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
parents:
1
diff
changeset
|
68 |
|
1 | 69 |
var cmt_open; |
70 |
var list; |
|
71 |
var edit_open = false; |
|
72 |
var catlist = new Array(); |
|
73 |
var arrDiff1Buttons = new Array(); |
|
74 |
var arrDiff2Buttons = new Array(); |
|
75 |
var arrTimeIdList = new Array(); |
|
76 |
var list; |
|
77 |
var unObj; |
|
78 |
var unSelectMenuOn = false; |
|
79 |
var unObjDivCurrentId = false; |
|
80 |
var unObjCurrentSelection = false; |
|
81 |
var userlist = new Array(); |
|
82 |
var submitAuthorized = true; |
|
83 |
var rDnsObj; |
|
84 |
var rDnsBannerObj; |
|
85 |
var ns4 = document.layers; |
|
86 |
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1); |
|
87 |
var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1); |
|
88 |
var agt=navigator.userAgent.toLowerCase(); |
|
89 |
var mac = (agt.indexOf("mac")!=-1); |
|
90 |
var ie = (agt.indexOf("msie") != -1); |
|
91 |
var mac_ie = mac && ie; |
|
92 |
var mouseX = 0; |
|
93 |
var mouseY = 0; |
|
94 |
var menuheight; |
|
95 |
var inertiabase = 1; |
|
96 |
var inertiainc = 1; |
|
97 |
var slideintervalinc = 20; |
|
98 |
var inertiabaseoriginal = inertiabase; |
|
99 |
var heightnow; |
|
100 |
var targetheight; |
|
101 |
var block; |
|
102 |
var slideinterval; |
|
103 |
var divheights = new Array(); |
|
104 |
var __menutimeout = false; |
|
105 |
var startmouseX = false; |
|
106 |
var startmouseY = false; |
|
107 |
var startScroll = false; |
|
108 |
var is_dragging = false; |
|
109 |
var current_ta = false; |
|
110 |
var startwidth = false; |
|
111 |
var startheight = false; |
|
112 |
var do_width = false; |
|
113 |
||
114 |
// You have an NSIS coder in your midst... |
|
115 |
var MB_OK = 1; |
|
116 |
var MB_OKCANCEL = 2; |
|
117 |
var MB_YESNO = 4; |
|
118 |
var MB_YESNOCANCEL = 8; |
|
119 |
var MB_ABORTRETRYIGNORE = 16; |
|
120 |
var MB_ICONINFORMATION = 32; |
|
121 |
var MB_ICONEXCLAMATION = 64; |
|
122 |
var MB_ICONSTOP = 128; |
|
123 |
var MB_ICONQUESTION = 256; |
|
124 |
var MB_ICONLOCK = 512; |
|
125 |
||
126 |
// Syntax: |
|
127 |
// messagebox(MB_OK|MB_ICONINFORMATION, 'Title', 'Text'); |
|
128 |
// :-D |
|
129 |
||
130 |
var main_css = document.getElementById('mdgCss').href; |
|
131 |
if(main_css.indexOf('?') > -1) { |
|
132 |
sep = '&'; |
|
133 |
} else sep = '?'; |
|
134 |
var _css = false; |
|
135 |
var print_css = main_css + sep + 'printable'; |
|
136 |
||
137 |
var shift; |
|
138 |
||
139 |
function makeUrl(page, query, html_friendly) |
|
140 |
{ |
|
141 |
url = contentPath+page; |
|
142 |
if(url.indexOf('?') > 0) sep = '&'; |
|
143 |
else sep = '?'; |
|
144 |
if(query) |
|
145 |
{ |
|
146 |
url = url + sep + query; |
|
147 |
} |
|
148 |
if(html_friendly) |
|
149 |
{ |
|
150 |
url = url.replace('&', '&'); |
|
151 |
url = url.replace('<', '<'); |
|
152 |
url = url.replace('>', '>'); |
|
153 |
} |
|
154 |
return url; |
|
155 |
} |
|
156 |
||
157 |
function makeUrlNS(namespace, page, query, html_friendly) |
|
158 |
{ |
|
159 |
var url = contentPath+namespace_list[namespace]+(page.replace(/ /g, '_')); |
|
160 |
if(url.indexOf('?') > 0) sep = '&'; |
|
161 |
else sep = '?'; |
|
162 |
if(query) |
|
163 |
{ |
|
164 |
url = url + sep + query; |
|
165 |
} |
|
166 |
if(html_friendly) |
|
167 |
{ |
|
168 |
url = url.replace('&', '&'); |
|
169 |
url = url.replace('<', '<'); |
|
170 |
url = url.replace('>', '>'); |
|
171 |
} |
|
172 |
return append_sid(url); |
|
173 |
} |
|
174 |
||
175 |
function strToPageID(string) |
|
176 |
{ |
|
177 |
// Convert Special:UploadFile to ['UploadFile', 'Special'], but convert 'Image:Enano.png' to ['Enano.png', 'File'] |
|
178 |
for(var i in namespace_list) |
|
179 |
if(namespace_list[i] != '') |
|
180 |
if(namespace_list[i] == string.substr(0, namespace_list[i].length)) |
|
181 |
return [string.substr(namespace_list[i].length), i]; |
|
182 |
return [string, 'Article']; |
|
183 |
} |
|
184 |
||
185 |
function append_sid(url) |
|
186 |
{ |
|
187 |
sep = ( url.indexOf('?') > 0 ) ? '&' : '?'; |
|
188 |
if(ENANO_SID.length > 10) |
|
189 |
{ |
|
190 |
url = url + sep + 'auth=' + ENANO_SID; |
|
191 |
sep = '&'; |
|
192 |
} |
|
193 |
if ( pagepass.length > 0 ) |
|
194 |
{ |
|
195 |
url = url + sep + 'pagepass=' + pagepass; |
|
196 |
} |
|
197 |
return url; |
|
198 |
} |
|
199 |
||
200 |
var stdAjaxPrefix = append_sid(scriptPath+'/ajax.php?title='+title); |
|
201 |
||
202 |
var $_REQUEST = new Object(); |
|
203 |
if ( window.location.hash ) |
|
204 |
{ |
|
205 |
var hash = String(window.location.hash); |
|
206 |
hash = hash.substr(1); |
|
207 |
var reqobj = hash.split(';'); |
|
208 |
var a, b; |
|
209 |
for ( var i = 0; i < reqobj.length; i++ ) |
|
210 |
{ |
|
211 |
a = reqobj[i].substr(0, reqobj[i].indexOf(':')); |
|
212 |
b = reqobj[i].substr( ( reqobj[i].indexOf(':') + 1 ) ); |
|
213 |
$_REQUEST[a] = b; |
|
214 |
} |
|
215 |
} |
|
216 |
||
217 |
var head = document.getElementsByTagName('head')[0]; |
|
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
parents:
40
diff
changeset
|
218 |
if ( !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
parents:
40
diff
changeset
|
219 |
{ |
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
parents:
40
diff
changeset
|
220 |
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
parents:
40
diff
changeset
|
221 |
script.type="text/javascript"; |
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
parents:
40
diff
changeset
|
222 |
script.src=scriptPath+"/includes/clientside/tinymce/tiny_mce_src.js"; |
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
parents:
40
diff
changeset
|
223 |
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
parents:
40
diff
changeset
|
224 |
} |
1 | 225 |
|
226 |
// Start loading files |
|
227 |
var thefiles = [ |
|
228 |
'misc.js', |
|
229 |
'admin-menu.js', |
|
230 |
'ajax.js', |
|
231 |
'autocomplete.js', |
|
232 |
'base64.js', |
|
233 |
'dropdown.js', |
|
234 |
'faders.js', |
|
235 |
'fat.js', |
|
236 |
'grippy.js', |
|
237 |
'json.js', |
|
238 |
'md5.js', |
|
239 |
'sliders.js', |
|
240 |
'toolbar.js', |
|
241 |
'windows.js', |
|
242 |
'rijndael.js', |
|
243 |
'template-compiler.js', |
|
244 |
'acl.js', |
|
245 |
'comments.js', |
|
246 |
'editor.js', |
|
247 |
'dynano.js', |
|
248 |
'flyin.js', |
|
249 |
'loader.js' |
|
250 |
]; |
|
251 |
||
252 |
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
parents:
40
diff
changeset
|
253 |
'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
parents:
40
diff
changeset
|
254 |
'template-compiler.js' : true |
1 | 255 |
}; |
256 |
||
257 |
for(var f in thefiles) |
|
258 |
{ |
|
259 |
if ( typeof(thefiles[f]) != 'string' ) |
|
260 |
continue; |
|
261 |
var script = document.createElement('script'); |
|
262 |
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
parents:
40
diff
changeset
|
263 |
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
parents:
40
diff
changeset
|
264 |
{ |
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
parents:
40
diff
changeset
|
265 |
// 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
parents:
40
diff
changeset
|
266 |
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
parents:
40
diff
changeset
|
267 |
} |
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
parents:
40
diff
changeset
|
268 |
script.src=scriptPath+"/includes/clientside/static/"+thefiles[f]; |
1 | 269 |
head.appendChild(script); |
270 |
} |
|
271 |
||
272 |
var onload_hooks = new Array(); |
|
273 |
||
274 |
function addOnloadHook(func) |
|
275 |
{ |
|
276 |
if ( typeof ( func ) == 'function' ) |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
21
diff
changeset
|
277 |
{ |
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
278 |
if ( typeof(onload_hooks.push) == 'function' ) |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
21
diff
changeset
|
279 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
21
diff
changeset
|
280 |
onload_hooks.push(func); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
21
diff
changeset
|
281 |
} |
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
282 |
else |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
21
diff
changeset
|
283 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
21
diff
changeset
|
284 |
onload_hooks[onload_hooks.length] = func; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
21
diff
changeset
|
285 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
21
diff
changeset
|
286 |
} |
1 | 287 |
} |
288 |
||
289 |
function runOnloadHooks(e) |
|
290 |
{ |
|
291 |
var _errorTrapper = 0; |
|
292 |
for ( var _oLc = 0; _oLc < onload_hooks.length; _oLc++ ) |
|
293 |
{ |
|
294 |
_errorTrapper++; |
|
295 |
if ( _errorTrapper >= 1000 ) |
|
296 |
break; |
|
297 |
var _f = onload_hooks[_oLc]; |
|
298 |
if ( typeof(_f) == 'function' ) |
|
299 |
{ |
|
300 |
_f(e); |
|
301 |
} |
|
302 |
} |
|
303 |
} |
|
304 |
||
305 |
addOnloadHook(function() { |
|
306 |
if ( $_REQUEST['do'] ) |
|
307 |
{ |
|
308 |
var act = $_REQUEST['do']; |
|
309 |
switch(act) |
|
310 |
{ |
|
311 |
case 'comments': |
|
312 |
ajaxComments(); |
|
313 |
break; |
|
314 |
case 'edit': |
|
315 |
ajaxEditor(); |
|
316 |
break; |
|
317 |
case 'login': |
|
318 |
ajaxStartLogin(); |
|
319 |
break; |
|
320 |
case 'history': |
|
321 |
ajaxHistory(); |
|
322 |
break; |
|
323 |
case 'catedit': |
|
324 |
ajaxCatEdit(); |
|
325 |
break; |
|
326 |
} |
|
327 |
} |
|
328 |
}); |
|
329 |
||
330 |
||
331 |
//*/ |