MediaWiki:Common.js:修订间差异
删除的内容 添加的内容
标签:撤销 |
小无编辑摘要 |
||
第21行: | 第21行: | ||
s.parentNode.insertBefore(hm, s); |
s.parentNode.insertBefore(hm, s); |
||
})(); |
})(); |
||
function fixCompare() { |
|||
var $histForm = $('#mw-history-compare'), |
|||
$diffList = $('#pagehistory'), |
|||
$buttons = $histForm.find('input.historysubmit'), |
|||
buttonText, $compareLink; |
|||
if ( $buttons.length === 0 ) { |
|||
// Only one version, so do nothing |
|||
return; |
|||
} |
|||
buttonText = $buttons |
|||
.remove() |
|||
.first().val(); |
|||
$compareLink = $('<a></a>', { |
|||
'class': 'compare-link', |
|||
'text': buttonText |
|||
}); |
|||
$histForm |
|||
.prepend($compareLink) |
|||
.append($compareLink.clone()); |
|||
var updateCompare = function(){ |
|||
var $radio = $histForm.find('input[type=radio]:checked'), |
|||
genLink = mw.config.get('wgScript') |
|||
+ '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ) |
|||
+ '&diff=' + $radio.eq(0).val() |
|||
+ '&oldid=' + $radio.eq(1).val(); |
|||
$('.compare-link').each(function() { |
|||
$(this).attr('href', genLink); |
|||
}); |
|||
}; |
|||
updateCompare(); |
|||
$diffList.change(updateCompare); |
|||
} |
|||
if ( mw.config.get('wgAction') === 'history' ) { |
|||
mw.util.addCSS( '.compare-link { border-radius:5px; color:black; text-decoration:none; border-width:1px 2px 2px 1px; border-style:solid; border-color:#DDDDDD #BBBBBB #BBBBBB #DDDDDD; padding:0.2em 1em; background-color:#EEEEEE; white-space:nowrap; } .compare-link:active{ border-width:0.1em; margin:0.1em; }' ); |
|||
$(fixCompare); |
|||
} |
2022年12月12日 (一) 17:53的版本
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
/* 随系统切换暗黑模式。 */
window.wpDarkModeAutoToggle = true;
/* UTC时钟使用本地时区。 */
window.LiveClockTimeZone = 'Asia/Shanghai';
/* 优化 */
if (location.pathname === '/') {
history.replaceState({}, document.title, 'Index');
}
/* 百度统计代码 */
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?1d1f417946fa19c604c8a03880f407ed";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
function fixCompare() {
var $histForm = $('#mw-history-compare'),
$diffList = $('#pagehistory'),
$buttons = $histForm.find('input.historysubmit'),
buttonText, $compareLink;
if ( $buttons.length === 0 ) {
// Only one version, so do nothing
return;
}
buttonText = $buttons
.remove()
.first().val();
$compareLink = $('<a></a>', {
'class': 'compare-link',
'text': buttonText
});
$histForm
.prepend($compareLink)
.append($compareLink.clone());
var updateCompare = function(){
var $radio = $histForm.find('input[type=radio]:checked'),
genLink = mw.config.get('wgScript')
+ '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) )
+ '&diff=' + $radio.eq(0).val()
+ '&oldid=' + $radio.eq(1).val();
$('.compare-link').each(function() {
$(this).attr('href', genLink);
});
};
updateCompare();
$diffList.change(updateCompare);
}
if ( mw.config.get('wgAction') === 'history' ) {
mw.util.addCSS( '.compare-link { border-radius:5px; color:black; text-decoration:none; border-width:1px 2px 2px 1px; border-style:solid; border-color:#DDDDDD #BBBBBB #BBBBBB #DDDDDD; padding:0.2em 1em; background-color:#EEEEEE; white-space:nowrap; } .compare-link:active{ border-width:0.1em; margin:0.1em; }' );
$(fixCompare);
}