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