author | Dan |
Sat, 29 Mar 2008 15:58:59 -0700 | |
changeset 513 | c15fbf197a54 |
parent 504 | bc8e0e9ee01d |
child 520 | 4c16e87cfeae |
permissions | -rw-r--r-- |
1 | 1 |
// Some additional DHTML functions |
2 |
||
3 |
function fetch_offset(obj) { |
|
4 |
var left_offset = obj.offsetLeft; |
|
5 |
var top_offset = obj.offsetTop; |
|
6 |
while ((obj = obj.offsetParent) != null) { |
|
7 |
left_offset += obj.offsetLeft; |
|
8 |
top_offset += obj.offsetTop; |
|
9 |
} |
|
10 |
return { 'left' : left_offset, 'top' : top_offset }; |
|
11 |
} |
|
12 |
||
13 |
function fetch_dimensions(o) { |
|
14 |
var w = o.offsetWidth; |
|
15 |
var h = o.offsetHeight; |
|
16 |
return { 'w' : w, 'h' : h }; |
|
17 |
} |
|
18 |
||
19 |
function findParentForm(o) |
|
20 |
{ |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
21 |
if ( o.tagName == 'FORM' ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
22 |
return o; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
23 |
while(true) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
24 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
25 |
o = o.parentNode; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
26 |
if ( !o ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
27 |
return false; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
28 |
if ( o.tagName == 'FORM' ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
29 |
return o; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
30 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
31 |
return false; |
1 | 32 |
} |
33 |
||
34 |
function ajaxReverseDNS(o, text) |
|
35 |
{ |
|
36 |
if(text) var ipaddr = text; |
|
37 |
else var ipaddr = o.innerHTML; |
|
38 |
rDnsObj = o; |
|
39 |
rDnsBannerObj = bannerOn('Retrieving reverse DNS info...'); |
|
40 |
ajaxGet(stdAjaxPrefix+'&_mode=rdns&ip='+ipaddr, function() { |
|
407
35d94240a197
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents:
372
diff
changeset
|
41 |
if ( ajax.readyState == 4 && ajax.status == 200 ) |
1 | 42 |
{ |
43 |
off = fetch_offset(rDnsObj); |
|
44 |
dim = fetch_dimensions(rDnsObj); |
|
45 |
right = off['left'] + dim['w']; |
|
46 |
top = off['top'] + dim['h']; |
|
47 |
var thediv = document.createElement('div'); |
|
48 |
thediv.className = 'info-box'; |
|
49 |
thediv.style.margin = '0'; |
|
50 |
thediv.style.position = 'absolute'; |
|
51 |
thediv.style.top = top + 'px'; |
|
52 |
thediv.style.display = 'none'; |
|
53 |
thediv.style.zIndex = getHighestZ() + 2; |
|
54 |
thediv.id = 'mdgDynamic_rDnsInfoDiv_'+Math.floor(Math.random() * 1000000); |
|
55 |
thediv.innerHTML = '<b>Reverse DNS:</b><br />'+ajax.responseText+' <a href="#" onclick="elem = document.getElementById(\''+thediv.id+'\'); elem.innerHTML = \'\'; elem.style.display = \'none\';return false;">Close</a>'; |
|
56 |
var body = document.getElementsByTagName('body'); |
|
57 |
body = body[0]; |
|
58 |
bannerOff(rDnsBannerObj); |
|
59 |
body.appendChild(thediv); |
|
60 |
thediv.style.display = 'block'; |
|
61 |
left = fetch_dimensions(thediv); |
|
62 |
thediv.style.display = 'none'; |
|
63 |
left = right - left['w']; |
|
64 |
thediv.style.left = left + 'px'; |
|
65 |
thediv.style.display = 'block'; |
|
66 |
fadeInfoBoxes(); |
|
67 |
} |
|
68 |
}); |
|
69 |
} |
|
70 |
||
71 |
function bannerOn(text) |
|
72 |
{ |
|
73 |
darken(true); |
|
74 |
var thediv = document.createElement('div'); |
|
75 |
thediv.className = 'mdg-comment'; |
|
76 |
thediv.style.padding = '0'; |
|
77 |
thediv.style.marginLeft = '0'; |
|
78 |
thediv.style.position = 'absolute'; |
|
79 |
thediv.style.display = 'none'; |
|
80 |
thediv.style.padding = '4px'; |
|
81 |
thediv.style.fontSize = '14pt'; |
|
82 |
thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000); |
|
83 |
thediv.innerHTML = text; |
|
84 |
||
85 |
var body = document.getElementsByTagName('body'); |
|
86 |
body = body[0]; |
|
87 |
body.appendChild(thediv); |
|
88 |
body.style.cursor = 'wait'; |
|
89 |
||
90 |
thediv.style.display = 'block'; |
|
91 |
dim = fetch_dimensions(thediv); |
|
92 |
thediv.style.display = 'none'; |
|
93 |
bdim = { 'w' : getWidth(), 'h' : getHeight() }; |
|
94 |
so = getScrollOffset(); |
|
95 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
96 |
var left = (bdim['w'] / 2) - ( dim['w'] / 2 ); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
97 |
|
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
98 |
var top = (bdim['h'] / 2); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
99 |
top = top - ( dim['h'] / 2 ); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
100 |
|
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
101 |
top = top + so; |
1 | 102 |
|
103 |
thediv.style.top = top + 'px'; |
|
104 |
thediv.style.left = left + 'px'; |
|
105 |
||
106 |
thediv.style.display = 'block'; |
|
107 |
||
108 |
return thediv.id; |
|
109 |
} |
|
110 |
||
111 |
function bannerOff(id) |
|
112 |
{ |
|
113 |
e = document.getElementById(id); |
|
114 |
if(!e) return; |
|
115 |
e.innerHTML = ''; |
|
116 |
e.style.display = 'none'; |
|
117 |
var body = document.getElementsByTagName('body'); |
|
118 |
body = body[0]; |
|
119 |
body.style.cursor = 'default'; |
|
120 |
enlighten(true); |
|
121 |
} |
|
122 |
||
123 |
function disableUnload(message) |
|
124 |
{ |
|
125 |
if(typeof message != 'string') message = 'You may want to save your changes first.'; |
|
440 | 126 |
window._unloadmsg = message; |
127 |
window.onbeforeunload = function(e) |
|
128 |
{ |
|
129 |
if ( !e ) |
|
130 |
e = window.event; |
|
131 |
e.returnValue = window._unloadmsg; |
|
132 |
} |
|
1 | 133 |
} |
134 |
||
135 |
function enableUnload() |
|
136 |
{ |
|
440 | 137 |
window._unloadmsg = null; |
138 |
window.onbeforeunload = null; |
|
1 | 139 |
} |
140 |
||
141 |
/** |
|
142 |
* Gets the highest z-index of all divs in the document |
|
143 |
* @return integer |
|
144 |
*/ |
|
145 |
function getHighestZ() |
|
146 |
{ |
|
147 |
z = 0; |
|
148 |
var divs = document.getElementsByTagName('div'); |
|
149 |
for(var i = 0; i < divs.length; i++) |
|
150 |
{ |
|
151 |
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex; |
|
152 |
} |
|
153 |
return z; |
|
154 |
} |
|
155 |
||
156 |
function isKeyPressed(event) |
|
157 |
{ |
|
158 |
if (event.shiftKey==1) |
|
159 |
{ |
|
160 |
shift = true; |
|
161 |
} |
|
162 |
else |
|
163 |
{ |
|
164 |
shift = false; |
|
165 |
} |
|
166 |
} |
|
167 |
||
168 |
function moveDiv(div, newparent) |
|
169 |
{ |
|
170 |
var backup = div; |
|
171 |
var oldparent = div.parentNode; |
|
172 |
oldparent.removeChild(div); |
|
173 |
newparent.appendChild(backup); |
|
174 |
} |
|
175 |
||
176 |
function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;} |
|
177 |
function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";} |
|
178 |
function eraseCookie(name) {createCookie(name,"",-1);} |
|
179 |
||
180 |
var busyBannerID; |
|
181 |
function goBusy(msg) |
|
182 |
{ |
|
183 |
if(!msg) msg = 'Please wait...'; |
|
184 |
body = document.getElementsByTagName('body'); |
|
185 |
body = body[0]; |
|
186 |
body.style.cursor = 'wait'; |
|
187 |
busyBannerID = bannerOn(msg); |
|
188 |
} |
|
189 |
||
190 |
function unBusy() |
|
191 |
{ |
|
192 |
body = document.getElementsByTagName('body'); |
|
193 |
body = body[0]; |
|
194 |
body.style.cursor = 'default'; |
|
195 |
bannerOff(busyBannerID); |
|
196 |
} |
|
197 |
||
198 |
function setAjaxLoading() |
|
199 |
{ |
|
200 |
if ( document.getElementById('ajaxloadicon') ) |
|
201 |
{ |
|
200
63fddf1335d9
Nothing real special. The AJAX loading icon can be changed using the Javascript variable ajax_load_icon in header.tpl.
Dan
parents:
176
diff
changeset
|
202 |
document.getElementById('ajaxloadicon').src=ajax_load_icon; |
1 | 203 |
} |
204 |
} |
|
205 |
||
206 |
function unsetAjaxLoading() |
|
207 |
{ |
|
208 |
if ( document.getElementById('ajaxloadicon') ) |
|
209 |
{ |
|
210 |
document.getElementById('ajaxloadicon').src=scriptPath + '/images/spacer.gif'; |
|
211 |
} |
|
212 |
} |
|
213 |
||
214 |
/* |
|
215 |
* Search boxes |
|
216 |
*/ |
|
217 |
||
218 |
function buildSearchBoxes() |
|
219 |
{ |
|
220 |
var divs = document.getElementsByTagName('*'); |
|
221 |
var boxes = new Array(); |
|
222 |
for ( var i = 0; i < divs.length; i++ ) |
|
223 |
{ |
|
224 |
if ( divs[i].className) |
|
225 |
{ |
|
226 |
if ( divs[i].className.substr(0, 9) == 'searchbox' ) |
|
227 |
{ |
|
228 |
boxes.push(divs[i]); |
|
229 |
} |
|
230 |
} |
|
231 |
} |
|
232 |
for ( var i = 0; i < boxes.length; i++ ) |
|
233 |
{ |
|
234 |
if ( boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/) ) |
|
235 |
{ |
|
236 |
var width = boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/); |
|
237 |
width = parseInt(width[1]); |
|
238 |
} |
|
239 |
else |
|
240 |
{ |
|
241 |
var width = 120; |
|
242 |
} |
|
243 |
createSearchBox(boxes[i], width); |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
function createSearchBox(parent, width) |
|
248 |
{ |
|
249 |
if ( typeof(parent) != 'object') |
|
250 |
{ |
|
251 |
alert('BUG: createSearchBox(): parent is not an object'); |
|
252 |
return false; |
|
253 |
} |
|
254 |
//parent.style.padding = '0px'; |
|
255 |
//parent.style.textAlign = 'center'; |
|
256 |
parent.style.width = width + 'px'; |
|
257 |
var submit = document.createElement('div'); |
|
258 |
submit.onclick = function() { searchFormSubmit(this); }; |
|
259 |
submit.className = 'js-search-submit'; |
|
260 |
var input = document.createElement('input'); |
|
261 |
input.className = 'js-search-box'; |
|
262 |
input.value = 'Search'; |
|
263 |
input.name = 'q'; |
|
264 |
input.style.width = ( width - 28 ) + 'px'; |
|
265 |
input.onfocus = function() { if ( this.value == 'Search' ) this.value = ''; }; |
|
266 |
input.onblur = function() { if ( this.value == '' ) this.value = 'Search'; }; |
|
267 |
parent.appendChild(input); |
|
268 |
var off = fetch_offset(input); |
|
269 |
var top = off['top'] + 'px'; |
|
270 |
var left = ( parseInt(off['left']) + ( width - 24 ) ) + 'px'; |
|
271 |
submit.style.top = top; |
|
272 |
submit.style.left = left; |
|
273 |
parent.appendChild(submit); |
|
274 |
} |
|
275 |
||
276 |
function searchFormSubmit(obj) |
|
277 |
{ |
|
278 |
var input = obj.previousSibling; |
|
279 |
if ( input.value == 'Search' || input.value == '' ) |
|
280 |
return false; |
|
281 |
var p = obj; |
|
282 |
while(true) |
|
283 |
{ |
|
284 |
p = p.parentNode; |
|
285 |
if ( !p ) |
|
286 |
break; |
|
287 |
if ( typeof(p.tagName) != 'string' ) |
|
288 |
break; |
|
289 |
else if ( p.tagName.toLowerCase() == 'form' ) |
|
290 |
{ |
|
291 |
p.submit(); |
|
292 |
} |
|
293 |
else if ( p.tagName.toLowerCase() == 'body' ) |
|
294 |
{ |
|
295 |
break; |
|
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
||
300 |
/* |
|
301 |
* AJAX login box (experimental) |
|
436
242353360e37
Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
426
diff
changeset
|
302 |
* Moved / rewritten in login.js |
1 | 303 |
*/ |
304 |
||
436
242353360e37
Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
426
diff
changeset
|
305 |
// Included only for API-compatibility |
1 | 306 |
function ajaxPromptAdminAuth(call_on_ok, level) |
307 |
{ |
|
436
242353360e37
Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
426
diff
changeset
|
308 |
ajaxLogonInit(call_on_ok, level); |
1 | 309 |
} |
310 |
||
311 |
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/ |
|
312 |
function sprintf() |
|
313 |
{ |
|
314 |
if (!arguments || arguments.length < 1 || !RegExp) |
|
315 |
{ |
|
316 |
return; |
|
317 |
} |
|
318 |
var str = arguments[0]; |
|
319 |
var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; |
|
320 |
var a = b = [], numSubstitutions = 0, numMatches = 0; |
|
321 |
while (a = re.exec(str)) |
|
322 |
{ |
|
323 |
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; |
|
324 |
var pPrecision = a[5], pType = a[6], rightPart = a[7]; |
|
325 |
||
326 |
//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision); |
|
327 |
||
328 |
numMatches++; |
|
329 |
if (pType == '%') |
|
330 |
{ |
|
331 |
subst = '%'; |
|
332 |
} |
|
333 |
else |
|
334 |
{ |
|
335 |
numSubstitutions++; |
|
336 |
if (numSubstitutions >= arguments.length) |
|
337 |
{ |
|
338 |
alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).'); |
|
339 |
} |
|
340 |
var param = arguments[numSubstitutions]; |
|
341 |
var pad = ''; |
|
342 |
if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1); |
|
343 |
else if (pPad) pad = pPad; |
|
344 |
var justifyRight = true; |
|
345 |
if (pJustify && pJustify === "-") justifyRight = false; |
|
346 |
var minLength = -1; |
|
347 |
if (pMinLength) minLength = parseInt(pMinLength); |
|
348 |
var precision = -1; |
|
349 |
if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1)); |
|
350 |
var subst = param; |
|
351 |
if (pType == 'b') subst = parseInt(param).toString(2); |
|
352 |
else if (pType == 'c') subst = String.fromCharCode(parseInt(param)); |
|
353 |
else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0; |
|
354 |
else if (pType == 'u') subst = Math.abs(param); |
|
355 |
else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); |
|
356 |
else if (pType == 'o') subst = parseInt(param).toString(8); |
|
357 |
else if (pType == 's') subst = param; |
|
358 |
else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); |
|
359 |
else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); |
|
360 |
} |
|
361 |
str = leftpart + subst + rightPart; |
|
362 |
} |
|
363 |
return str; |
|
364 |
} |
|
365 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
366 |
/** |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
367 |
* Insert a DOM object _after_ the specified child. |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
368 |
* @param object Parent node |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
369 |
* @param object Node to insert |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
370 |
* @param object Node to insert after |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
371 |
*/ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
372 |
|
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
373 |
function insertAfter(parent, baby, bigsister) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
374 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
375 |
try |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
376 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
377 |
if ( parent.childNodes[parent.childNodes.length-1] == bigsister ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
378 |
parent.appendChild(baby); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
379 |
else |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
380 |
parent.insertBefore(baby, bigsister.nextSibling); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
381 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
382 |
catch(e) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
383 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
384 |
alert(e.toString()); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
385 |
if ( window.console ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
386 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
387 |
// Firebug support |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
388 |
window.console.warn(e); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
389 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
390 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
391 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
392 |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
393 |
/** |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
394 |
* Validates an e-mail address. |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
395 |
* @param string E-mail address |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
396 |
* @return bool |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
397 |
*/ |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
398 |
|
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
399 |
function validateEmail(email) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
400 |
{ |
504
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
501
diff
changeset
|
401 |
return ( email.match(/^(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*)*<[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*)*:[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)?(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*>)$/) ) ? true : false; |
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
402 |
} |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
403 |
|
334
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
404 |
/** |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
405 |
* Validates a username. |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
406 |
* @param string Username to test |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
407 |
* @return bool |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
408 |
*/ |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
409 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
410 |
function validateUsername(username) |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
411 |
{ |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
412 |
var regex = new RegExp('^[^<>&\?\'"%\n\r/]+$', ''); |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
413 |
return ( username.match(regex) ) ? true : false; |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
414 |
} |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
415 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
416 |
/** |
334
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
417 |
* Equivalent of PHP's time() |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
418 |
* @return int |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
419 |
*/ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
420 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
421 |
function unix_time() |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
422 |
{ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
423 |
return parseInt((new Date()).getTime()/1000); |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
424 |
} |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
425 |
|
420
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
426 |
/* |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
427 |
* Utility functions, moved from windows.js |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
428 |
*/ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
429 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
430 |
// getElementWidth() and getElementHeight() |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
431 |
// Source: http://www.aspandjavascript.co.uk/javascript/javascript_api/get_element_width_height.asp |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
432 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
433 |
function getElementHeight(Elem) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
434 |
if (ns4) |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
435 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
436 |
var elem = getObjNN4(document, Elem); |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
437 |
return elem.clip.height; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
438 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
439 |
else |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
440 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
441 |
if(document.getElementById) |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
442 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
443 |
var elem = document.getElementById(Elem); |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
444 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
445 |
else if (document.all) |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
446 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
447 |
var elem = document.all[Elem]; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
448 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
449 |
if (op5) |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
450 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
451 |
xPos = elem.style.pixelHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
452 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
453 |
else |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
454 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
455 |
xPos = elem.offsetHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
456 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
457 |
return xPos; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
458 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
459 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
460 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
461 |
function getElementWidth(Elem) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
462 |
if (ns4) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
463 |
var elem = getObjNN4(document, Elem); |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
464 |
return elem.clip.width; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
465 |
} else { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
466 |
if(document.getElementById) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
467 |
var elem = document.getElementById(Elem); |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
468 |
} else if (document.all){ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
469 |
var elem = document.all[Elem]; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
470 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
471 |
if (op5) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
472 |
xPos = elem.style.pixelWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
473 |
} else { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
474 |
xPos = elem.offsetWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
475 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
476 |
return xPos; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
477 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
478 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
479 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
480 |
function getHeight() { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
481 |
var myHeight = 0; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
482 |
if( typeof( window.innerWidth ) == 'number' ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
483 |
myHeight = window.innerHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
484 |
} else if( document.documentElement && |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
485 |
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
486 |
myHeight = document.documentElement.clientHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
487 |
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
488 |
myHeight = document.body.clientHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
489 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
490 |
return myHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
491 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
492 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
493 |
function getWidth() { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
494 |
var myWidth = 0; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
495 |
if( typeof( window.innerWidth ) == 'number' ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
496 |
myWidth = window.innerWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
497 |
} else if( document.documentElement && |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
498 |
( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
499 |
myWidth = document.documentElement.clientWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
500 |
} else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
501 |
myWidth = document.body.clientWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
502 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
503 |
return myWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
504 |
} |
426 | 505 |
|
506 |
/** |
|
507 |
* Sanitizes a page URL string so that it can safely be stored in the database. |
|
508 |
* @param string Page ID to sanitize |
|
509 |
* @return string Cleaned text |
|
510 |
*/ |
|
511 |
||
512 |
function sanitize_page_id(page_id) |
|
513 |
{ |
|
514 |
// Remove character escapes |
|
515 |
page_id = dirtify_page_id(page_id); |
|
516 |
||
517 |
var regex = new RegExp('[A-Za-z0-9\\[\\]\./:;\(\)@_-]', 'g'); |
|
518 |
pid_clean = page_id.replace(regex, 'X'); |
|
519 |
var pid_dirty = []; |
|
520 |
for ( var i = 0; i < pid_clean.length; i++ ) |
|
521 |
pid_dirty[i] = pid_clean.substr(i, 1); |
|
522 |
||
523 |
for ( var i = 0; i < pid_dirty.length; i++ ) |
|
524 |
{ |
|
525 |
var char = pid_dirty[i]; |
|
526 |
if ( char == 'X' ) |
|
527 |
continue; |
|
528 |
var cid = char.charCodeAt(0); |
|
529 |
cid = cid.toString(16).toUpperCase(); |
|
530 |
if ( cid.length < 2 ) |
|
531 |
{ |
|
532 |
cid = '0' + cid; |
|
533 |
} |
|
534 |
pid_dirty[i] = "." + cid; |
|
535 |
} |
|
536 |
||
537 |
var pid_chars = []; |
|
538 |
for ( var i = 0; i < page_id.length; i++ ) |
|
539 |
pid_chars[i] = page_id.substr(i, 1); |
|
540 |
||
541 |
var page_id_cleaned = ''; |
|
542 |
||
543 |
for ( var id in pid_chars ) |
|
544 |
{ |
|
545 |
var char = pid_chars[id]; |
|
546 |
if ( pid_dirty[id] == 'X' ) |
|
547 |
page_id_cleaned += char; |
|
548 |
else |
|
549 |
page_id_cleaned += pid_dirty[id]; |
|
550 |
} |
|
551 |
||
552 |
return page_id_cleaned; |
|
553 |
} |
|
554 |
||
555 |
/** |
|
556 |
* Removes character escapes in a page ID string |
|
557 |
* @param string Page ID string to dirty up |
|
558 |
* @return string |
|
559 |
*/ |
|
560 |
||
561 |
function dirtify_page_id(page_id) |
|
562 |
{ |
|
563 |
// First, replace spaces with underscores |
|
564 |
page_id = page_id.replace(/ /g, '_'); |
|
565 |
||
566 |
var matches = page_id.match(/\.[A-Fa-f0-9][A-Fa-f0-9]/g); |
|
567 |
||
568 |
if ( matches != null ) |
|
569 |
{ |
|
570 |
for ( var i = 0; i < matches.length; i++ ) |
|
571 |
{ |
|
572 |
var match = matches[i]; |
|
573 |
var byt = (match.substr(1)).toUpperCase(); |
|
574 |
var code = eval("0x" + byt); |
|
575 |
var regex = new RegExp('\\.' + byt, 'g'); |
|
576 |
page_id = page_id.replace(regex, String.fromCharCode(code)); |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
return page_id; |
|
581 |
} |
|
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
582 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
583 |
/* |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
584 |
* Expandable fieldsets |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
585 |
*/ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
586 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
587 |
var expander_onload = function() |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
588 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
589 |
var sets = document.getElementsByTagName('fieldset'); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
590 |
if ( sets.length < 1 ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
591 |
return false; |
513 | 592 |
var init_us = []; |
593 |
for ( var index = 0; index < sets.length; index++ ) |
|
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
594 |
{ |
513 | 595 |
var mode = sets[index].getAttribute('enano:expand'); |
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
596 |
if ( mode == 'closed' || mode == 'open' ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
597 |
{ |
513 | 598 |
init_us.push(sets[index]); |
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
599 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
600 |
} |
513 | 601 |
for ( var k = 0; k < init_us.length; k++ ) |
602 |
{ |
|
603 |
expander_init_element(init_us[k]); |
|
604 |
} |
|
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
605 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
606 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
607 |
function expander_init_element(el) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
608 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
609 |
// get the legend tag |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
610 |
var legend = el.getElementsByTagName('legend')[0]; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
611 |
if ( !legend ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
612 |
return false; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
613 |
// existing content |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
614 |
var existing_inner = legend.innerHTML; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
615 |
// blank the innerHTML and replace it with a link |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
616 |
legend.innerHTML = ''; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
617 |
var button = document.createElement('a'); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
618 |
button.className = 'expander expander-open'; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
619 |
button.innerHTML = existing_inner; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
620 |
button.href = '#'; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
621 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
622 |
legend.appendChild(button); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
623 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
624 |
button.onclick = function() |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
625 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
626 |
try |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
627 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
628 |
expander_handle_click(this); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
629 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
630 |
catch(e) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
631 |
{ |
513 | 632 |
console.debug('Exception caught: ', e); |
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
633 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
634 |
return false; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
635 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
636 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
637 |
if ( el.getAttribute('enano:expand') == 'closed' ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
638 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
639 |
expander_close(el); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
640 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
641 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
642 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
643 |
function expander_handle_click(el) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
644 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
645 |
if ( el.parentNode.parentNode.tagName != 'FIELDSET' ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
646 |
return false; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
647 |
var parent = el.parentNode.parentNode; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
648 |
if ( parent.getAttribute('enano:expand') == 'closed' ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
649 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
650 |
expander_open(parent); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
651 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
652 |
else |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
653 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
654 |
expander_close(parent); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
655 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
656 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
657 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
658 |
function expander_close(el) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
659 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
660 |
var children = el.childNodes; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
661 |
for ( var i = 0; i < children.length; i++ ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
662 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
663 |
var child = children[i]; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
664 |
if ( child.tagName == 'LEGEND' ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
665 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
666 |
var a = child.getElementsByTagName('a')[0]; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
667 |
$(a).rmClass('expander-open'); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
668 |
$(a).addClass('expander-closed'); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
669 |
continue; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
670 |
} |
513 | 671 |
if ( child.style ) |
672 |
{ |
|
673 |
child.expander_meta_old_state = child.style.display; |
|
674 |
child.style.display = 'none'; |
|
675 |
} |
|
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
676 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
677 |
el.expander_meta_padbak = el.style.padding; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
678 |
el.setAttribute('enano:expand', 'closed'); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
679 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
680 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
681 |
function expander_open(el) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
682 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
683 |
var children = el.childNodes; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
684 |
for ( var i = 0; i < children.length; i++ ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
685 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
686 |
var child = children[i]; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
687 |
if ( child.tagName == 'LEGEND' ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
688 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
689 |
var a = child.getElementsByTagName('a')[0]; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
690 |
$(a).rmClass('expander-closed'); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
691 |
$(a).addClass('expander-open'); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
692 |
continue; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
693 |
} |
513 | 694 |
if ( child.expander_meta_old_state && child.style ) |
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
695 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
696 |
child.style.display = child.expander_meta_old_state; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
697 |
child.expander_meta_old_state = null; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
698 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
699 |
else |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
700 |
{ |
513 | 701 |
if ( child.style ) |
702 |
{ |
|
703 |
child.style.display = null; |
|
704 |
} |
|
501
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
705 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
706 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
707 |
if ( el.expander_meta_padbak ) |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
708 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
709 |
el.style.padding = el.expander_meta_padbak; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
710 |
el.expander_meta_padbak = null; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
711 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
712 |
else |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
713 |
{ |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
714 |
el.style.padding = null; |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
715 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
716 |
el.setAttribute('enano:expand', 'open'); |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
717 |
} |
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
718 |
|
9367161b2457
Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents:
458
diff
changeset
|
719 |
addOnloadHook(expander_onload); |