1 // Wikipedia JavaScript support functions
3 // for enhanced RecentChanges
4 function toggleVisibility( _levelId
, _otherId
, _linkId
) {
5 var thisLevel
= document
.getElementById( _levelId
);
6 var otherLevel
= document
.getElementById( _otherId
);
7 var linkLevel
= document
.getElementById( _linkId
);
8 if ( thisLevel
.style
.display
== 'none' ) {
9 thisLevel
.style
.display
= 'block';
10 otherLevel
.style
.display
= 'none';
11 linkLevel
.style
.display
= 'inline';
13 thisLevel
.style
.display
= 'none';
14 otherLevel
.style
.display
= 'inline';
15 linkLevel
.style
.display
= 'none';
20 // tz in format [+-]HHMM
21 function checkTimezone( tz
, msg
) {
22 var localclock
= new Date();
23 // returns negative offset from GMT in minutes
24 var tzRaw
= localclock
.getTimezoneOffset();
25 var tzHour
= Math
.floor( Math
.abs(tzRaw
) / 60);
26 var tzMin
= Math
.abs(tzRaw
) % 60;
27 var tzString
= ((tzRaw
>= 0) ? "-" : "+") + ((tzHour
< 10) ? "0" : "") + tzHour
+ ((tzMin
< 10) ? "0" : "") + tzMin
;
28 if( tz
!= tzString
) {
29 var junk
= msg
.split( '$1' );
30 document
.write( junk
[0] + "UTC" + tzString
+ junk
[1] );
34 // in [-][H]H format...
35 // won't yet work with non-even tzs
36 function fetchTimezone() {
37 // FIXME: work around Safari bug
38 var localclock
= new Date();
39 // returns negative offset from GMT in minutes
40 var tzRaw
= localclock
.getTimezoneOffset();
41 var tzHour
= Math
.floor( Math
.abs(tzRaw
) / 60);
42 var tzString
= ((tzRaw
>= 0) ? "-" : "") + ((tzHour
< 10) ? "" : "0") + tzHour
;
46 function guessTimezone(box
) {
47 document
.preferences
.wpHourDiff
.value
= fetchTimezone();
51 function showTocToggle(show
,hide
) {
52 if(document
.getElementById
) {
53 document
.writeln('<small>[<a href="javascript:toggleToc()" id="toctoggle">' +
54 hide
+ '/' + show
+ '</a>]</small>');
60 function toggleToc() {
61 var toc
= document
.getElementById('tocinside');
62 var tog
= document
.getElementById('toctoggle');
63 if(toc
.style
.display
== 'none') {
64 toc
.style
.display
= tocWas
;
65 // tog.innerHtml = tocHide;
67 tocWas
= toc
.style
.display
;
68 toc
.style
.display
= 'none';
69 // tog.innerHtml = tocShow;
74 /* Temporary hack for Mozilla bug; revert to quirks mode handling of <hr> */
75 if(navigator
.userAgent
&&
76 navigator
.userAgent
.indexOf('Gecko') != -1 &&
77 navigator
.userAgent
.indexOf('KHTML') == -1) {
79 '<style type="text/css">\n' +
81 ' display: inline;\n' +
82 ' -moz-box-sizing: border-box;\n' +
83 ' margin: 0 0.1% 0 0.1%;\n' +
84 ' font-size: -moz-initial !important;\n' +
87 ' white-space: pre;\n' +
88 ' content: "\\A";\n' +
91 ' white-space: pre;\n' +
92 ' content: "\\A";\n' +