0cfb6002a7e259b2540692ba0f40a55b5d15ff0b
[lhc/web/wiklou.git] / skins / common / wikibits.js
1 // MediaWiki JavaScript support functions
2
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 ));
8 if (clientPC.indexOf('opera') != -1) {
9 var is_opera = true;
10 var is_opera_preseven = (window.opera && !document.childNodes);
11 var is_opera_seven = (window.opera && document.childNodes);
12 }
13
14 // add any onload functions in this hook (please don't hard-code any events in the xhtml source)
15
16 var doneOnloadHook;
17
18 if (!window.onloadFuncts)
19 var onloadFuncts = [];
20
21 function addOnloadHook(hookFunct) {
22 // Allows add-on scripts to add onload functions
23 onloadFuncts[onloadFuncts.length] = hookFunct;
24 }
25
26 function runOnloadHook() {
27 // don't run anything below this for non-dom browsers
28 if (doneOnloadHook || !(document.getElementById && document.getElementsByTagName))
29 return;
30
31 histrowinit();
32 unhidetzbutton();
33 tabbedprefs();
34 akeytt();
35 scrollEditBox();
36 setupCheckboxShiftClick();
37
38 // Run any added-on functions
39 for (var i = 0; i < onloadFuncts.length; i++)
40 onloadFuncts[i]();
41
42 doneOnloadHook = true;
43 }
44
45 function hookEvent(hookName, hookFunct) {
46 if (window.addEventListener)
47 addEventListener(hookName, hookFunct, false);
48 else if (window.attachEvent)
49 attachEvent("on" + hookName, hookFunct);
50 }
51
52 //note: all skins shoud call runOnloadHook() at the end of html output,
53 // so the below should be redundant. It's there just in case.
54 hookEvent("load", runOnloadHook);
55
56 // document.write special stylesheet links
57 if (typeof stylepath != 'undefined' && typeof skin != 'undefined') {
58 if (is_opera_preseven) {
59 document.write('<link rel="stylesheet" type="text/css" href="'+stylepath+'/'+skin+'/Opera6Fixes.css">');
60 } else if (is_opera_seven) {
61 document.write('<link rel="stylesheet" type="text/css" href="'+stylepath+'/'+skin+'/Opera7Fixes.css">');
62 } else if (is_khtml) {
63 document.write('<link rel="stylesheet" type="text/css" href="'+stylepath+'/'+skin+'/KHTMLFixes.css">');
64 }
65 }
66 // Un-trap us from framesets
67 if (window.top != window)
68 window.top.location = window.location;
69
70 // for enhanced RecentChanges
71 function toggleVisibility(_levelId, _otherId, _linkId) {
72 var thisLevel = document.getElementById(_levelId);
73 var otherLevel = document.getElementById(_otherId);
74 var linkLevel = document.getElementById(_linkId);
75 if (thisLevel.style.display == 'none') {
76 thisLevel.style.display = 'block';
77 otherLevel.style.display = 'none';
78 linkLevel.style.display = 'inline';
79 } else {
80 thisLevel.style.display = 'none';
81 otherLevel.style.display = 'inline';
82 linkLevel.style.display = 'none';
83 }
84 }
85
86 // page history stuff
87 // attach event handlers to the input elements on history page
88 function histrowinit() {
89 var hf = document.getElementById('pagehistory');
90 if (!hf)
91 return;
92 var lis = hf.getElementsByTagName('li');
93 for (var i = 0; i < lis.length; i++) {
94 var inputs = historyRadios(lis[i]);
95 if (inputs[0] && inputs[1]) {
96 inputs[0].onclick = diffcheck;
97 inputs[1].onclick = diffcheck;
98 }
99 }
100 diffcheck();
101 }
102
103 function historyRadios(parent) {
104 var inputs = parent.getElementsByTagName('input');
105 var radios = [];
106 for (var i = 0; i < inputs.length; i++) {
107 if (inputs[i].name == "diff" || inputs[i].name == "oldid")
108 radios[radios.length] = inputs[i];
109 }
110 return radios;
111 }
112
113 // check selection and tweak visibility/class onclick
114 function diffcheck() {
115 var dli = false; // the li where the diff radio is checked
116 var oli = false; // the li where the oldid radio is checked
117 var hf = document.getElementById('pagehistory');
118 if (!hf)
119 return true;
120 var lis = hf.getElementsByTagName('li');
121 for (i=0;i<lis.length;i++) {
122 var inputs = historyRadios(lis[i]);
123 if (inputs[1] && inputs[0]) {
124 if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button
125 if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value)
126 return false;
127 if (oli) { // it's the second checked radio
128 if (inputs[1].checked) {
129 oli.className = "selected";
130 return false;
131 }
132 } else if (inputs[0].checked) {
133 return false;
134 }
135 if (inputs[0].checked)
136 dli = lis[i];
137 if (!oli)
138 inputs[0].style.visibility = 'hidden';
139 if (dli)
140 inputs[1].style.visibility = 'hidden';
141 lis[i].className = "selected";
142 oli = lis[i];
143 } else { // no radio is checked in this row
144 if (!oli)
145 inputs[0].style.visibility = 'hidden';
146 else
147 inputs[0].style.visibility = 'visible';
148 if (dli)
149 inputs[1].style.visibility = 'hidden';
150 else
151 inputs[1].style.visibility = 'visible';
152 lis[i].className = "";
153 }
154 }
155 }
156 return true;
157 }
158
159 // generate toc from prefs form, fold sections
160 // XXX: needs testing on IE/Mac and safari
161 // more comments to follow
162 function tabbedprefs() {
163 var prefform = document.getElementById('preferences');
164 if (!prefform || !document.createElement)
165 return;
166 if (prefform.nodeName.toLowerCase() == 'a')
167 return; // Occasional IE problem
168 prefform.className = prefform.className + 'jsprefs';
169 var sections = new Array();
170 var children = prefform.childNodes;
171 var seci = 0;
172 for (var i = 0; i < children.length; i++) {
173 if (children[i].nodeName.toLowerCase() == 'fieldset') {
174 children[i].id = 'prefsection-' + seci;
175 children[i].className = 'prefsection';
176 if (is_opera || is_khtml)
177 children[i].className = 'prefsection operaprefsection';
178 var legends = children[i].getElementsByTagName('legend');
179 sections[seci] = new Object();
180 legends[0].className = 'mainLegend';
181 if (legends[0] && legends[0].firstChild.nodeValue)
182 sections[seci].text = legends[0].firstChild.nodeValue;
183 else
184 sections[seci].text = '# ' + seci;
185 sections[seci].secid = children[i].id;
186 seci++;
187 if (sections.length != 1)
188 children[i].style.display = 'none';
189 else
190 var selectedid = children[i].id;
191 }
192 }
193 var toc = document.createElement('ul');
194 toc.id = 'preftoc';
195 toc.selectedid = selectedid;
196 for (i = 0; i < sections.length; i++) {
197 var li = document.createElement('li');
198 if (i == 0)
199 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;
205 li.appendChild(a);
206 toc.appendChild(li);
207 }
208 prefform.parentNode.insertBefore(toc, prefform.parentNode.childNodes[0]);
209 document.getElementById('prefsubmit').id = 'prefcontrol';
210 }
211
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 = '';
223 }
224 this.parentNode.className = 'selected';
225 }
226 return false;
227 }
228
229 // Timezone stuff
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]);
241 }
242 }
243
244 function unhidetzbutton() {
245 var tzb = document.getElementById('guesstimezonebutton');
246 if (tzb)
247 tzb.style.display = 'inline';
248 }
249
250 // in [-]HH:MM format...
251 // won't yet work with non-even tzs
252 function fetchTimezone() {
253 // FIXME: work around Safari bug
254 var localclock = new Date();
255 // returns negative offset from GMT in minutes
256 var tzRaw = localclock.getTimezoneOffset();
257 var tzHour = Math.floor( Math.abs(tzRaw) / 60);
258 var tzMin = Math.abs(tzRaw) % 60;
259 var tzString = ((tzRaw >= 0) ? "-" : "") + ((tzHour < 10) ? "0" : "") + tzHour +
260 ":" + ((tzMin < 10) ? "0" : "") + tzMin;
261 return tzString;
262 }
263
264 function guessTimezone(box) {
265 document.getElementsByName("wpHourDiff")[0].value = fetchTimezone();
266 }
267
268 function showTocToggle() {
269 if (document.createTextNode) {
270 // Uses DOM calls to avoid document.write + XHTML issues
271
272 var linkHolder = document.getElementById('toctitle')
273 if (!linkHolder)
274 return;
275
276 var outerSpan = document.createElement('span');
277 outerSpan.className = 'toctoggle';
278
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));
284
285 outerSpan.appendChild(document.createTextNode('['));
286 outerSpan.appendChild(toggleLink);
287 outerSpan.appendChild(document.createTextNode(']'));
288
289 linkHolder.appendChild(document.createTextNode(' '));
290 linkHolder.appendChild(outerSpan);
291
292 var cookiePos = document.cookie.indexOf("hidetoc=");
293 if (cookiePos > -1 && document.cookie.charAt(cookiePos + 8) == 1)
294 toggleToc();
295 }
296 }
297
298 function changeText(el, newText) {
299 // Safari work around
300 if (el.innerText)
301 el.innerText = newText;
302 else if (el.firstChild && el.firstChild.nodeValue)
303 el.firstChild.nodeValue = newText;
304 }
305
306 function toggleToc() {
307 var toc = document.getElementById('toc').getElementsByTagName('ul')[0];
308 var toggleLink = document.getElementById('togglelink')
309
310 if (toc && toggleLink && toc.style.display == 'none') {
311 changeText(toggleLink, tocHideText);
312 toc.style.display = 'block';
313 document.cookie = "hidetoc=0";
314 } else {
315 changeText(toggleLink, tocShowText);
316 toc.style.display = 'none';
317 document.cookie = "hidetoc=1";
318 }
319 }
320
321 var mwEditButtons = [];
322 var mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
323
324 // this function generates the actual toolbar buttons with localized text
325 // we use it to avoid creating the toolbar where javascript is not enabled
326 function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText) {
327 // Don't generate buttons for browsers which don't fully
328 // support it.
329 mwEditButtons[mwEditButtons.length] =
330 {"imageFile": imageFile,
331 "speedTip": speedTip,
332 "tagOpen": tagOpen,
333 "tagClose": tagClose,
334 "sampleText": sampleText};
335 }
336
337 // this function generates the actual toolbar buttons with localized text
338 // we use it to avoid creating the toolbar where javascript is not enabled
339 function mwInsertEditButton(parent, item) {
340 var image = document.createElement("img");
341 image.width = 23;
342 image.height = 22;
343 image.src = item.imageFile;
344 image.border = 0;
345 image.alt = item.speedTip;
346 image.title = item.speedTip;
347 image.style.cursor = "pointer";
348 image.onclick = function() {
349 insertTags(item.tagOpen, item.tagClose, item.sampleText);
350 return false;
351 }
352
353 parent.appendChild(image);
354 return true;
355 }
356
357 function mwSetupToolbar() {
358 var toolbar = document.getElementById('toolbar');
359 if (!toolbar) return false;
360
361 var textbox = document.getElementById('wpTextbox1');
362 if (!textbox) return false;
363
364 // Don't generate buttons for browsers which don't fully
365 // support it.
366 if (!document.selection && textbox.selectionStart == null)
367 return false;
368
369 for (var i in mwEditButtons) {
370 mwInsertEditButton(toolbar, mwEditButtons[i]);
371 }
372 for (var i in mwCustomEditButtons) {
373 mwInsertEditButton(toolbar, mwCustomEditButtons[i]);
374 }
375 return true;
376 }
377
378 function escapeQuotes(text) {
379 var re = new RegExp("'","g");
380 text = text.replace(re,"\\'");
381 re = new RegExp("\\n","g");
382 text = text.replace(re,"\\n");
383 return escapeQuotesHTML(text);
384 }
385
386 function escapeQuotesHTML(text) {
387 var re = new RegExp('&',"g");
388 text = text.replace(re,"&amp;");
389 var re = new RegExp('"',"g");
390 text = text.replace(re,"&quot;");
391 var re = new RegExp('<',"g");
392 text = text.replace(re,"&lt;");
393 var re = new RegExp('>',"g");
394 text = text.replace(re,"&gt;");
395 return text;
396 }
397
398 // apply tagOpen/tagClose to selection in textarea,
399 // use sampleText instead of selection if there is none
400 // copied and adapted from phpBB
401 function insertTags(tagOpen, tagClose, sampleText) {
402 if (document.editform)
403 var txtarea = document.editform.wpTextbox1;
404 else {
405 // some alternate form? take the first one we can find
406 var areas = document.getElementsByTagName('textarea');
407 var txtarea = areas[0];
408 }
409
410 // IE
411 if (document.selection && !is_gecko) {
412 var theSelection = document.selection.createRange().text;
413 if (!theSelection)
414 theSelection=sampleText;
415 txtarea.focus();
416 if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
417 theSelection = theSelection.substring(0, theSelection.length - 1);
418 document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
419 } else {
420 document.selection.createRange().text = tagOpen + theSelection + tagClose;
421 }
422
423 // Mozilla
424 } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
425 var replaced = false;
426 var startPos = txtarea.selectionStart;
427 var endPos = txtarea.selectionEnd;
428 if (endPos-startPos)
429 replaced = true;
430 var scrollTop = txtarea.scrollTop;
431 var myText = (txtarea.value).substring(startPos, endPos);
432 if (!myText)
433 myText=sampleText;
434 if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
435 subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
436 } else {
437 subst = tagOpen + myText + tagClose;
438 }
439 txtarea.value = txtarea.value.substring(0, startPos) + subst +
440 txtarea.value.substring(endPos, txtarea.value.length);
441 txtarea.focus();
442 //set new selection
443 if (replaced) {
444 var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
445 txtarea.selectionStart = cPos;
446 txtarea.selectionEnd = cPos;
447 } else {
448 txtarea.selectionStart = startPos+tagOpen.length;
449 txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
450 }
451 txtarea.scrollTop = scrollTop;
452
453 // All other browsers get no toolbar.
454 // There was previously support for a crippled "help"
455 // bar, but that caused more problems than it solved.
456 }
457 // reposition cursor if possible
458 if (txtarea.createTextRange)
459 txtarea.caretPos = document.selection.createRange().duplicate();
460 }
461
462 function akeytt() {
463 if (typeof ta == "undefined" || !ta)
464 return;
465 var pref = 'alt-';
466 if (is_safari || navigator.userAgent.toLowerCase().indexOf('mac') + 1
467 || navigator.userAgent.toLowerCase().indexOf('konqueror') + 1 )
468 pref = 'control-';
469 if (is_opera)
470 pref = 'shift-esc-';
471
472 for (var id in ta) {
473 var n = document.getElementById(id);
474 if (n) {
475 var a = null;
476 var ak = '';
477 // Are we putting accesskey in it
478 if (ta[id][0].length > 0) {
479 // Is this object a object? If not assume it's the next child.
480
481 if (n.nodeName.toLowerCase() == "a") {
482 a = n;
483 } else {
484 a = n.childNodes[0];
485 }
486
487 if (a) {
488 a.accessKey = ta[id][0];
489 ak = ' ['+pref+ta[id][0]+']';
490 }
491 } else {
492 // We don't care what type the object is when assigning tooltip
493 a = n;
494 ak = '';
495 }
496
497 if (a) {
498 a.title = ta[id][1]+ak;
499 }
500 }
501 }
502 }
503
504 function setupRightClickEdit() {
505 if (document.getElementsByTagName) {
506 var divs = document.getElementsByTagName('div');
507 for (var i = 0; i < divs.length; i++) {
508 var el = divs[i];
509 if(el.className == 'editsection') {
510 addRightClickEditHandler(el);
511 }
512 }
513 }
514 }
515
516 function addRightClickEditHandler(el) {
517 for (var i = 0; i < el.childNodes.length; i++) {
518 var link = el.childNodes[i];
519 if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') {
520 var editHref = link.getAttribute('href');
521
522 // find the following a
523 var next = el.nextSibling;
524 while (next.nodeType != 1)
525 next = next.nextSibling;
526
527 // find the following header
528 next = next.nextSibling;
529 while (next.nodeType != 1)
530 next = next.nextSibling;
531
532 if (next && next.nodeType == 1 &&
533 next.nodeName.match(/^[Hh][1-6]$/)) {
534 next.oncontextmenu = function() {
535 document.location = editHref;
536 return false;
537 }
538 }
539 }
540 }
541 }
542
543 function setupCheckboxShiftClick() {
544 if (document.getElementsByTagName) {
545 var uls = document.getElementsByTagName('ul');
546 var len = uls.length;
547 for (var i = 0; i < len; ++i) {
548 addCheckboxClickHandlers(uls[i]);
549 }
550 }
551 }
552
553 function addCheckboxClickHandlers(ul, start, finish) {
554 if (ul.checkboxHandlersTimer) {
555 clearInterval(ul.checkboxHandlersTimer);
556 }
557 if ( !ul.childNodes ) {
558 return;
559 }
560 var len = ul.childNodes.length;
561 if (len < 2) {
562 return;
563 }
564 start = start || 0;
565 finish = finish || start + 250;
566 if ( finish > len ) { finish = len; }
567 ul.checkboxes = ul.checkboxes || [];
568 ul.lastCheckbox = ul.lastCheckbox || null;
569 for (var i = start; i<finish; ++i) {
570 var child = ul.childNodes[i];
571 if ( child && child.childNodes && child.childNodes[0] ) {
572 var cb = child.childNodes[0];
573 if ( !cb.nodeName || cb.nodeName.toLowerCase() != 'input' ||
574 !cb.type || cb.type.toLowerCase() != 'checkbox' ) {
575 return;
576 }
577 cb.index = ul.checkboxes.push(cb) - 1;
578 cb.container = ul;
579 cb.onmouseup = checkboxMouseupHandler;
580 }
581 }
582 if (finish < len) {
583 var f=function(){ addCheckboxClickHandlers(ul, finish, finish+250); };
584 ul.checkboxHandlersTimer=setInterval(f, 200);
585 }
586 }
587
588 function checkboxMouseupHandler(e) {
589 if (typeof e == 'undefined') {
590 e = window.event;
591 }
592 if ( !e.shiftKey || this.container.lastCheckbox === null ) {
593 this.container.lastCheckbox = this.index;
594 return true;
595 }
596 var endState = !this.checked;
597 if ( is_opera ) { // opera has already toggled the checkbox by this point
598 endState = !endState;
599 }
600 var start, finish;
601 if ( this.index < this.container.lastCheckbox ) {
602 start = this.index + 1;
603 finish = this.container.lastCheckbox;
604 } else {
605 start = this.container.lastCheckbox;
606 finish = this.index - 1;
607 }
608 for (var i = start; i <= finish; ++i ) {
609 this.container.checkboxes[i].checked = endState;
610 }
611 this.container.lastCheckbox = this.index;
612 return true;
613 }
614
615 function fillDestFilename() {
616 if (!document.getElementById)
617 return;
618 var path = document.getElementById('wpUploadFile').value;
619 // Find trailing part
620 var slash = path.lastIndexOf('/');
621 var backslash = path.lastIndexOf('\\');
622 var fname;
623 if (slash == -1 && backslash == -1) {
624 fname = path;
625 } else if (slash > backslash) {
626 fname = path.substring(slash+1, 10000);
627 } else {
628 fname = path.substring(backslash+1, 10000);
629 }
630
631 // Capitalise first letter and replace spaces by underscores
632 fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_');
633
634 // Output result
635 var destFile = document.getElementById('wpDestFile');
636 if (destFile)
637 destFile.value = fname;
638 }
639
640
641 function considerChangingExpiryFocus() {
642 if (!document.getElementById)
643 return;
644 var drop = document.getElementById('wpBlockExpiry');
645 if (!drop)
646 return;
647 var field = document.getElementById('wpBlockOther');
648 if (!field)
649 return;
650 var opt = drop.value;
651 if (opt == 'other')
652 field.style.display = '';
653 else
654 field.style.display = 'none';
655 }
656
657 function scrollEditBox() {
658 var editBoxEl = document.getElementById("wpTextbox1");
659 var scrollTopEl = document.getElementById("wpScrolltop");
660 var editFormEl = document.getElementById("editform");
661
662 if (editBoxEl && scrollTopEl) {
663 if (scrollTopEl.value) editBoxEl.scrollTop = scrollTopEl.value;
664 editFormEl.onsubmit = function() {
665 document.getElementById("wpScrolltop").value = document.getElementById("wpTextbox1").scrollTop;
666 }
667 }
668 }
669
670 hookEvent("load", scrollEditBox);
671
672 function allmessagesfilter() {
673 text = document.getElementById('allmessagesinput').value;
674 k = document.getElementById('allmessagestable');
675 if (!k) { return;}
676
677 var items = k.getElementsByTagName('span');
678
679 if ( text.length > allmessages_prev.length ) {
680 for (var i = items.length-1, j = 0; i >= 0; i--) {
681 j = allmessagesforeach(items, i, j);
682 }
683 } else {
684 for (var i = 0, j = 0; i < items.length; i++) {
685 j = allmessagesforeach(items, i, j);
686 }
687 }
688 allmessages_prev = text;
689 }
690
691 function allmessagesforeach(items, i, j) {
692 var hItem = items[i].getAttribute('id');
693 if (hItem.substring(0,17) == 'sp-allmessages-i-') {
694 if (items[i].firstChild && items[i].firstChild.nodeName == '#text' && items[i].firstChild.nodeValue.indexOf(text) != -1) {
695 var itemA = document.getElementById( hItem.replace('i', 'r1') );
696 var itemB = document.getElementById( hItem.replace('i', 'r2') );
697 if ( itemA.style.display != '' ) {
698 var s = "allmessageshider(\"" + hItem.replace('i', 'r1') + "\", \"" + hItem.replace('i', 'r2') + "\", '')";
699 var k = window.setTimeout(s,j++*5);
700 }
701 } else {
702 var itemA = document.getElementById( hItem.replace('i', 'r1') );
703 var itemB = document.getElementById( hItem.replace('i', 'r2') );
704 if ( itemA.style.display != 'none' ) {
705 var s = "allmessageshider(\"" + hItem.replace('i', 'r1') + "\", \"" + hItem.replace('i', 'r2') + "\", 'none')";
706 var k = window.setTimeout(s,j++*5);
707 }
708 }
709 }
710 return j;
711 }
712
713
714 function allmessageshider(idA, idB, cstyle) {
715 var itemA = document.getElementById( idA );
716 var itemB = document.getElementById( idB );
717 if (itemA) { itemA.style.display = cstyle; }
718 if (itemB) { itemB.style.display = cstyle; }
719 }
720
721 function allmessagesmodified() {
722 allmessages_modified = !allmessages_modified;
723 k = document.getElementById('allmessagestable');
724 if (!k) { return;}
725 var items = k.getElementsByTagName('tr');
726 for (var i = 0, j = 0; i< items.length; i++) {
727 if (!allmessages_modified ) {
728 if ( items[i].style.display != '' ) {
729 var s = "allmessageshider(\"" + items[i].getAttribute('id') + "\", null, '')";
730 var k = window.setTimeout(s,j++*5);
731 }
732 } else if (items[i].getAttribute('class') == 'def' && allmessages_modified) {
733 if ( items[i].style.display != 'none' ) {
734 var s = "allmessageshider(\"" + items[i].getAttribute('id') + "\", null, 'none')";
735 var k = window.setTimeout(s,j++*5);
736 }
737 }
738 }
739 }
740
741 function allmessagesshow() {
742 k = document.getElementById('allmessagesfilter');
743 if (k) { k.style.display = ''; }
744
745 allmessages_prev = '';
746 allmessages_modified = false;
747 }
748
749 hookEvent("load", allmessagesshow);
750 hookEvent("load", mwSetupToolbar);