author | Dan |
Tue, 26 Jun 2007 20:48:44 -0400 | |
changeset 22 | d0314575e2f0 |
parent 21 | 663fcf528726 |
child 40 | 723bb7acf914 |
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 |
// dummy tinyMCE object |
|
29 |
var tinyMCE = new Object(); |
|
30 |
||
31 |
// Detect whether the user is running the Evil One or not... |
|
32 |
||
33 |
function checkIt(string) { |
|
34 |
place = detect.indexOf(string) + 1; |
|
35 |
thestring = string; |
|
36 |
return place; |
|
37 |
} |
|
38 |
if (checkIt('msie')) IE = true; |
|
39 |
else IE = false; |
|
40 |
||
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
|
41 |
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
|
42 |
|
1 | 43 |
var cmt_open; |
44 |
var list; |
|
45 |
var edit_open = false; |
|
46 |
var catlist = new Array(); |
|
47 |
var arrDiff1Buttons = new Array(); |
|
48 |
var arrDiff2Buttons = new Array(); |
|
49 |
var arrTimeIdList = new Array(); |
|
50 |
var list; |
|
51 |
var unObj; |
|
52 |
var unSelectMenuOn = false; |
|
53 |
var unObjDivCurrentId = false; |
|
54 |
var unObjCurrentSelection = false; |
|
55 |
var userlist = new Array(); |
|
56 |
var submitAuthorized = true; |
|
57 |
var rDnsObj; |
|
58 |
var rDnsBannerObj; |
|
59 |
var ns4 = document.layers; |
|
60 |
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1); |
|
61 |
var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1); |
|
62 |
var agt=navigator.userAgent.toLowerCase(); |
|
63 |
var mac = (agt.indexOf("mac")!=-1); |
|
64 |
var ie = (agt.indexOf("msie") != -1); |
|
65 |
var mac_ie = mac && ie; |
|
66 |
var mouseX = 0; |
|
67 |
var mouseY = 0; |
|
68 |
var menuheight; |
|
69 |
var inertiabase = 1; |
|
70 |
var inertiainc = 1; |
|
71 |
var slideintervalinc = 20; |
|
72 |
var inertiabaseoriginal = inertiabase; |
|
73 |
var heightnow; |
|
74 |
var targetheight; |
|
75 |
var block; |
|
76 |
var slideinterval; |
|
77 |
var divheights = new Array(); |
|
78 |
var __menutimeout = false; |
|
79 |
var startmouseX = false; |
|
80 |
var startmouseY = false; |
|
81 |
var startScroll = false; |
|
82 |
var is_dragging = false; |
|
83 |
var current_ta = false; |
|
84 |
var startwidth = false; |
|
85 |
var startheight = false; |
|
86 |
var do_width = false; |
|
87 |
||
88 |
// You have an NSIS coder in your midst... |
|
89 |
var MB_OK = 1; |
|
90 |
var MB_OKCANCEL = 2; |
|
91 |
var MB_YESNO = 4; |
|
92 |
var MB_YESNOCANCEL = 8; |
|
93 |
var MB_ABORTRETRYIGNORE = 16; |
|
94 |
var MB_ICONINFORMATION = 32; |
|
95 |
var MB_ICONEXCLAMATION = 64; |
|
96 |
var MB_ICONSTOP = 128; |
|
97 |
var MB_ICONQUESTION = 256; |
|
98 |
var MB_ICONLOCK = 512; |
|
99 |
||
100 |
// Syntax: |
|
101 |
// messagebox(MB_OK|MB_ICONINFORMATION, 'Title', 'Text'); |
|
102 |
// :-D |
|
103 |
||
104 |
var main_css = document.getElementById('mdgCss').href; |
|
105 |
if(main_css.indexOf('?') > -1) { |
|
106 |
sep = '&'; |
|
107 |
} else sep = '?'; |
|
108 |
var _css = false; |
|
109 |
var print_css = main_css + sep + 'printable'; |
|
110 |
||
111 |
var shift; |
|
112 |
||
113 |
function makeUrl(page, query, html_friendly) |
|
114 |
{ |
|
115 |
url = contentPath+page; |
|
116 |
if(url.indexOf('?') > 0) sep = '&'; |
|
117 |
else sep = '?'; |
|
118 |
if(query) |
|
119 |
{ |
|
120 |
url = url + sep + query; |
|
121 |
} |
|
122 |
if(html_friendly) |
|
123 |
{ |
|
124 |
url = url.replace('&', '&'); |
|
125 |
url = url.replace('<', '<'); |
|
126 |
url = url.replace('>', '>'); |
|
127 |
} |
|
128 |
return url; |
|
129 |
} |
|
130 |
||
131 |
function makeUrlNS(namespace, page, query, html_friendly) |
|
132 |
{ |
|
133 |
var url = contentPath+namespace_list[namespace]+(page.replace(/ /g, '_')); |
|
134 |
if(url.indexOf('?') > 0) sep = '&'; |
|
135 |
else sep = '?'; |
|
136 |
if(query) |
|
137 |
{ |
|
138 |
url = url + sep + query; |
|
139 |
} |
|
140 |
if(html_friendly) |
|
141 |
{ |
|
142 |
url = url.replace('&', '&'); |
|
143 |
url = url.replace('<', '<'); |
|
144 |
url = url.replace('>', '>'); |
|
145 |
} |
|
146 |
return append_sid(url); |
|
147 |
} |
|
148 |
||
149 |
function strToPageID(string) |
|
150 |
{ |
|
151 |
// Convert Special:UploadFile to ['UploadFile', 'Special'], but convert 'Image:Enano.png' to ['Enano.png', 'File'] |
|
152 |
for(var i in namespace_list) |
|
153 |
if(namespace_list[i] != '') |
|
154 |
if(namespace_list[i] == string.substr(0, namespace_list[i].length)) |
|
155 |
return [string.substr(namespace_list[i].length), i]; |
|
156 |
return [string, 'Article']; |
|
157 |
} |
|
158 |
||
159 |
function append_sid(url) |
|
160 |
{ |
|
161 |
sep = ( url.indexOf('?') > 0 ) ? '&' : '?'; |
|
162 |
if(ENANO_SID.length > 10) |
|
163 |
{ |
|
164 |
url = url + sep + 'auth=' + ENANO_SID; |
|
165 |
sep = '&'; |
|
166 |
} |
|
167 |
if ( pagepass.length > 0 ) |
|
168 |
{ |
|
169 |
url = url + sep + 'pagepass=' + pagepass; |
|
170 |
} |
|
171 |
return url; |
|
172 |
} |
|
173 |
||
174 |
var stdAjaxPrefix = append_sid(scriptPath+'/ajax.php?title='+title); |
|
175 |
||
176 |
// Code for parsing JSON strings - full source code in json.js |
|
177 |
if(!Object.prototype.toJSONString){Array.prototype.toJSONString=function(){var a=['['],b,i,l=this.length,v;function p(s){if(b){a.push(',');} |
|
178 |
a.push(s);b=true;} |
|
179 |
for(i=0;i<l;i+=1){v=this[i];switch(typeof v){case'undefined':case'function':case'unknown':break;case'object':if(v){if(typeof v.toJSONString==='function'){p(v.toJSONString());}}else{p("null");} |
|
180 |
break;default:p(v.toJSONString());}} |
|
181 |
a.push(']');return a.join('');};Boolean.prototype.toJSONString=function(){return String(this);};Date.prototype.toJSONString=function(){function f(n){return n<10?'0'+n:n;} |
|
182 |
return'"'+this.getFullYear()+'-'+ |
|
183 |
f(this.getMonth()+1)+'-'+ |
|
184 |
f(this.getDate())+'T'+ |
|
185 |
f(this.getHours())+':'+ |
|
186 |
f(this.getMinutes())+':'+ |
|
187 |
f(this.getSeconds())+'"';};Number.prototype.toJSONString=function(){return isFinite(this)?String(this):"null";};Object.prototype.toJSONString=function(){var a=['{'],b,i,v;function p(s){if(b){a.push(',');} |
|
188 |
a.push(i.toJSONString(),':',s);b=true;} |
|
189 |
for(i in this){if(this.hasOwnProperty(i)){v=this[i];switch(typeof v){case'undefined':case'function':case'unknown':break;case'object':if(v){if(typeof v.toJSONString==='function'){p(v.toJSONString());}}else{p("null");} |
|
190 |
break;default:p(v.toJSONString());}}} |
|
191 |
a.push('}');return a.join('');};(function(s){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};s.parseJSON=function(filter){try{if(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(this)){var j=eval('('+this+')');if(typeof filter==='function'){function walk(k,v){if(v&&typeof v==='object'){for(var i in v){if(v.hasOwnProperty(i)){v[i]=walk(i,v[i]);}}} |
|
192 |
return filter(k,v);} |
|
193 |
return walk('',j);} |
|
194 |
return j;}}catch(e){} |
|
195 |
throw new SyntaxError("parseJSON");};s.toJSONString=function(){if(/["\\\x00-\x1f]/.test(this)){return'"'+this.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;} |
|
196 |
c=b.charCodeAt();return'\\u00'+ |
|
197 |
Math.floor(c/16).toString(16)+ |
|
198 |
(c%16).toString(16);})+'"';} |
|
199 |
return'"'+this+'"';};})(String.prototype);} |
|
200 |
||
201 |
function disableJSONExts() |
|
202 |
{ |
|
203 |
delete(Object.prototype.toJSONString); |
|
204 |
delete(Array.prototype.toJSONString); |
|
205 |
delete(Boolean.prototype.toJSONString); |
|
206 |
delete(Date.prototype.toJSONString); |
|
207 |
delete(Number.prototype.toJSONString); |
|
208 |
delete(String.prototype.toJSONString); |
|
209 |
} |
|
210 |
||
211 |
// JSON extensions are deprecated now - use the toJSONString **function** |
|
212 |
disableJSONExts(); |
|
213 |
||
214 |
var $_REQUEST = new Object(); |
|
215 |
if ( window.location.hash ) |
|
216 |
{ |
|
217 |
var hash = String(window.location.hash); |
|
218 |
hash = hash.substr(1); |
|
219 |
var reqobj = hash.split(';'); |
|
220 |
var a, b; |
|
221 |
for ( var i = 0; i < reqobj.length; i++ ) |
|
222 |
{ |
|
223 |
a = reqobj[i].substr(0, reqobj[i].indexOf(':')); |
|
224 |
b = reqobj[i].substr( ( reqobj[i].indexOf(':') + 1 ) ); |
|
225 |
$_REQUEST[a] = b; |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
var head = document.getElementsByTagName('head')[0]; |
|
230 |
var script = document.createElement('script'); |
|
231 |
script.type="text/javascript"; |
|
232 |
script.src=scriptPath+"/includes/clientside/tinymce/tiny_mce_src.js"; |
|
233 |
head.appendChild(script); |
|
234 |
||
235 |
// Start loading files |
|
236 |
var thefiles = [ |
|
237 |
'misc.js', |
|
238 |
'admin-menu.js', |
|
239 |
'ajax.js', |
|
240 |
'autocomplete.js', |
|
241 |
'base64.js', |
|
242 |
'dropdown.js', |
|
243 |
'faders.js', |
|
244 |
'fat.js', |
|
245 |
'grippy.js', |
|
246 |
'json.js', |
|
247 |
'md5.js', |
|
248 |
'sliders.js', |
|
249 |
'toolbar.js', |
|
250 |
'windows.js', |
|
251 |
'rijndael.js', |
|
252 |
'template-compiler.js', |
|
253 |
'acl.js', |
|
254 |
'comments.js', |
|
255 |
'editor.js', |
|
256 |
'dynano.js', |
|
257 |
'flyin.js', |
|
258 |
'loader.js' |
|
259 |
]; |
|
260 |
||
261 |
var problem_scripts = { |
|
262 |
'faders.js' : true, |
|
263 |
'acl.js' : true, |
|
264 |
'admin-menu.js' : true, |
|
265 |
'loader.js' : true |
|
266 |
}; |
|
267 |
||
268 |
for(var f in thefiles) |
|
269 |
{ |
|
270 |
if ( typeof(thefiles[f]) != 'string' ) |
|
271 |
continue; |
|
272 |
var script = document.createElement('script'); |
|
273 |
script.type="text/javascript"; |
|
274 |
//if ( problem_scripts[thefiles[f]] ) |
|
275 |
script.src=scriptPath+"/includes/clientside/static/"+thefiles[f]; |
|
276 |
//else |
|
277 |
// script.src=scriptPath+"/includes/clientside/jsres.php?file="+thefiles[f]; |
|
278 |
head.appendChild(script); |
|
279 |
} |
|
280 |
||
281 |
var onload_hooks = new Array(); |
|
282 |
||
283 |
function addOnloadHook(func) |
|
284 |
{ |
|
285 |
if ( typeof ( func ) == 'function' ) |
|
286 |
onload_hooks[onload_hooks.length] = func; |
|
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 |
//*/ |