d20ca1c968fe8c79440d0b1b466c867ea77d13f0
1 // MediaWiki JavaScript support functions
3 var clientPC
= navigator
.userAgent
.toLowerCase(); // Get client info
4 var is_gecko
= ((clientPC
.indexOf('gecko')!=-1) && (clientPC
.indexOf('spoofer')==-1)
5 && (clientPC
.indexOf('khtml') == -1) && (clientPC
.indexOf('netscape/7.0')==-1));
6 var is_safari
= ((clientPC
.indexOf('applewebkit')!=-1) && (clientPC
.indexOf('spoofer')==-1));
7 var is_khtml
= (navigator
.vendor
== 'KDE' || ( document
.childNodes
&& !document
.all
&& !navigator
.taintEnabled
));
9 var is_ff2_win
= (clientPC
.indexOf('firefox/2')!=-1 || clientPC
.indexOf('minefield/3')!=-1) && clientPC
.indexOf('windows')!=-1;
10 var is_ff2_x11
= (clientPC
.indexOf('firefox/2')!=-1 || clientPC
.indexOf('minefield/3')!=-1) && clientPC
.indexOf('x11')!=-1;
11 if (clientPC
.indexOf('opera') != -1) {
13 var is_opera_preseven
= (window
.opera
&& !document
.childNodes
);
14 var is_opera_seven
= (window
.opera
&& document
.childNodes
);
17 // Global external objects used by this script.
18 /*extern ta, stylepath, skin */
20 // add any onload functions in this hook (please don't hard-code any events in the xhtml source)
23 if (!window
.onloadFuncts
) {
24 var onloadFuncts
= [];
27 function addOnloadHook(hookFunct
) {
28 // Allows add-on scripts to add onload functions
29 onloadFuncts
[onloadFuncts
.length
] = hookFunct
;
32 function hookEvent(hookName
, hookFunct
) {
33 if (window
.addEventListener
) {
34 window
.addEventListener(hookName
, hookFunct
, false);
35 } else if (window
.attachEvent
) {
36 window
.attachEvent("on" + hookName
, hookFunct
);
40 // document.write special stylesheet links
41 if (typeof stylepath
!= 'undefined' && typeof skin
!= 'undefined') {
42 if (is_opera_preseven
) {
43 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/Opera6Fixes.css">');
44 } else if (is_opera_seven
) {
45 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/Opera7Fixes.css">');
46 } else if (is_khtml
) {
47 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/KHTMLFixes.css">');
50 // Un-trap us from framesets
51 if (window
.top
!= window
) {
52 window
.top
.location
= window
.location
;
55 // for enhanced RecentChanges
56 function toggleVisibility(_levelId
, _otherId
, _linkId
) {
57 var thisLevel
= document
.getElementById(_levelId
);
58 var otherLevel
= document
.getElementById(_otherId
);
59 var linkLevel
= document
.getElementById(_linkId
);
60 if (thisLevel
.style
.display
== 'none') {
61 thisLevel
.style
.display
= 'block';
62 otherLevel
.style
.display
= 'none';
63 linkLevel
.style
.display
= 'inline';
65 thisLevel
.style
.display
= 'none';
66 otherLevel
.style
.display
= 'inline';
67 linkLevel
.style
.display
= 'none';
71 function historyRadios(parent
) {
72 var inputs
= parent
.getElementsByTagName('input');
74 for (var i
= 0; i
< inputs
.length
; i
++) {
75 if (inputs
[i
].name
== "diff" || inputs
[i
].name
== "oldid") {
76 radios
[radios
.length
] = inputs
[i
];
82 // check selection and tweak visibility/class onclick
83 function diffcheck() {
84 var dli
= false; // the li where the diff radio is checked
85 var oli
= false; // the li where the oldid radio is checked
86 var hf
= document
.getElementById('pagehistory');
90 var lis
= hf
.getElementsByTagName('li');
91 for (var i
=0;i
<lis
.length
;i
++) {
92 var inputs
= historyRadios(lis
[i
]);
93 if (inputs
[1] && inputs
[0]) {
94 if (inputs
[1].checked
|| inputs
[0].checked
) { // this row has a checked radio button
95 if (inputs
[1].checked
&& inputs
[0].checked
&& inputs
[0].value
== inputs
[1].value
) {
98 if (oli
) { // it's the second checked radio
99 if (inputs
[1].checked
) {
100 oli
.className
= "selected";
103 } else if (inputs
[0].checked
) {
106 if (inputs
[0].checked
) {
110 inputs
[0].style
.visibility
= 'hidden';
113 inputs
[1].style
.visibility
= 'hidden';
115 lis
[i
].className
= "selected";
117 } else { // no radio is checked in this row
119 inputs
[0].style
.visibility
= 'hidden';
121 inputs
[0].style
.visibility
= 'visible';
124 inputs
[1].style
.visibility
= 'hidden';
126 inputs
[1].style
.visibility
= 'visible';
128 lis
[i
].className
= "";
135 // page history stuff
136 // attach event handlers to the input elements on history page
137 function histrowinit() {
138 var hf
= document
.getElementById('pagehistory');
142 var lis
= hf
.getElementsByTagName('li');
143 for (var i
= 0; i
< lis
.length
; i
++) {
144 var inputs
= historyRadios(lis
[i
]);
145 if (inputs
[0] && inputs
[1]) {
146 inputs
[0].onclick
= diffcheck
;
147 inputs
[1].onclick
= diffcheck
;
153 // generate toc from prefs form, fold sections
154 // XXX: needs testing on IE/Mac and safari
155 // more comments to follow
156 function tabbedprefs() {
157 var prefform
= document
.getElementById('preferences');
158 if (!prefform
|| !document
.createElement
) {
161 if (prefform
.nodeName
.toLowerCase() == 'a') {
162 return; // Occasional IE problem
164 prefform
.className
= prefform
.className
+ 'jsprefs';
166 var children
= prefform
.childNodes
;
168 for (var i
= 0; i
< children
.length
; i
++) {
169 if (children
[i
].nodeName
.toLowerCase() == 'fieldset') {
170 children
[i
].id
= 'prefsection-' + seci
;
171 children
[i
].className
= 'prefsection';
172 if (is_opera
|| is_khtml
) {
173 children
[i
].className
= 'prefsection operaprefsection';
175 var legends
= children
[i
].getElementsByTagName('legend');
177 legends
[0].className
= 'mainLegend';
178 if (legends
[0] && legends
[0].firstChild
.nodeValue
) {
179 sections
[seci
].text
= legends
[0].firstChild
.nodeValue
;
181 sections
[seci
].text
= '# ' + seci
;
183 sections
[seci
].secid
= children
[i
].id
;
185 if (sections
.length
!= 1) {
186 children
[i
].style
.display
= 'none';
188 var selectedid
= children
[i
].id
;
192 var toc
= document
.createElement('ul');
194 toc
.selectedid
= selectedid
;
195 for (i
= 0; i
< sections
.length
; i
++) {
196 var li
= document
.createElement('li');
198 li
.className
= 'selected';
200 var a
= document
.createElement('a');
201 a
.href
= '#' + sections
[i
].secid
;
202 a
.onmousedown
= a
.onclick
= uncoversection
;
203 a
.appendChild(document
.createTextNode(sections
[i
].text
));
204 a
.secid
= sections
[i
].secid
;
208 prefform
.parentNode
.insertBefore(toc
, prefform
.parentNode
.childNodes
[0]);
209 document
.getElementById('prefsubmit').id
= 'prefcontrol';
212 function uncoversection() {
213 var oldsecid
= this.parentNode
.parentNode
.selectedid
;
214 var newsec
= document
.getElementById(this.secid
);
215 if (oldsecid
!= this.secid
) {
216 var ul
= document
.getElementById('preftoc');
217 document
.getElementById(oldsecid
).style
.display
= 'none';
218 newsec
.style
.display
= 'block';
219 ul
.selectedid
= this.secid
;
220 var lis
= ul
.getElementsByTagName('li');
221 for (var i
= 0; i
< lis
.length
; i
++) {
222 lis
[i
].className
= '';
224 this.parentNode
.className
= 'selected';
230 // tz in format [+-]HHMM
231 function checkTimezone(tz
, msg
) {
232 var localclock
= new Date();
233 // returns negative offset from GMT in minutes
234 var tzRaw
= localclock
.getTimezoneOffset();
235 var tzHour
= Math
.floor( Math
.abs(tzRaw
) / 60);
236 var tzMin
= Math
.abs(tzRaw
) % 60;
237 var tzString
= ((tzRaw
>= 0) ? "-" : "+") + ((tzHour
< 10) ? "0" : "") + tzHour
+ ((tzMin
< 10) ? "0" : "") + tzMin
;
238 if (tz
!= tzString
) {
239 var junk
= msg
.split('$1');
240 document
.write(junk
[0] + "UTC" + tzString
+ junk
[1]);
244 function unhidetzbutton() {
245 var tzb
= document
.getElementById('guesstimezonebutton');
247 tzb
.style
.display
= 'inline';
251 // in [-]HH:MM format...
252 // won't yet work with non-even tzs
253 function fetchTimezone() {
254 // FIXME: work around Safari bug
255 var localclock
= new Date();
256 // returns negative offset from GMT in minutes
257 var tzRaw
= localclock
.getTimezoneOffset();
258 var tzHour
= Math
.floor( Math
.abs(tzRaw
) / 60);
259 var tzMin
= Math
.abs(tzRaw
) % 60;
260 var tzString
= ((tzRaw
>= 0) ? "-" : "") + ((tzHour
< 10) ? "0" : "") + tzHour
+
261 ":" + ((tzMin
< 10) ? "0" : "") + tzMin
;
265 function guessTimezone(box
) {
266 document
.getElementsByName("wpHourDiff")[0].value
= fetchTimezone();
269 function showTocToggle() {
270 if (document
.createTextNode
) {
271 // Uses DOM calls to avoid document.write + XHTML issues
273 var linkHolder
= document
.getElementById('toctitle');
278 var outerSpan
= document
.createElement('span');
279 outerSpan
.className
= 'toctoggle';
281 var toggleLink
= document
.createElement('a');
282 toggleLink
.id
= 'togglelink';
283 toggleLink
.className
= 'internal';
284 toggleLink
.href
= 'javascript:toggleToc()';
285 toggleLink
.appendChild(document
.createTextNode(tocHideText
));
287 outerSpan
.appendChild(document
.createTextNode('['));
288 outerSpan
.appendChild(toggleLink
);
289 outerSpan
.appendChild(document
.createTextNode(']'));
291 linkHolder
.appendChild(document
.createTextNode(' '));
292 linkHolder
.appendChild(outerSpan
);
294 var cookiePos
= document
.cookie
.indexOf("hidetoc=");
295 if (cookiePos
> -1 && document
.cookie
.charAt(cookiePos
+ 8) == 1) {
301 function changeText(el
, newText
) {
302 // Safari work around
304 el
.innerText
= newText
;
305 } else if (el
.firstChild
&& el
.firstChild
.nodeValue
) {
306 el
.firstChild
.nodeValue
= newText
;
310 function toggleToc() {
311 var toc
= document
.getElementById('toc').getElementsByTagName('ul')[0];
312 var toggleLink
= document
.getElementById('togglelink');
314 if (toc
&& toggleLink
&& toc
.style
.display
== 'none') {
315 changeText(toggleLink
, tocHideText
);
316 toc
.style
.display
= 'block';
317 document
.cookie
= "hidetoc=0";
319 changeText(toggleLink
, tocShowText
);
320 toc
.style
.display
= 'none';
321 document
.cookie
= "hidetoc=1";
325 var mwEditButtons
= [];
326 var mwCustomEditButtons
= []; // eg to add in MediaWiki:Common.js
328 // this function generates the actual toolbar buttons with localized text
329 // we use it to avoid creating the toolbar where javascript is not enabled
330 function addButton(imageFile
, speedTip
, tagOpen
, tagClose
, sampleText
) {
331 // Don't generate buttons for browsers which don't fully
333 mwEditButtons
[mwEditButtons
.length
] =
334 {"imageFile": imageFile
,
335 "speedTip": speedTip
,
337 "tagClose": tagClose
,
338 "sampleText": sampleText
};
341 // this function generates the actual toolbar buttons with localized text
342 // we use it to avoid creating the toolbar where javascript is not enabled
343 function mwInsertEditButton(parent
, item
) {
344 var image
= document
.createElement("img");
347 image
.src
= item
.imageFile
;
349 image
.alt
= item
.speedTip
;
350 image
.title
= item
.speedTip
;
351 image
.style
.cursor
= "pointer";
352 image
.onclick = function() {
353 insertTags(item
.tagOpen
, item
.tagClose
, item
.sampleText
);
357 parent
.appendChild(image
);
361 function mwSetupToolbar() {
362 var toolbar
= document
.getElementById('toolbar');
363 if (!toolbar
) { return false; }
365 var textbox
= document
.getElementById('wpTextbox1');
366 if (!textbox
) { return false; }
368 // Don't generate buttons for browsers which don't fully
370 if (!document
.selection
&& textbox
.selectionStart
=== null) {
374 for (var i
in mwEditButtons
) {
375 mwInsertEditButton(toolbar
, mwEditButtons
[i
]);
377 for (i
in mwCustomEditButtons
) {
378 mwInsertEditButton(toolbar
, mwCustomEditButtons
[i
]);
383 function escapeQuotes(text
) {
384 var re
= new RegExp("'","g");
385 text
= text
.replace(re
,"\\'");
386 re
= new RegExp("\\n","g");
387 text
= text
.replace(re
,"\\n");
388 return escapeQuotesHTML(text
);
391 function escapeQuotesHTML(text
) {
392 var re
= new RegExp('&',"g");
393 text
= text
.replace(re
,"&");
394 re
= new RegExp('"',"g");
395 text
= text
.replace(re
,""");
396 re
= new RegExp('<',"g");
397 text
= text
.replace(re
,"<");
398 re
= new RegExp('>',"g");
399 text
= text
.replace(re
,">");
403 // apply tagOpen/tagClose to selection in textarea,
404 // use sampleText instead of selection if there is none
405 // copied and adapted from phpBB
406 function insertTags(tagOpen
, tagClose
, sampleText
) {
408 if (document
.editform
) {
409 txtarea
= document
.editform
.wpTextbox1
;
411 // some alternate form? take the first one we can find
412 var areas
= document
.getElementsByTagName('textarea');
417 if (document
.selection
&& !is_gecko
) {
418 var theSelection
= document
.selection
.createRange().text
;
420 theSelection
=sampleText
;
423 if (theSelection
.charAt(theSelection
.length
- 1) == " ") { // exclude ending space char, if any
424 theSelection
= theSelection
.substring(0, theSelection
.length
- 1);
425 document
.selection
.createRange().text
= tagOpen
+ theSelection
+ tagClose
+ " ";
427 document
.selection
.createRange().text
= tagOpen
+ theSelection
+ tagClose
;
431 } else if(txtarea
.selectionStart
|| txtarea
.selectionStart
== '0') {
432 var replaced
= false;
433 var startPos
= txtarea
.selectionStart
;
434 var endPos
= txtarea
.selectionEnd
;
435 if (endPos
-startPos
) {
438 var scrollTop
= txtarea
.scrollTop
;
439 var myText
= (txtarea
.value
).substring(startPos
, endPos
);
444 if (myText
.charAt(myText
.length
- 1) == " ") { // exclude ending space char, if any
445 subst
= tagOpen
+ myText
.substring(0, (myText
.length
- 1)) + tagClose
+ " ";
447 subst
= tagOpen
+ myText
+ tagClose
;
449 txtarea
.value
= txtarea
.value
.substring(0, startPos
) + subst
+
450 txtarea
.value
.substring(endPos
, txtarea
.value
.length
);
454 var cPos
= startPos
+(tagOpen
.length
+myText
.length
+tagClose
.length
);
455 txtarea
.selectionStart
= cPos
;
456 txtarea
.selectionEnd
= cPos
;
458 txtarea
.selectionStart
= startPos
+tagOpen
.length
;
459 txtarea
.selectionEnd
= startPos
+tagOpen
.length
+myText
.length
;
461 txtarea
.scrollTop
= scrollTop
;
463 // All other browsers get no toolbar.
464 // There was previously support for a crippled "help"
465 // bar, but that caused more problems than it solved.
467 // reposition cursor if possible
468 if (txtarea
.createTextRange
) {
469 txtarea
.caretPos
= document
.selection
.createRange().duplicate();
474 if (typeof ta
== "undefined" || !ta
) {
479 if (is_safari
|| navigator
.userAgent
.toLowerCase().indexOf('mac') + 1
480 || navigator
.userAgent
.toLowerCase().indexOf('konqueror') + 1 ) {
482 } else if (is_opera
) {
484 } else if (is_ff2_x11
) {
485 pref
= 'ctrl-shift-';
486 } else if (is_ff2_win
) {
493 var n
= document
.getElementById(id
);
497 // Are we putting accesskey in it
498 if (ta
[id
][0].length
> 0) {
499 // Is this object a object? If not assume it's the next child.
501 if (n
.nodeName
.toLowerCase() == "a") {
506 // Don't add an accesskey for the watch tab if the watch
507 // checkbox is also available.
508 if (a
&& ((id
!= 'ca-watch' && id
!= 'ca-unwatch') ||
509 !(window
.location
.search
.match(/[\?&](action=edit|action=submit)/i)))) {
510 a
.accessKey
= ta
[id
][0];
511 ak
= ' ['+pref
+ta
[id
][0]+']';
514 // We don't care what type the object is when assigning tooltip
520 a
.title
= ta
[id
][1]+ak
;
526 function setupRightClickEdit() {
527 if (document
.getElementsByTagName
) {
528 var spans
= document
.getElementsByTagName('span');
529 for (var i
= 0; i
< spans
.length
; i
++) {
531 if(el
.className
== 'editsection') {
532 addRightClickEditHandler(el
);
538 function addRightClickEditHandler(el
) {
539 for (var i
= 0; i
< el
.childNodes
.length
; i
++) {
540 var link
= el
.childNodes
[i
];
541 if (link
.nodeType
== 1 && link
.nodeName
.toLowerCase() == 'a') {
542 var editHref
= link
.getAttribute('href');
543 // find the enclosing (parent) header
544 var prev
= el
.parentNode
;
545 if (prev
&& prev
.nodeType
== 1 &&
546 prev
.nodeName
.match(/^[Hh][1-6]$/)) {
547 prev
.oncontextmenu = function(e
) {
548 if (!e
) { e
= window
.event
; }
549 // e is now the event in all browsers
551 if (e
.target
) { targ
= e
.target
; }
552 else if (e
.srcElement
) { targ
= e
.srcElement
; }
553 if (targ
.nodeType
== 3) { // defeat Safari bug
554 targ
= targ
.parentNode
;
556 // targ is now the target element
558 // We don't want to deprive the noble reader of a context menu
559 // for the section edit link, do we? (Might want to extend this
561 if (targ
.nodeName
.toLowerCase() != 'a'
562 || targ
.parentNode
.className
!= 'editsection') {
563 document
.location
= editHref
;
573 function setupCheckboxShiftClick() {
574 if (document
.getElementsByTagName
) {
575 var uls
= document
.getElementsByTagName('ul');
576 var len
= uls
.length
;
577 for (var i
= 0; i
< len
; ++i
) {
578 addCheckboxClickHandlers(uls
[i
]);
583 function addCheckboxClickHandlers(ul
, start
, finish
) {
584 if (ul
.checkboxHandlersTimer
) {
585 clearInterval(ul
.checkboxHandlersTimer
);
587 if ( !ul
.childNodes
) {
590 var len
= ul
.childNodes
.length
;
595 finish
= finish
|| start
+ 250;
596 if ( finish
> len
) { finish
= len
; }
597 ul
.checkboxes
= ul
.checkboxes
|| [];
598 ul
.lastCheckbox
= ul
.lastCheckbox
|| null;
599 for (var i
= start
; i
<finish
; ++i
) {
600 var child
= ul
.childNodes
[i
];
601 if ( child
&& child
.childNodes
&& child
.childNodes
[0] ) {
602 var cb
= child
.childNodes
[0];
603 if ( !cb
.nodeName
|| cb
.nodeName
.toLowerCase() != 'input' ||
604 !cb
.type
|| cb
.type
.toLowerCase() != 'checkbox' ) {
607 cb
.index
= ul
.checkboxes
.push(cb
) - 1;
609 cb
.onmouseup
= checkboxMouseupHandler
;
613 var f=function(){ addCheckboxClickHandlers(ul
, finish
, finish
+250); };
614 ul
.checkboxHandlersTimer
=setInterval(f
, 200);
618 function checkboxMouseupHandler(e
) {
619 if (typeof e
== 'undefined') {
622 if ( !e
.shiftKey
|| this.container
.lastCheckbox
=== null ) {
623 this.container
.lastCheckbox
= this.index
;
626 var endState
= !this.checked
;
627 if ( is_opera
) { // opera has already toggled the checkbox by this point
628 endState
= !endState
;
631 if ( this.index
< this.container
.lastCheckbox
) {
632 start
= this.index
+ 1;
633 finish
= this.container
.lastCheckbox
;
635 start
= this.container
.lastCheckbox
;
636 finish
= this.index
- 1;
638 for (var i
= start
; i
<= finish
; ++i
) {
639 this.container
.checkboxes
[i
].checked
= endState
;
641 this.container
.lastCheckbox
= this.index
;
645 function toggle_element_activation(ida
,idb
) {
646 if (!document
.getElementById
) {
649 document
.getElementById(ida
).disabled
=true;
650 document
.getElementById(idb
).disabled
=false;
653 function toggle_element_check(ida
,idb
) {
654 if (!document
.getElementById
) {
657 document
.getElementById(ida
).checked
=true;
658 document
.getElementById(idb
).checked
=false;
661 function fillDestFilename(id
) {
662 if (!document
.getElementById
) {
665 var path
= document
.getElementById(id
).value
;
666 // Find trailing part
667 var slash
= path
.lastIndexOf('/');
668 var backslash
= path
.lastIndexOf('\\');
670 if (slash
== -1 && backslash
== -1) {
672 } else if (slash
> backslash
) {
673 fname
= path
.substring(slash
+1, 10000);
675 fname
= path
.substring(backslash
+1, 10000);
678 // Capitalise first letter and replace spaces by underscores
679 fname
= fname
.charAt(0).toUpperCase().concat(fname
.substring(1,10000)).replace(/ /g
, '_');
682 var destFile
= document
.getElementById('wpDestFile');
684 destFile
.value
= fname
;
689 function considerChangingExpiryFocus() {
690 if (!document
.getElementById
) {
693 var drop
= document
.getElementById('wpBlockExpiry');
697 var field
= document
.getElementById('wpBlockOther');
701 var opt
= drop
.value
;
702 if (opt
== 'other') {
703 field
.style
.display
= '';
705 field
.style
.display
= 'none';
709 function scrollEditBox() {
710 var editBoxEl
= document
.getElementById("wpTextbox1");
711 var scrollTopEl
= document
.getElementById("wpScrolltop");
712 var editFormEl
= document
.getElementById("editform");
714 if (editBoxEl
&& scrollTopEl
) {
715 if (scrollTopEl
.value
) { editBoxEl
.scrollTop
= scrollTopEl
.value
; }
716 editFormEl
.onsubmit = function() {
717 document
.getElementById("wpScrolltop").value
= document
.getElementById("wpTextbox1").scrollTop
;
722 hookEvent("load", scrollEditBox
);
724 function allmessagesfilter() {
725 var text
= document
.getElementById('allmessagesinput').value
;
726 var k
= document
.getElementById('allmessagestable');
729 var items
= k
.getElementsByTagName('span');
732 if ( text
.length
> allmessages_prev
.length
) {
733 for (i
= items
.length
-1, j
= 0; i
>= 0; i
--) {
734 j
= allmessagesforeach(items
, i
, j
, text
);
737 for (i
= 0, j
= 0; i
< items
.length
; i
++) {
738 j
= allmessagesforeach(items
, i
, j
, text
);
741 allmessages_prev
= text
;
744 function allmessagesforeach(items
, i
, j
, text
) {
745 var hItem
= items
[i
].getAttribute('id');
746 if (hItem
.substring(0,17) == 'sp-allmessages-i-') {
747 var itemA
, itemB
, s
, k
;
748 if (items
[i
].firstChild
&& items
[i
].firstChild
.nodeName
== '#text' && items
[i
].firstChild
.nodeValue
.indexOf(text
) != -1) {
749 itemA
= document
.getElementById( hItem
.replace('i', 'r1') );
750 itemB
= document
.getElementById( hItem
.replace('i', 'r2') );
751 if ( itemA
.style
.display
!== '' ) {
752 s
= "allmessageshider(\"" + hItem
.replace('i', 'r1') + "\", \"" + hItem
.replace('i', 'r2') + "\", '')";
753 k
= window
.setTimeout(s
,j
++*5);
756 itemA
= document
.getElementById( hItem
.replace('i', 'r1') );
757 itemB
= document
.getElementById( hItem
.replace('i', 'r2') );
758 if ( itemA
.style
.display
!= 'none' ) {
759 s
= "allmessageshider(\"" + hItem
.replace('i', 'r1') + "\", \"" + hItem
.replace('i', 'r2') + "\", 'none')";
760 k
= window
.setTimeout(s
,j
++*5);
768 function allmessageshider(idA
, idB
, cstyle
) {
769 var itemA
= document
.getElementById( idA
);
770 var itemB
= document
.getElementById( idB
);
771 if (itemA
) { itemA
.style
.display
= cstyle
; }
772 if (itemB
) { itemB
.style
.display
= cstyle
; }
775 function allmessagesmodified() {
776 allmessages_modified
= !allmessages_modified
;
777 var k
= document
.getElementById('allmessagestable');
779 var items
= k
.getElementsByTagName('tr');
780 for (var i
= 0, j
= 0; i
< items
.length
; i
++) {
782 if (!allmessages_modified
) {
783 if ( items
[i
].style
.display
!== '' ) {
784 s
= "allmessageshider(\"" + items
[i
].getAttribute('id') + "\", null, '')";
785 k
= window
.setTimeout(s
,j
++*5);
787 } else if (items
[i
].getAttribute('class') == 'def' && allmessages_modified
) {
788 if ( items
[i
].style
.display
!= 'none' ) {
789 s
= "allmessageshider(\"" + items
[i
].getAttribute('id') + "\", null, 'none')";
790 k
= window
.setTimeout(s
,j
++*5);
796 function allmessagesshow() {
797 var k
= document
.getElementById('allmessagesfilter');
798 if (k
) { k
.style
.display
= ''; }
800 allmessages_prev
= '';
801 allmessages_modified
= false;
805 Written by Jonathan Snook, http://www.snook.ca/jonathan
806 Add-ons by Robert Nyman, http://www.robertnyman.com
807 Author says "The credit comment is all it takes, no license. Go crazy with it!:-)"
808 From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
810 function getElementsByClassName(oElm
, strTagName
, oClassNames
){
811 var arrElements
= (strTagName
== "*" && oElm
.all
)? oElm
.all
: oElm
.getElementsByTagName(strTagName
);
812 var arrReturnElements
= new Array();
813 var arrRegExpClassNames
= new Array();
814 if(typeof oClassNames
== "object"){
815 for(var i
=0; i
<oClassNames
.length
; i
++){
816 arrRegExpClassNames
.push(new RegExp("(^|\\s)" + oClassNames
[i
].replace(/\-/g, "\\-") + "(\\s|$)"));
820 arrRegExpClassNames
.push(new RegExp("(^|\\s)" + oClassNames
.replace(/\-/g, "\\-") + "(\\s|$)"));
824 for(var j
=0; j
<arrElements
.length
; j
++){
825 oElement
= arrElements
[j
];
827 for(var k
=0; k
<arrRegExpClassNames
.length
; k
++){
828 if(!arrRegExpClassNames
[k
].test(oElement
.className
)){
834 arrReturnElements
.push(oElement
);
837 return (arrReturnElements
)
840 function sortableTables() {
841 if (getElementsByClassName(document
, "table", "sortable").length
!= 0) {
842 document
.write('<script type="text/javascript" src="'+stylepath
+'/common/sorttable.js"></script>');
847 function runOnloadHook() {
848 // don't run anything below this for non-dom browsers
849 if (doneOnloadHook
|| !(document
.getElementById
&& document
.getElementsByTagName
)) {
858 setupCheckboxShiftClick();
861 // Run any added-on functions
862 for (var i
= 0; i
< onloadFuncts
.length
; i
++) {
866 doneOnloadHook
= true;
869 //note: all skins should call runOnloadHook() at the end of html output,
870 // so the below should be redundant. It's there just in case.
871 hookEvent("load", runOnloadHook
);
873 hookEvent("load", allmessagesshow
);
874 hookEvent("load", mwSetupToolbar
);