1 window
.historyRadios = function( parent
) {
2 var inputs
= parent
.getElementsByTagName( 'input' );
5 for ( i
= 0; i
< inputs
.length
; i
++ ) {
6 if ( inputs
[i
].name
== 'diff' || inputs
[i
].name
== 'oldid' ) {
7 radios
[radios
.length
] = inputs
[i
];
13 // check selection and tweak visibility/class onclick
14 window
.diffcheck = function() {
15 var dli
= false, // the li where the diff radio is checked
16 oli
= false, // the li where the oldid radio is checked
18 var hf
= document
.getElementById( 'pagehistory' );
22 var lis
= hf
.getElementsByTagName( 'li' );
23 for ( i
= 0; i
< lis
.length
; i
++ ) {
24 var inputs
= historyRadios( lis
[i
] );
25 if ( inputs
[1] && inputs
[0] ) {
26 if ( inputs
[1].checked
|| inputs
[0].checked
) { // this row has a checked radio button
27 if ( inputs
[1].checked
&& inputs
[0].checked
&& inputs
[0].value
== inputs
[1].value
) {
30 if ( oli
) { // it's the second checked radio
31 if ( inputs
[1].checked
) {
32 if ( typeof oli
.className
!= 'undefined' ) {
33 oli
.classNameOriginal
= oli
.className
.replace( 'selected', '' );
35 oli
.classNameOriginal
= '';
38 oli
.className
= 'selected ' + oli
.classNameOriginal
;
41 } else if ( inputs
[0].checked
) {
44 if ( inputs
[0].checked
) {
48 inputs
[0].style
.visibility
= 'hidden';
51 inputs
[1].style
.visibility
= 'hidden';
53 if ( (typeof lis
[i
].className
) != 'undefined') {
54 lis
[i
].classNameOriginal
= lis
[i
].className
.replace( 'selected', '' );
56 lis
[i
].classNameOriginal
= '';
59 lis
[i
].className
= 'selected ' + lis
[i
].classNameOriginal
;
61 } else { // no radio is checked in this row
63 inputs
[0].style
.visibility
= 'hidden';
65 inputs
[0].style
.visibility
= 'visible';
68 inputs
[1].style
.visibility
= 'hidden';
70 inputs
[1].style
.visibility
= 'visible';
72 if ( typeof lis
[i
].classNameOriginal
!= 'undefined' ) {
73 lis
[i
].className
= lis
[i
].classNameOriginal
;
81 //update the compare link as you select radio buttons
82 window
.updateCompare = function () {
83 var hf
= compareLink
.$form
.get(0);
86 while(oldInd
== -1 & i
<hf
.oldid
.length
) {
87 if(hf
.oldid
[i
].checked
){
94 while(diffInd
==-1 & j
<hf
.diff
.length
) {
95 if(hf
.diff
[j
].checked
){
100 var wikiLinkURL
= wgServer
+ wgScript
+ "?title=" + encodeURIComponent(hf
.title
.value
)
101 + "&diff=" + hf
.diff
[diffInd
].value
+ "&oldid=" + hf
.oldid
[oldInd
].value
;
102 compareLink
.wikiTop
.attr("href", wikiLinkURL
);
103 compareLink
.wikiEnd
.attr("href", wikiLinkURL
);
105 if(compareLink
.htmlDiffs
)
107 var htmlLinkURL
= wgServer
+ wgScript
+ "?title=" + encodeURIComponent(hf
.title
.value
)
108 + "&htmldiff=" + compareLink
.htmlDiffButtonTxt
109 + "&diff=" + hf
.diff
[diffInd
].value
+ "&oldid=" + hf
.oldid
[oldInd
].value
;
110 compareLink
.htmlTop
.attr("href", htmlLinkURL
);
111 compareLink
.htmlEnd
.attr("href", htmlLinkURL
);
115 //change the button to a link where possible
116 window
.fixCompare = function () {
117 window
.compareLink
= {};
118 var doneHtml
= false;
119 var doneWiki
= false;
120 compareLink
.htmlDiffs
= false;
122 compareLink
.$form
= $("#mw-history-compare");
123 var hf
= compareLink
.$form
.get(0);
125 var $buttons
= $('input.historysubmit');
127 if (!compareLink
.$form
.length
|| !$buttons
.length
) return;
129 $buttons
.each(function() {
130 if(this.name
== "htmldiff") {
131 if (doneHtml
) return true;
133 var url
= wgServer
+ wgScript
+ "?title=" + encodeURIComponent(hf
.title
.value
)
134 + "&htmldiff=" + this.value
+ "&diff=" + hf
.diff
[0].value
+ "&oldid=" + hf
.oldid
[1].value
;
135 compareLink
.htmlDiffs
= true;
137 if (doneWiki
) return true;
139 var url
= wgServer
+ wgScript
+ "?title=" + encodeURIComponent(hf
.title
.value
)
140 + "&diff=" + hf
.diff
[0].value
+ "&oldid=" + hf
.oldid
[1].value
;
142 var $linkTop
= $("<a href='" + url
+ "' class='historycomparelink ui-button'>" + this.value
+ "</a>").button();
143 compareLink
.$form
.before($linkTop
);
144 $linkEnd
= $linkTop
.clone();
145 compareLink
.$form
.append($linkEnd
);
147 if(this.name
== "htmldiff") {
148 compareLink
.htmlTop
= $linkTop
;
149 compareLink
.htmlEnd
= $linkEnd
;
151 compareLink
.wikiTop
= $linkTop
;
152 compareLink
.wikiEnd
= $linkEnd
;
157 $("#pagehistory").change(function() {window
.updateCompare()});