MediaWiki:Common.js:修订间差异
外观
小无编辑摘要 标签:手工回退 |
标签:撤销 |
||
| 第21行: | 第21行: | ||
s.parentNode.insertBefore(hm, s); | s.parentNode.insertBefore(hm, s); | ||
})(); | })(); | ||
/* 测试 */ | |||
$( document ).ready( function( $ ) { | |||
var $sb = $( '#specialchars' ).find( '.specialbasic' ), bl = $sb.length, $sel, ci = 0; | |||
if ( bl > 1 ) { | |||
ci = Number( $.cookie('mw-charinsert') ) || 0; | |||
if ( ci > bl ) { | |||
$.cookie( 'mw-charinsert', 0, { expires: 30, path: '/' } ); | |||
ci = 0; | |||
} | |||
$sel = $( '<select>' ).change( function(e) { | |||
var $this = $( this ), | |||
i = Number( $this.val() ), | |||
last = Number( $.cookie('mw-charinsert') ) || 0; | |||
if ( last !== i ) { | |||
$sb.eq( last ).css( 'display', 'none' ); | |||
$sb.eq( i ).css( 'display', 'inline' ); | |||
$.cookie( 'mw-charinsert', i, { expires: 30, path: '/' } ); | |||
} | |||
}); | |||
} | |||
$sb.each( function( i ) { | |||
var id = $( this ) | |||
.css( 'display', i !== ci ? 'none' : 'inline' ) | |||
.find( 'a' ).replaceWith( function() { | |||
var $this = $( this ), onclick = $this.attr( 'onclick' ); | |||
return $( '<button>', { type: 'button', text: $this.text() } ) | |||
.blur() | |||
.click( $.isFunction( onclick ) ? onclick : Function( onclick ) ); | |||
}) | |||
.end() | |||
.attr( 'id' ) | |||
.replace( /\.([0-9A-F]{2})/g, '%$1' ) | |||
.replace( /_/g, ' ' ); | |||
if ( bl > 1 ) { | |||
$sel.append( | |||
'<option value="' + i + '"' + (i === ci ? ' selected="selected"' : '') + '>' | |||
+ decodeURIComponent( id ) | |||
+ '</option>' | |||
); | |||
} | |||
}).end().prepend( $sel ); | |||
ci = null; | |||
}); | |||
2022年12月12日 (一) 16:02的版本
/* 这里的任何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);
})();
/* 测试 */
$( document ).ready( function( $ ) {
var $sb = $( '#specialchars' ).find( '.specialbasic' ), bl = $sb.length, $sel, ci = 0;
if ( bl > 1 ) {
ci = Number( $.cookie('mw-charinsert') ) || 0;
if ( ci > bl ) {
$.cookie( 'mw-charinsert', 0, { expires: 30, path: '/' } );
ci = 0;
}
$sel = $( '<select>' ).change( function(e) {
var $this = $( this ),
i = Number( $this.val() ),
last = Number( $.cookie('mw-charinsert') ) || 0;
if ( last !== i ) {
$sb.eq( last ).css( 'display', 'none' );
$sb.eq( i ).css( 'display', 'inline' );
$.cookie( 'mw-charinsert', i, { expires: 30, path: '/' } );
}
});
}
$sb.each( function( i ) {
var id = $( this )
.css( 'display', i !== ci ? 'none' : 'inline' )
.find( 'a' ).replaceWith( function() {
var $this = $( this ), onclick = $this.attr( 'onclick' );
return $( '<button>', { type: 'button', text: $this.text() } )
.blur()
.click( $.isFunction( onclick ) ? onclick : Function( onclick ) );
})
.end()
.attr( 'id' )
.replace( /\.([0-9A-F]{2})/g, '%$1' )
.replace( /_/g, ' ' );
if ( bl > 1 ) {
$sel.append(
'<option value="' + i + '"' + (i === ci ? ' selected="selected"' : '') + '>'
+ decodeURIComponent( id )
+ '</option>'
);
}
}).end().prepend( $sel );
ci = null;
});