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 // add any onload functions in this hook (please don't hard-code any events in the xhtml source)
21 if (!window
.onloadFuncts
) {
22 var onloadFuncts
= [];
25 function addOnloadHook(hookFunct
) {
26 // Allows add-on scripts to add onload functions
27 onloadFuncts
[onloadFuncts
.length
] = hookFunct
;
30 function hookEvent(hookName
, hookFunct
) {
31 if (window
.addEventListener
) {
32 window
.addEventListener(hookName
, hookFunct
, false);
33 } else if (window
.attachEvent
) {
34 window
.attachEvent("on" + hookName
, hookFunct
);
38 // document.write special stylesheet links
39 if (typeof stylepath
!= 'undefined' && typeof skin
!= 'undefined') {
40 if (is_opera_preseven
) {
41 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/Opera6Fixes.css">');
42 } else if (is_opera_seven
) {
43 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/Opera7Fixes.css">');
44 } else if (is_khtml
) {
45 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/KHTMLFixes.css">');
48 // Un-trap us from framesets
49 if (window
.top
!= window
) {
50 window
.top
.location
= window
.location
;
53 // for enhanced RecentChanges
54 function toggleVisibility(_levelId
, _otherId
, _linkId
) {
55 var thisLevel
= document
.getElementById(_levelId
);
56 var otherLevel
= document
.getElementById(_otherId
);
57 var linkLevel
= document
.getElementById(_linkId
);
58 if (thisLevel
.style
.display
== 'none') {
59 thisLevel
.style
.display
= 'block';
60 otherLevel
.style
.display
= 'none';
61 linkLevel
.style
.display
= 'inline';
63 thisLevel
.style
.display
= 'none';
64 otherLevel
.style
.display
= 'inline';
65 linkLevel
.style
.display
= 'none';
69 function historyRadios(parent
) {
70 var inputs
= parent
.getElementsByTagName('input');
72 for (var i
= 0; i
< inputs
.length
; i
++) {
73 if (inputs
[i
].name
== "diff" || inputs
[i
].name
== "oldid") {
74 radios
[radios
.length
] = inputs
[i
];
80 // check selection and tweak visibility/class onclick
81 function diffcheck() {
82 var dli
= false; // the li where the diff radio is checked
83 var oli
= false; // the li where the oldid radio is checked
84 var hf
= document
.getElementById('pagehistory');
88 var lis
= hf
.getElementsByTagName('li');
89 for (var i
=0;i
<lis
.length
;i
++) {
90 var inputs
= historyRadios(lis
[i
]);
91 if (inputs
[1] && inputs
[0]) {
92 if (inputs
[1].checked
|| inputs
[0].checked
) { // this row has a checked radio button
93 if (inputs
[1].checked
&& inputs
[0].checked
&& inputs
[0].value
== inputs
[1].value
) {
96 if (oli
) { // it's the second checked radio
97 if (inputs
[1].checked
) {
98 oli
.className
= "selected";
101 } else if (inputs
[0].checked
) {
104 if (inputs
[0].checked
) {
108 inputs
[0].style
.visibility
= 'hidden';
111 inputs
[1].style
.visibility
= 'hidden';
113 lis
[i
].className
= "selected";
115 } else { // no radio is checked in this row
117 inputs
[0].style
.visibility
= 'hidden';
119 inputs
[0].style
.visibility
= 'visible';
122 inputs
[1].style
.visibility
= 'hidden';
124 inputs
[1].style
.visibility
= 'visible';
126 lis
[i
].className
= "";
133 // page history stuff
134 // attach event handlers to the input elements on history page
135 function histrowinit() {
136 var hf
= document
.getElementById('pagehistory');
140 var lis
= hf
.getElementsByTagName('li');
141 for (var i
= 0; i
< lis
.length
; i
++) {
142 var inputs
= historyRadios(lis
[i
]);
143 if (inputs
[0] && inputs
[1]) {
144 inputs
[0].onclick
= diffcheck
;
145 inputs
[1].onclick
= diffcheck
;
151 // generate toc from prefs form, fold sections
152 // XXX: needs testing on IE/Mac and safari
153 // more comments to follow
154 function tabbedprefs() {
155 var prefform
= document
.getElementById('preferences');
156 if (!prefform
|| !document
.createElement
) {
159 if (prefform
.nodeName
.toLowerCase() == 'a') {
160 return; // Occasional IE problem
162 prefform
.className
= prefform
.className
+ 'jsprefs';
164 var children
= prefform
.childNodes
;
166 for (var i
= 0; i
< children
.length
; i
++) {
167 if (children
[i
].nodeName
.toLowerCase() == 'fieldset') {
168 children
[i
].id
= 'prefsection-' + seci
;
169 children
[i
].className
= 'prefsection';
170 if (is_opera
|| is_khtml
) {
171 children
[i
].className
= 'prefsection operaprefsection';
173 var legends
= children
[i
].getElementsByTagName('legend');
175 legends
[0].className
= 'mainLegend';
176 if (legends
[0] && legends
[0].firstChild
.nodeValue
) {
177 sections
[seci
].text
= legends
[0].firstChild
.nodeValue
;
179 sections
[seci
].text
= '# ' + seci
;
181 sections
[seci
].secid
= children
[i
].id
;
183 if (sections
.length
!= 1) {
184 children
[i
].style
.display
= 'none';
186 var selectedid
= children
[i
].id
;
190 var toc
= document
.createElement('ul');
192 toc
.selectedid
= selectedid
;
193 for (i
= 0; i
< sections
.length
; i
++) {
194 var li
= document
.createElement('li');
196 li
.className
= 'selected';
198 var a
= document
.createElement('a');
199 a
.href
= '#' + sections
[i
].secid
;
200 a
.onmousedown
= a
.onclick
= uncoversection
;
201 a
.appendChild(document
.createTextNode(sections
[i
].text
));
202 a
.secid
= sections
[i
].secid
;
206 prefform
.parentNode
.insertBefore(toc
, prefform
.parentNode
.childNodes
[0]);
207 document
.getElementById('prefsubmit').id
= 'prefcontrol';
210 function uncoversection() {
211 var oldsecid
= this.parentNode
.parentNode
.selectedid
;
212 var newsec
= document
.getElementById(this.secid
);
213 if (oldsecid
!= this.secid
) {
214 var ul
= document
.getElementById('preftoc');
215 document
.getElementById(oldsecid
).style
.display
= 'none';
216 newsec
.style
.display
= 'block';
217 ul
.selectedid
= this.secid
;
218 var lis
= ul
.getElementsByTagName('li');
219 for (var i
= 0; i
< lis
.length
; i
++) {
220 lis
[i
].className
= '';
222 this.parentNode
.className
= 'selected';
228 // tz in format [+-]HHMM
229 function checkTimezone(tz
, msg
) {
230 var localclock
= new Date();
231 // returns negative offset from GMT in minutes
232 var tzRaw
= localclock
.getTimezoneOffset();
233 var tzHour
= Math
.floor( Math
.abs(tzRaw
) / 60);
234 var tzMin
= Math
.abs(tzRaw
) % 60;
235 var tzString
= ((tzRaw
>= 0) ? "-" : "+") + ((tzHour
< 10) ? "0" : "") + tzHour
+ ((tzMin
< 10) ? "0" : "") + tzMin
;
236 if (tz
!= tzString
) {
237 var junk
= msg
.split('$1');
238 document
.write(junk
[0] + "UTC" + tzString
+ junk
[1]);
242 function unhidetzbutton() {
243 var tzb
= document
.getElementById('guesstimezonebutton');
245 tzb
.style
.display
= 'inline';
249 // in [-]HH:MM format...
250 // won't yet work with non-even tzs
251 function fetchTimezone() {
252 // FIXME: work around Safari bug
253 var localclock
= new Date();
254 // returns negative offset from GMT in minutes
255 var tzRaw
= localclock
.getTimezoneOffset();
256 var tzHour
= Math
.floor( Math
.abs(tzRaw
) / 60);
257 var tzMin
= Math
.abs(tzRaw
) % 60;
258 var tzString
= ((tzRaw
>= 0) ? "-" : "") + ((tzHour
< 10) ? "0" : "") + tzHour
+
259 ":" + ((tzMin
< 10) ? "0" : "") + tzMin
;
263 function guessTimezone(box
) {
264 document
.getElementsByName("wpHourDiff")[0].value
= fetchTimezone();
267 function showTocToggle() {
268 if (document
.createTextNode
) {
269 // Uses DOM calls to avoid document.write + XHTML issues
271 var linkHolder
= document
.getElementById('toctitle');
276 var outerSpan
= document
.createElement('span');
277 outerSpan
.className
= 'toctoggle';
279 var toggleLink
= document
.createElement('a');
280 toggleLink
.id
= 'togglelink';
281 toggleLink
.className
= 'internal';
282 toggleLink
.href
= 'javascript:toggleToc()';
283 toggleLink
.appendChild(document
.createTextNode(tocHideText
));
285 outerSpan
.appendChild(document
.createTextNode('['));
286 outerSpan
.appendChild(toggleLink
);
287 outerSpan
.appendChild(document
.createTextNode(']'));
289 linkHolder
.appendChild(document
.createTextNode(' '));
290 linkHolder
.appendChild(outerSpan
);
292 var cookiePos
= document
.cookie
.indexOf("hidetoc=");
293 if (cookiePos
> -1 && document
.cookie
.charAt(cookiePos
+ 8) == 1) {
299 function changeText(el
, newText
) {
300 // Safari work around
302 el
.innerText
= newText
;
303 } else if (el
.firstChild
&& el
.firstChild
.nodeValue
) {
304 el
.firstChild
.nodeValue
= newText
;
308 function toggleToc() {
309 var toc
= document
.getElementById('toc').getElementsByTagName('ul')[0];
310 var toggleLink
= document
.getElementById('togglelink');
312 if (toc
&& toggleLink
&& toc
.style
.display
== 'none') {
313 changeText(toggleLink
, tocHideText
);
314 toc
.style
.display
= 'block';
315 document
.cookie
= "hidetoc=0";
317 changeText(toggleLink
, tocShowText
);
318 toc
.style
.display
= 'none';
319 document
.cookie
= "hidetoc=1";
323 var mwEditButtons
= [];
324 var mwCustomEditButtons
= []; // eg to add in MediaWiki:Common.js
326 // this function generates the actual toolbar buttons with localized text
327 // we use it to avoid creating the toolbar where javascript is not enabled
328 function addButton(imageFile
, speedTip
, tagOpen
, tagClose
, sampleText
) {
329 // Don't generate buttons for browsers which don't fully
331 mwEditButtons
[mwEditButtons
.length
] =
332 {"imageFile": imageFile
,
333 "speedTip": speedTip
,
335 "tagClose": tagClose
,
336 "sampleText": sampleText
};
339 // this function generates the actual toolbar buttons with localized text
340 // we use it to avoid creating the toolbar where javascript is not enabled
341 function mwInsertEditButton(parent
, item
) {
342 var image
= document
.createElement("img");
345 image
.src
= item
.imageFile
;
347 image
.alt
= item
.speedTip
;
348 image
.title
= item
.speedTip
;
349 image
.style
.cursor
= "pointer";
350 image
.onclick = function() {
351 insertTags(item
.tagOpen
, item
.tagClose
, item
.sampleText
);
355 parent
.appendChild(image
);
359 function mwSetupToolbar() {
360 var toolbar
= document
.getElementById('toolbar');
361 if (!toolbar
) { return false; }
363 var textbox
= document
.getElementById('wpTextbox1');
364 if (!textbox
) { return false; }
366 // Don't generate buttons for browsers which don't fully
368 if (!document
.selection
&& textbox
.selectionStart
=== null) {
372 for (var i
in mwEditButtons
) {
373 mwInsertEditButton(toolbar
, mwEditButtons
[i
]);
375 for (i
in mwCustomEditButtons
) {
376 mwInsertEditButton(toolbar
, mwCustomEditButtons
[i
]);
381 function escapeQuotes(text
) {
382 var re
= new RegExp("'","g");
383 text
= text
.replace(re
,"\\'");
384 re
= new RegExp("\\n","g");
385 text
= text
.replace(re
,"\\n");
386 return escapeQuotesHTML(text
);
389 function escapeQuotesHTML(text
) {
390 var re
= new RegExp('&',"g");
391 text
= text
.replace(re
,"&");
392 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
,">");
401 // apply tagOpen/tagClose to selection in textarea,
402 // use sampleText instead of selection if there is none
403 // copied and adapted from phpBB
404 function insertTags(tagOpen
, tagClose
, sampleText
) {
406 if (document
.editform
) {
407 txtarea
= document
.editform
.wpTextbox1
;
409 // some alternate form? take the first one we can find
410 var areas
= document
.getElementsByTagName('textarea');
415 if (document
.selection
&& !is_gecko
) {
416 var theSelection
= document
.selection
.createRange().text
;
418 theSelection
=sampleText
;
421 if (theSelection
.charAt(theSelection
.length
- 1) == " ") { // exclude ending space char, if any
422 theSelection
= theSelection
.substring(0, theSelection
.length
- 1);
423 document
.selection
.createRange().text
= tagOpen
+ theSelection
+ tagClose
+ " ";
425 document
.selection
.createRange().text
= tagOpen
+ theSelection
+ tagClose
;
429 } else if(txtarea
.selectionStart
|| txtarea
.selectionStart
== '0') {
430 var replaced
= false;
431 var startPos
= txtarea
.selectionStart
;
432 var endPos
= txtarea
.selectionEnd
;
433 if (endPos
-startPos
) {
436 var scrollTop
= txtarea
.scrollTop
;
437 var myText
= (txtarea
.value
).substring(startPos
, endPos
);
442 if (myText
.charAt(myText
.length
- 1) == " ") { // exclude ending space char, if any
443 subst
= tagOpen
+ myText
.substring(0, (myText
.length
- 1)) + tagClose
+ " ";
445 subst
= tagOpen
+ myText
+ tagClose
;
447 txtarea
.value
= txtarea
.value
.substring(0, startPos
) + subst
+
448 txtarea
.value
.substring(endPos
, txtarea
.value
.length
);
452 var cPos
= startPos
+(tagOpen
.length
+myText
.length
+tagClose
.length
);
453 txtarea
.selectionStart
= cPos
;
454 txtarea
.selectionEnd
= cPos
;
456 txtarea
.selectionStart
= startPos
+tagOpen
.length
;
457 txtarea
.selectionEnd
= startPos
+tagOpen
.length
+myText
.length
;
459 txtarea
.scrollTop
= scrollTop
;
461 // All other browsers get no toolbar.
462 // There was previously support for a crippled "help"
463 // bar, but that caused more problems than it solved.
465 // reposition cursor if possible
466 if (txtarea
.createTextRange
) {
467 txtarea
.caretPos
= document
.selection
.createRange().duplicate();
472 if (typeof ta
== "undefined" || !ta
) {
477 if (is_safari
|| navigator
.userAgent
.toLowerCase().indexOf('mac') + 1
478 || navigator
.userAgent
.toLowerCase().indexOf('konqueror') + 1 ) {
480 } else if (is_opera
) {
482 } else if (is_ff2_x11
) {
483 pref
= 'ctrl-shift-';
484 } else if (is_ff2_win
) {
491 var n
= document
.getElementById(id
);
495 // Are we putting accesskey in it
496 if (ta
[id
][0].length
> 0) {
497 // Is this object a object? If not assume it's the next child.
499 if (n
.nodeName
.toLowerCase() == "a") {
504 // Don't add an accesskey for the watch tab if the watch
505 // checkbox is also available.
506 if (a
&& ((id
!= 'ca-watch' && id
!= 'ca-unwatch') ||
507 !(window
.location
.search
.match(/[\?&](action=edit|action=submit)/i)))) {
508 a
.accessKey
= ta
[id
][0];
509 ak
= ' ['+pref
+ta
[id
][0]+']';
512 // We don't care what type the object is when assigning tooltip
518 a
.title
= ta
[id
][1]+ak
;
524 function setupRightClickEdit() {
525 if (document
.getElementsByTagName
) {
526 var spans
= document
.getElementsByTagName('span');
527 for (var i
= 0; i
< spans
.length
; i
++) {
529 if(el
.className
== 'editsection') {
530 addRightClickEditHandler(el
);
536 function addRightClickEditHandler(el
) {
537 for (var i
= 0; i
< el
.childNodes
.length
; i
++) {
538 var link
= el
.childNodes
[i
];
539 if (link
.nodeType
== 1 && link
.nodeName
.toLowerCase() == 'a') {
540 var editHref
= link
.getAttribute('href');
541 // find the enclosing (parent) header
542 var prev
= el
.parentNode
;
543 if (prev
&& prev
.nodeType
== 1 &&
544 prev
.nodeName
.match(/^[Hh][1-6]$/)) {
545 prev
.oncontextmenu = function(e
) {
546 if (!e
) { e
= window
.event
; }
547 // e is now the event in all browsers
549 if (e
.target
) { targ
= e
.target
; }
550 else if (e
.srcElement
) { targ
= e
.srcElement
; }
551 if (targ
.nodeType
== 3) { // defeat Safari bug
552 targ
= targ
.parentNode
;
554 // targ is now the target element
556 // We don't want to deprive the noble reader of a context menu
557 // for the section edit link, do we? (Might want to extend this
559 if (targ
.nodeName
.toLowerCase() != 'a'
560 || targ
.parentNode
.className
!= 'editsection') {
561 document
.location
= editHref
;
571 function setupCheckboxShiftClick() {
572 if (document
.getElementsByTagName
) {
573 var uls
= document
.getElementsByTagName('ul');
574 var len
= uls
.length
;
575 for (var i
= 0; i
< len
; ++i
) {
576 addCheckboxClickHandlers(uls
[i
]);
581 function addCheckboxClickHandlers(ul
, start
, finish
) {
582 if (ul
.checkboxHandlersTimer
) {
583 clearInterval(ul
.checkboxHandlersTimer
);
585 if ( !ul
.childNodes
) {
588 var len
= ul
.childNodes
.length
;
593 finish
= finish
|| start
+ 250;
594 if ( finish
> len
) { finish
= len
; }
595 ul
.checkboxes
= ul
.checkboxes
|| [];
596 ul
.lastCheckbox
= ul
.lastCheckbox
|| null;
597 for (var i
= start
; i
<finish
; ++i
) {
598 var child
= ul
.childNodes
[i
];
599 if ( child
&& child
.childNodes
&& child
.childNodes
[0] ) {
600 var cb
= child
.childNodes
[0];
601 if ( !cb
.nodeName
|| cb
.nodeName
.toLowerCase() != 'input' ||
602 !cb
.type
|| cb
.type
.toLowerCase() != 'checkbox' ) {
605 cb
.index
= ul
.checkboxes
.push(cb
) - 1;
607 cb
.onmouseup
= checkboxMouseupHandler
;
611 var f=function(){ addCheckboxClickHandlers(ul
, finish
, finish
+250); };
612 ul
.checkboxHandlersTimer
=setInterval(f
, 200);
616 function checkboxMouseupHandler(e
) {
617 if (typeof e
== 'undefined') {
620 if ( !e
.shiftKey
|| this.container
.lastCheckbox
=== null ) {
621 this.container
.lastCheckbox
= this.index
;
624 var endState
= !this.checked
;
625 if ( is_opera
) { // opera has already toggled the checkbox by this point
626 endState
= !endState
;
629 if ( this.index
< this.container
.lastCheckbox
) {
630 start
= this.index
+ 1;
631 finish
= this.container
.lastCheckbox
;
633 start
= this.container
.lastCheckbox
;
634 finish
= this.index
- 1;
636 for (var i
= start
; i
<= finish
; ++i
) {
637 this.container
.checkboxes
[i
].checked
= endState
;
639 this.container
.lastCheckbox
= this.index
;
643 function toggle_element_activation(ida
,idb
) {
644 if (!document
.getElementById
) {
647 document
.getElementById(ida
).disabled
=true;
648 document
.getElementById(idb
).disabled
=false;
651 function toggle_element_check(ida
,idb
) {
652 if (!document
.getElementById
) {
655 document
.getElementById(ida
).checked
=true;
656 document
.getElementById(idb
).checked
=false;
659 function fillDestFilename(id
) {
660 if (!document
.getElementById
) {
663 var path
= document
.getElementById(id
).value
;
664 // Find trailing part
665 var slash
= path
.lastIndexOf('/');
666 var backslash
= path
.lastIndexOf('\\');
668 if (slash
== -1 && backslash
== -1) {
670 } else if (slash
> backslash
) {
671 fname
= path
.substring(slash
+1, 10000);
673 fname
= path
.substring(backslash
+1, 10000);
676 // Capitalise first letter and replace spaces by underscores
677 fname
= fname
.charAt(0).toUpperCase().concat(fname
.substring(1,10000)).replace(/ /g
, '_');
680 var destFile
= document
.getElementById('wpDestFile');
682 destFile
.value
= fname
;
687 function considerChangingExpiryFocus() {
688 if (!document
.getElementById
) {
691 var drop
= document
.getElementById('wpBlockExpiry');
695 var field
= document
.getElementById('wpBlockOther');
699 var opt
= drop
.value
;
700 if (opt
== 'other') {
701 field
.style
.display
= '';
703 field
.style
.display
= 'none';
707 function scrollEditBox() {
708 var editBoxEl
= document
.getElementById("wpTextbox1");
709 var scrollTopEl
= document
.getElementById("wpScrolltop");
710 var editFormEl
= document
.getElementById("editform");
712 if (editBoxEl
&& scrollTopEl
) {
713 if (scrollTopEl
.value
) { editBoxEl
.scrollTop
= scrollTopEl
.value
; }
714 editFormEl
.onsubmit = function() {
715 document
.getElementById("wpScrolltop").value
= document
.getElementById("wpTextbox1").scrollTop
;
720 hookEvent("load", scrollEditBox
);
722 function allmessagesfilter() {
723 var text
= document
.getElementById('allmessagesinput').value
;
724 var k
= document
.getElementById('allmessagestable');
727 var items
= k
.getElementsByTagName('span');
730 if ( text
.length
> allmessages_prev
.length
) {
731 for (i
= items
.length
-1, j
= 0; i
>= 0; i
--) {
732 j
= allmessagesforeach(items
, i
, j
, text
);
735 for (i
= 0, j
= 0; i
< items
.length
; i
++) {
736 j
= allmessagesforeach(items
, i
, j
, text
);
739 allmessages_prev
= text
;
742 function allmessagesforeach(items
, i
, j
, text
) {
743 var hItem
= items
[i
].getAttribute('id');
744 if (hItem
.substring(0,17) == 'sp-allmessages-i-') {
745 var itemA
, itemB
, s
, k
;
746 if (items
[i
].firstChild
&& items
[i
].firstChild
.nodeName
== '#text' && items
[i
].firstChild
.nodeValue
.indexOf(text
) != -1) {
747 itemA
= document
.getElementById( hItem
.replace('i', 'r1') );
748 itemB
= document
.getElementById( hItem
.replace('i', 'r2') );
749 if ( itemA
.style
.display
!== '' ) {
750 s
= "allmessageshider(\"" + hItem
.replace('i', 'r1') + "\", \"" + hItem
.replace('i', 'r2') + "\", '')";
751 k
= window
.setTimeout(s
,j
++*5);
754 itemA
= document
.getElementById( hItem
.replace('i', 'r1') );
755 itemB
= document
.getElementById( hItem
.replace('i', 'r2') );
756 if ( itemA
.style
.display
!= 'none' ) {
757 s
= "allmessageshider(\"" + hItem
.replace('i', 'r1') + "\", \"" + hItem
.replace('i', 'r2') + "\", 'none')";
758 k
= window
.setTimeout(s
,j
++*5);
766 function allmessageshider(idA
, idB
, cstyle
) {
767 var itemA
= document
.getElementById( idA
);
768 var itemB
= document
.getElementById( idB
);
769 if (itemA
) { itemA
.style
.display
= cstyle
; }
770 if (itemB
) { itemB
.style
.display
= cstyle
; }
773 function allmessagesmodified() {
774 allmessages_modified
= !allmessages_modified
;
775 var k
= document
.getElementById('allmessagestable');
777 var items
= k
.getElementsByTagName('tr');
778 for (var i
= 0, j
= 0; i
< items
.length
; i
++) {
780 if (!allmessages_modified
) {
781 if ( items
[i
].style
.display
!== '' ) {
782 s
= "allmessageshider(\"" + items
[i
].getAttribute('id') + "\", null, '')";
783 k
= window
.setTimeout(s
,j
++*5);
785 } else if (items
[i
].getAttribute('class') == 'def' && allmessages_modified
) {
786 if ( items
[i
].style
.display
!= 'none' ) {
787 s
= "allmessageshider(\"" + items
[i
].getAttribute('id') + "\", null, 'none')";
788 k
= window
.setTimeout(s
,j
++*5);
794 function allmessagesshow() {
795 var k
= document
.getElementById('allmessagesfilter');
796 if (k
) { k
.style
.display
= ''; }
798 allmessages_prev
= '';
799 allmessages_modified
= false;
802 function runOnloadHook() {
803 // don't run anything below this for non-dom browsers
804 if (doneOnloadHook
|| !(document
.getElementById
&& document
.getElementsByTagName
)) {
813 setupCheckboxShiftClick();
815 // Run any added-on functions
816 for (var i
= 0; i
< onloadFuncts
.length
; i
++) {
820 doneOnloadHook
= true;
823 //note: all skins should call runOnloadHook() at the end of html output,
824 // so the below should be redundant. It's there just in case.
825 hookEvent("load", runOnloadHook
);
827 hookEvent("load", allmessagesshow
);
828 hookEvent("load", mwSetupToolbar
);