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
= [];
24 function addOnloadHook(hookFunct
) {
25 // Allows add-on scripts to add onload functions
26 onloadFuncts
[onloadFuncts
.length
] = hookFunct
;
29 function runOnloadHook() {
30 // don't run anything below this for non-dom browsers
31 if (doneOnloadHook
|| !(document
.getElementById
&& document
.getElementsByTagName
))
39 setupCheckboxShiftClick();
41 // Run any added-on functions
42 for (var i
= 0; i
< onloadFuncts
.length
; i
++)
45 doneOnloadHook
= true;
48 function hookEvent(hookName
, hookFunct
) {
49 if (window
.addEventListener
)
50 addEventListener(hookName
, hookFunct
, false);
51 else if (window
.attachEvent
)
52 attachEvent("on" + hookName
, hookFunct
);
55 //note: all skins shoud call runOnloadHook() at the end of html output,
56 // so the below should be redundant. It's there just in case.
57 hookEvent("load", runOnloadHook
);
59 // document.write special stylesheet links
60 if (typeof stylepath
!= 'undefined' && typeof skin
!= 'undefined') {
61 if (is_opera_preseven
) {
62 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/Opera6Fixes.css">');
63 } else if (is_opera_seven
) {
64 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/Opera7Fixes.css">');
65 } else if (is_khtml
) {
66 document
.write('<link rel="stylesheet" type="text/css" href="'+stylepath
+'/'+skin
+'/KHTMLFixes.css">');
69 // Un-trap us from framesets
70 if (window
.top
!= window
)
71 window
.top
.location
= window
.location
;
73 // for enhanced RecentChanges
74 function toggleVisibility(_levelId
, _otherId
, _linkId
) {
75 var thisLevel
= document
.getElementById(_levelId
);
76 var otherLevel
= document
.getElementById(_otherId
);
77 var linkLevel
= document
.getElementById(_linkId
);
78 if (thisLevel
.style
.display
== 'none') {
79 thisLevel
.style
.display
= 'block';
80 otherLevel
.style
.display
= 'none';
81 linkLevel
.style
.display
= 'inline';
83 thisLevel
.style
.display
= 'none';
84 otherLevel
.style
.display
= 'inline';
85 linkLevel
.style
.display
= 'none';
90 // attach event handlers to the input elements on history page
91 function histrowinit() {
92 var hf
= document
.getElementById('pagehistory');
95 var lis
= hf
.getElementsByTagName('li');
96 for (var i
= 0; i
< lis
.length
; i
++) {
97 var inputs
= historyRadios(lis
[i
]);
98 if (inputs
[0] && inputs
[1]) {
99 inputs
[0].onclick
= diffcheck
;
100 inputs
[1].onclick
= diffcheck
;
106 function historyRadios(parent
) {
107 var inputs
= parent
.getElementsByTagName('input');
109 for (var i
= 0; i
< inputs
.length
; i
++) {
110 if (inputs
[i
].name
== "diff" || inputs
[i
].name
== "oldid")
111 radios
[radios
.length
] = inputs
[i
];
116 // check selection and tweak visibility/class onclick
117 function diffcheck() {
118 var dli
= false; // the li where the diff radio is checked
119 var oli
= false; // the li where the oldid radio is checked
120 var hf
= document
.getElementById('pagehistory');
123 var lis
= hf
.getElementsByTagName('li');
124 for (i
=0;i
<lis
.length
;i
++) {
125 var inputs
= historyRadios(lis
[i
]);
126 if (inputs
[1] && inputs
[0]) {
127 if (inputs
[1].checked
|| inputs
[0].checked
) { // this row has a checked radio button
128 if (inputs
[1].checked
&& inputs
[0].checked
&& inputs
[0].value
== inputs
[1].value
)
130 if (oli
) { // it's the second checked radio
131 if (inputs
[1].checked
) {
132 oli
.className
= "selected";
135 } else if (inputs
[0].checked
) {
138 if (inputs
[0].checked
)
141 inputs
[0].style
.visibility
= 'hidden';
143 inputs
[1].style
.visibility
= 'hidden';
144 lis
[i
].className
= "selected";
146 } else { // no radio is checked in this row
148 inputs
[0].style
.visibility
= 'hidden';
150 inputs
[0].style
.visibility
= 'visible';
152 inputs
[1].style
.visibility
= 'hidden';
154 inputs
[1].style
.visibility
= 'visible';
155 lis
[i
].className
= "";
162 // generate toc from prefs form, fold sections
163 // XXX: needs testing on IE/Mac and safari
164 // more comments to follow
165 function tabbedprefs() {
166 var prefform
= document
.getElementById('preferences');
167 if (!prefform
|| !document
.createElement
)
169 if (prefform
.nodeName
.toLowerCase() == 'a')
170 return; // Occasional IE problem
171 prefform
.className
= prefform
.className
+ 'jsprefs';
172 var sections
= new Array();
173 var children
= prefform
.childNodes
;
175 for (var i
= 0; i
< children
.length
; i
++) {
176 if (children
[i
].nodeName
.toLowerCase() == 'fieldset') {
177 children
[i
].id
= 'prefsection-' + seci
;
178 children
[i
].className
= 'prefsection';
179 if (is_opera
|| is_khtml
)
180 children
[i
].className
= 'prefsection operaprefsection';
181 var legends
= children
[i
].getElementsByTagName('legend');
182 sections
[seci
] = new Object();
183 legends
[0].className
= 'mainLegend';
184 if (legends
[0] && legends
[0].firstChild
.nodeValue
)
185 sections
[seci
].text
= legends
[0].firstChild
.nodeValue
;
187 sections
[seci
].text
= '# ' + seci
;
188 sections
[seci
].secid
= children
[i
].id
;
190 if (sections
.length
!= 1)
191 children
[i
].style
.display
= 'none';
193 var selectedid
= children
[i
].id
;
196 var toc
= document
.createElement('ul');
198 toc
.selectedid
= selectedid
;
199 for (i
= 0; i
< sections
.length
; i
++) {
200 var li
= document
.createElement('li');
202 li
.className
= 'selected';
203 var a
= document
.createElement('a');
204 a
.href
= '#' + sections
[i
].secid
;
205 a
.onmousedown
= a
.onclick
= uncoversection
;
206 a
.appendChild(document
.createTextNode(sections
[i
].text
));
207 a
.secid
= sections
[i
].secid
;
211 prefform
.parentNode
.insertBefore(toc
, prefform
.parentNode
.childNodes
[0]);
212 document
.getElementById('prefsubmit').id
= 'prefcontrol';
215 function uncoversection() {
216 var oldsecid
= this.parentNode
.parentNode
.selectedid
;
217 var newsec
= document
.getElementById(this.secid
);
218 if (oldsecid
!= this.secid
) {
219 var ul
= document
.getElementById('preftoc');
220 document
.getElementById(oldsecid
).style
.display
= 'none';
221 newsec
.style
.display
= 'block';
222 ul
.selectedid
= this.secid
;
223 var lis
= ul
.getElementsByTagName('li');
224 for (var i
= 0; i
< lis
.length
; i
++) {
225 lis
[i
].className
= '';
227 this.parentNode
.className
= 'selected';
233 // tz in format [+-]HHMM
234 function checkTimezone(tz
, msg
) {
235 var localclock
= new Date();
236 // returns negative offset from GMT in minutes
237 var tzRaw
= localclock
.getTimezoneOffset();
238 var tzHour
= Math
.floor( Math
.abs(tzRaw
) / 60);
239 var tzMin
= Math
.abs(tzRaw
) % 60;
240 var tzString
= ((tzRaw
>= 0) ? "-" : "+") + ((tzHour
< 10) ? "0" : "") + tzHour
+ ((tzMin
< 10) ? "0" : "") + tzMin
;
241 if (tz
!= tzString
) {
242 var junk
= msg
.split('$1');
243 document
.write(junk
[0] + "UTC" + tzString
+ junk
[1]);
247 function unhidetzbutton() {
248 var tzb
= document
.getElementById('guesstimezonebutton');
250 tzb
.style
.display
= 'inline';
253 // in [-]HH:MM format...
254 // won't yet work with non-even tzs
255 function fetchTimezone() {
256 // FIXME: work around Safari bug
257 var localclock
= new Date();
258 // returns negative offset from GMT in minutes
259 var tzRaw
= localclock
.getTimezoneOffset();
260 var tzHour
= Math
.floor( Math
.abs(tzRaw
) / 60);
261 var tzMin
= Math
.abs(tzRaw
) % 60;
262 var tzString
= ((tzRaw
>= 0) ? "-" : "") + ((tzHour
< 10) ? "0" : "") + tzHour
+
263 ":" + ((tzMin
< 10) ? "0" : "") + tzMin
;
267 function guessTimezone(box
) {
268 document
.getElementsByName("wpHourDiff")[0].value
= fetchTimezone();
271 function showTocToggle() {
272 if (document
.createTextNode
) {
273 // Uses DOM calls to avoid document.write + XHTML issues
275 var linkHolder
= document
.getElementById('toctitle')
279 var outerSpan
= document
.createElement('span');
280 outerSpan
.className
= 'toctoggle';
282 var toggleLink
= document
.createElement('a');
283 toggleLink
.id
= 'togglelink';
284 toggleLink
.className
= 'internal';
285 toggleLink
.href
= 'javascript:toggleToc()';
286 toggleLink
.appendChild(document
.createTextNode(tocHideText
));
288 outerSpan
.appendChild(document
.createTextNode('['));
289 outerSpan
.appendChild(toggleLink
);
290 outerSpan
.appendChild(document
.createTextNode(']'));
292 linkHolder
.appendChild(document
.createTextNode(' '));
293 linkHolder
.appendChild(outerSpan
);
295 var cookiePos
= document
.cookie
.indexOf("hidetoc=");
296 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
;
309 function toggleToc() {
310 var toc
= document
.getElementById('toc').getElementsByTagName('ul')[0];
311 var toggleLink
= document
.getElementById('togglelink')
313 if (toc
&& toggleLink
&& toc
.style
.display
== 'none') {
314 changeText(toggleLink
, tocHideText
);
315 toc
.style
.display
= 'block';
316 document
.cookie
= "hidetoc=0";
318 changeText(toggleLink
, tocShowText
);
319 toc
.style
.display
= 'none';
320 document
.cookie
= "hidetoc=1";
324 var mwEditButtons
= [];
325 var mwCustomEditButtons
= []; // eg to add in MediaWiki:Common.js
327 // this function generates the actual toolbar buttons with localized text
328 // we use it to avoid creating the toolbar where javascript is not enabled
329 function addButton(imageFile
, speedTip
, tagOpen
, tagClose
, sampleText
) {
330 // Don't generate buttons for browsers which don't fully
332 mwEditButtons
[mwEditButtons
.length
] =
333 {"imageFile": imageFile
,
334 "speedTip": speedTip
,
336 "tagClose": tagClose
,
337 "sampleText": sampleText
};
340 // this function generates the actual toolbar buttons with localized text
341 // we use it to avoid creating the toolbar where javascript is not enabled
342 function mwInsertEditButton(parent
, item
) {
343 var image
= document
.createElement("img");
346 image
.src
= item
.imageFile
;
348 image
.alt
= item
.speedTip
;
349 image
.title
= item
.speedTip
;
350 image
.style
.cursor
= "pointer";
351 image
.onclick = function() {
352 insertTags(item
.tagOpen
, item
.tagClose
, item
.sampleText
);
356 parent
.appendChild(image
);
360 function mwSetupToolbar() {
361 var toolbar
= document
.getElementById('toolbar');
362 if (!toolbar
) return false;
364 var textbox
= document
.getElementById('wpTextbox1');
365 if (!textbox
) return false;
367 // Don't generate buttons for browsers which don't fully
369 if (!document
.selection
&& textbox
.selectionStart
== null)
372 for (var i
in mwEditButtons
) {
373 mwInsertEditButton(toolbar
, mwEditButtons
[i
]);
375 for (var 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 var re
= new RegExp('"',"g");
393 text
= text
.replace(re
,""");
394 var re
= new RegExp('<',"g");
395 text
= text
.replace(re
,"<");
396 var 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
) {
405 if (document
.editform
)
406 var txtarea
= document
.editform
.wpTextbox1
;
408 // some alternate form? take the first one we can find
409 var areas
= document
.getElementsByTagName('textarea');
410 var txtarea
= areas
[0];
414 if (document
.selection
&& !is_gecko
) {
415 var theSelection
= document
.selection
.createRange().text
;
417 theSelection
=sampleText
;
419 if (theSelection
.charAt(theSelection
.length
- 1) == " ") { // exclude ending space char, if any
420 theSelection
= theSelection
.substring(0, theSelection
.length
- 1);
421 document
.selection
.createRange().text
= tagOpen
+ theSelection
+ tagClose
+ " ";
423 document
.selection
.createRange().text
= tagOpen
+ theSelection
+ tagClose
;
427 } else if(txtarea
.selectionStart
|| txtarea
.selectionStart
== '0') {
428 var replaced
= false;
429 var startPos
= txtarea
.selectionStart
;
430 var endPos
= txtarea
.selectionEnd
;
433 var scrollTop
= txtarea
.scrollTop
;
434 var myText
= (txtarea
.value
).substring(startPos
, endPos
);
437 if (myText
.charAt(myText
.length
- 1) == " ") { // exclude ending space char, if any
438 subst
= tagOpen
+ myText
.substring(0, (myText
.length
- 1)) + tagClose
+ " ";
440 subst
= tagOpen
+ myText
+ tagClose
;
442 txtarea
.value
= txtarea
.value
.substring(0, startPos
) + subst
+
443 txtarea
.value
.substring(endPos
, txtarea
.value
.length
);
447 var cPos
= startPos
+(tagOpen
.length
+myText
.length
+tagClose
.length
);
448 txtarea
.selectionStart
= cPos
;
449 txtarea
.selectionEnd
= cPos
;
451 txtarea
.selectionStart
= startPos
+tagOpen
.length
;
452 txtarea
.selectionEnd
= startPos
+tagOpen
.length
+myText
.length
;
454 txtarea
.scrollTop
= scrollTop
;
456 // All other browsers get no toolbar.
457 // There was previously support for a crippled "help"
458 // bar, but that caused more problems than it solved.
460 // reposition cursor if possible
461 if (txtarea
.createTextRange
)
462 txtarea
.caretPos
= document
.selection
.createRange().duplicate();
466 if (typeof ta
== "undefined" || !ta
)
468 if (is_safari
|| navigator
.userAgent
.toLowerCase().indexOf('mac') + 1
469 || navigator
.userAgent
.toLowerCase().indexOf('konqueror') + 1 )
474 pref
= 'ctrl-shift-';
481 var n
= document
.getElementById(id
);
485 // Are we putting accesskey in it
486 if (ta
[id
][0].length
> 0) {
487 // Is this object a object? If not assume it's the next child.
489 if (n
.nodeName
.toLowerCase() == "a") {
494 // Don't add an accesskey for the watch tab if the watch
495 // checkbox is also available.
496 if (a
&& ((id
!= 'ca-watch' && id
!= 'ca-unwatch') ||
497 !(window
.location
.search
.match(/[\?&](action=edit|action=submit)/i)))) {
498 a
.accessKey
= ta
[id
][0];
499 ak
= ' ['+pref
+ta
[id
][0]+']';
502 // We don't care what type the object is when assigning tooltip
508 a
.title
= ta
[id
][1]+ak
;
514 function setupRightClickEdit() {
515 if (document
.getElementsByTagName
) {
516 var spans
= document
.getElementsByTagName('span');
517 for (var i
= 0; i
< spans
.length
; i
++) {
519 if(el
.className
== 'editsection') {
520 addRightClickEditHandler(el
);
526 function addRightClickEditHandler(el
) {
527 for (var i
= 0; i
< el
.childNodes
.length
; i
++) {
528 var link
= el
.childNodes
[i
];
529 if (link
.nodeType
== 1 && link
.nodeName
.toLowerCase() == 'a') {
530 var editHref
= link
.getAttribute('href');
531 // find the enclosing (parent) header
532 var prev
= el
.parentNode
;
533 if (prev
&& prev
.nodeType
== 1 &&
534 prev
.nodeName
.match(/^[Hh][1-6]$/)) {
535 prev
.oncontextmenu = function(e
) {
536 if (!e
) e
= window
.event
;
537 // e is now the event in all browsers
538 if (e
.target
) var targ
= e
.target
;
539 else if (e
.srcElement
) var targ
= e
.srcElement
;
540 if (targ
.nodeType
== 3) // defeat Safari bug
541 targ
= targ
.parentNode
;
542 // targ is now the target element
544 // We don't want to deprive the noble reader of a context menu
545 // for the section edit link, do we? (Might want to extend this
547 if (targ
.nodeName
.toLowerCase() != 'a'
548 || targ
.parentNode
.className
!= 'editsection') {
549 document
.location
= editHref
;
558 function addRightClickEditHandler(el) {
559 // find the enclosing (parent) header
560 var par = el.parentNode;
561 if (par && par.nodeType == 1 && par.nodeName.match(/^[Hh][1-6]$/)) {
562 par.oncontextmenu = function(e) {
563 if (!e) var e = window.event;
564 // e is now the event in all browsers
565 if (e.target) targ = e.target;
566 else if (e.srcElement) targ = e.srcElement;
567 if (targ.nodeType == 3) // defeat Safari bug
568 targ = targ.parentNode;
569 // targ is now the target element
570 // We don't want to deprive the noble reader of a context menu
571 // for the section edit link, do we? (Might want to extend this
572 // to all <a>'s.)links
573 if (targ.className != 'editsection') {
574 document.location = editHref;
582 function setupCheckboxShiftClick() {
583 if (document
.getElementsByTagName
) {
584 var uls
= document
.getElementsByTagName('ul');
585 var len
= uls
.length
;
586 for (var i
= 0; i
< len
; ++i
) {
587 addCheckboxClickHandlers(uls
[i
]);
592 function addCheckboxClickHandlers(ul
, start
, finish
) {
593 if (ul
.checkboxHandlersTimer
) {
594 clearInterval(ul
.checkboxHandlersTimer
);
596 if ( !ul
.childNodes
) {
599 var len
= ul
.childNodes
.length
;
604 finish
= finish
|| start
+ 250;
605 if ( finish
> len
) { finish
= len
; }
606 ul
.checkboxes
= ul
.checkboxes
|| [];
607 ul
.lastCheckbox
= ul
.lastCheckbox
|| null;
608 for (var i
= start
; i
<finish
; ++i
) {
609 var child
= ul
.childNodes
[i
];
610 if ( child
&& child
.childNodes
&& child
.childNodes
[0] ) {
611 var cb
= child
.childNodes
[0];
612 if ( !cb
.nodeName
|| cb
.nodeName
.toLowerCase() != 'input' ||
613 !cb
.type
|| cb
.type
.toLowerCase() != 'checkbox' ) {
616 cb
.index
= ul
.checkboxes
.push(cb
) - 1;
618 cb
.onmouseup
= checkboxMouseupHandler
;
622 var f=function(){ addCheckboxClickHandlers(ul
, finish
, finish
+250); };
623 ul
.checkboxHandlersTimer
=setInterval(f
, 200);
627 function checkboxMouseupHandler(e
) {
628 if (typeof e
== 'undefined') {
631 if ( !e
.shiftKey
|| this.container
.lastCheckbox
=== null ) {
632 this.container
.lastCheckbox
= this.index
;
635 var endState
= !this.checked
;
636 if ( is_opera
) { // opera has already toggled the checkbox by this point
637 endState
= !endState
;
640 if ( this.index
< this.container
.lastCheckbox
) {
641 start
= this.index
+ 1;
642 finish
= this.container
.lastCheckbox
;
644 start
= this.container
.lastCheckbox
;
645 finish
= this.index
- 1;
647 for (var i
= start
; i
<= finish
; ++i
) {
648 this.container
.checkboxes
[i
].checked
= endState
;
650 this.container
.lastCheckbox
= this.index
;
654 function toggle_element_activation(ida
,idb
) {
655 if (!document
.getElementById
)
657 document
.getElementById(ida
).disabled
=true;
658 document
.getElementById(idb
).disabled
=false;
661 function toggle_element_check(ida
,idb
) {
662 if (!document
.getElementById
)
664 document
.getElementById(ida
).checked
=true;
665 document
.getElementById(idb
).checked
=false;
668 function fillDestFilename(id
) {
669 if (!document
.getElementById
)
671 var path
= document
.getElementById(id
).value
;
672 // Find trailing part
673 var slash
= path
.lastIndexOf('/');
674 var backslash
= path
.lastIndexOf('\\');
676 if (slash
== -1 && backslash
== -1) {
678 } else if (slash
> backslash
) {
679 fname
= path
.substring(slash
+1, 10000);
681 fname
= path
.substring(backslash
+1, 10000);
684 // Capitalise first letter and replace spaces by underscores
685 fname
= fname
.charAt(0).toUpperCase().concat(fname
.substring(1,10000)).replace(/ /g
, '_');
688 var destFile
= document
.getElementById('wpDestFile');
690 destFile
.value
= fname
;
694 function considerChangingExpiryFocus() {
695 if (!document
.getElementById
)
697 var drop
= document
.getElementById('wpBlockExpiry');
700 var field
= document
.getElementById('wpBlockOther');
703 var opt
= drop
.value
;
705 field
.style
.display
= '';
707 field
.style
.display
= 'none';
710 function scrollEditBox() {
711 var editBoxEl
= document
.getElementById("wpTextbox1");
712 var scrollTopEl
= document
.getElementById("wpScrolltop");
713 var editFormEl
= document
.getElementById("editform");
715 if (editBoxEl
&& scrollTopEl
) {
716 if (scrollTopEl
.value
) editBoxEl
.scrollTop
= scrollTopEl
.value
;
717 editFormEl
.onsubmit = function() {
718 document
.getElementById("wpScrolltop").value
= document
.getElementById("wpTextbox1").scrollTop
;
723 hookEvent("load", scrollEditBox
);
725 function allmessagesfilter() {
726 text
= document
.getElementById('allmessagesinput').value
;
727 k
= document
.getElementById('allmessagestable');
730 var items
= k
.getElementsByTagName('span');
732 if ( text
.length
> allmessages_prev
.length
) {
733 for (var i
= items
.length
-1, j
= 0; i
>= 0; i
--) {
734 j
= allmessagesforeach(items
, i
, j
);
737 for (var i
= 0, j
= 0; i
< items
.length
; i
++) {
738 j
= allmessagesforeach(items
, i
, j
);
741 allmessages_prev
= text
;
744 function allmessagesforeach(items
, i
, j
) {
745 var hItem
= items
[i
].getAttribute('id');
746 if (hItem
.substring(0,17) == 'sp-allmessages-i-') {
747 if (items
[i
].firstChild
&& items
[i
].firstChild
.nodeName
== '#text' && items
[i
].firstChild
.nodeValue
.indexOf(text
) != -1) {
748 var itemA
= document
.getElementById( hItem
.replace('i', 'r1') );
749 var itemB
= document
.getElementById( hItem
.replace('i', 'r2') );
750 if ( itemA
.style
.display
!= '' ) {
751 var s
= "allmessageshider(\"" + hItem
.replace('i', 'r1') + "\", \"" + hItem
.replace('i', 'r2') + "\", '')";
752 var k
= window
.setTimeout(s
,j
++*5);
755 var itemA
= document
.getElementById( hItem
.replace('i', 'r1') );
756 var itemB
= document
.getElementById( hItem
.replace('i', 'r2') );
757 if ( itemA
.style
.display
!= 'none' ) {
758 var s
= "allmessageshider(\"" + hItem
.replace('i', 'r1') + "\", \"" + hItem
.replace('i', 'r2') + "\", 'none')";
759 var k
= window
.setTimeout(s
,j
++*5);
767 function allmessageshider(idA
, idB
, cstyle
) {
768 var itemA
= document
.getElementById( idA
);
769 var itemB
= document
.getElementById( idB
);
770 if (itemA
) { itemA
.style
.display
= cstyle
; }
771 if (itemB
) { itemB
.style
.display
= cstyle
; }
774 function allmessagesmodified() {
775 allmessages_modified
= !allmessages_modified
;
776 k
= document
.getElementById('allmessagestable');
778 var items
= k
.getElementsByTagName('tr');
779 for (var i
= 0, j
= 0; i
< items
.length
; i
++) {
780 if (!allmessages_modified
) {
781 if ( items
[i
].style
.display
!= '' ) {
782 var s
= "allmessageshider(\"" + items
[i
].getAttribute('id') + "\", null, '')";
783 var k
= window
.setTimeout(s
,j
++*5);
785 } else if (items
[i
].getAttribute('class') == 'def' && allmessages_modified
) {
786 if ( items
[i
].style
.display
!= 'none' ) {
787 var s
= "allmessageshider(\"" + items
[i
].getAttribute('id') + "\", null, 'none')";
788 var k
= window
.setTimeout(s
,j
++*5);
794 function allmessagesshow() {
795 k
= document
.getElementById('allmessagesfilter');
796 if (k
) { k
.style
.display
= ''; }
798 allmessages_prev
= '';
799 allmessages_modified
= false;
802 hookEvent("load", allmessagesshow
);
803 hookEvent("load", mwSetupToolbar
);