× importMW = function ( name ) {
importScript( 'MediaWiki:' + name + '.js' );
};
importMWcss = function ( name ) {
importStylesheet( 'MediaWiki:' + name + '.css' );
};
mw.config.set( 'tableSorterCollation', { 'ё': 'е' } );
//Execution
mw.loader.using(
'mediawiki.util',
function () {
if ( mw.config.get( 'wgCanonicalNamespace' ) == 'Special' ) {
if ( /^(Uplo|Sear|Stat|Spec|Abus|Prefe|Move|Watch|Newp|Log)/i.test( mw.config.get( 'wgCanonicalSpecialPageName' ) ) ) {
importMW( 'Common.js/' + mw.config.get( 'wgCanonicalSpecialPageName' ) );
}
} else {
switch ( mw.config.get( 'wgAction' ) ) {
case 'history':
importMW( 'History' );
break;
case 'delete':
importMW( 'Deletepage' );
break;
case 'edit':
case 'submit':
importMW( 'Common.js/edit' );
//and continue with the default: view, purge
default:
if ( navigator.platform.indexOf( 'Win' ) != -1 ) {
mw.util.addCSS( '.IPA, .Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; }' );
}
}
}
/* Helper script for .hlist class in common.css
* Author: [[:en:User:Edokter]]
*/
if ( $.client.profile().name == 'msie' ) {
/* Add pseudo-selector class to last child list items in IE 8 */
if ( $.client.profile().versionBase == '8' ) {
$( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' )
.addClass( 'hlist-last-child' );
}
/* Generate interpuncts and parens for IE < 8 */
if ( $.client.profile().versionBase < '8' ) {
$( '.hlist' ).find( 'dt + dd, dt + dt' ).prev()
.append( '<b>:</b> ' );
$( '.hlist' ).find( 'dd + dd, dd + dt, li + li' ).prev()
.append( '<b>•</b> ' );
$( '.hlist' ).find( 'dl dl, ol ol, ul ul' )
.prepend( '( ' ).append( ') ' );
}
}
importMW('Wikibugs');
}
);
//extra scripts
var withJS = document.URL.match( /[&?]withjs=((mediawiki:)?([^&#]+))/i );
if ( withJS ) {
importScript( 'MediaWiki:' + withJS[3] );
}
var execJS = document.getElementById( 'executeJS' );
if ( execJS ) {
$.each( execJS.className.split( ' ' ), function ( i, sc ) {
sc = $.trim( sc.replace( /[^\w ]/g, '' ) );
if ( sc ) {
importMW( 'Script/' + sc );
importMWcss( 'Script/' + sc );
}
} );
}
// The function actually applying the offset
function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 50);
}
}
// This will capture hash changes while on the page
// Let the page finish loading.
$(document).ready(function() {
offsetAnchor();
$(window).on("hashchange", function () {
offsetAnchor();
});
$( '#revision-badge' ).click( function() {
$( '#revision-box' ).collapse( 'toggle' );
} );
$( '#revision-box' ).click( function() {
$( '#revision-box' ).collapse( 'toggle' );
} );
});× |
× /* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */ |
× // Helper function for toolbar buttons
function wgImg ( img ) {
return '//upload.wikimedia.org/wikipedia/' + img;
}
function createFuncBtn ( id, func, img, tip ) {
$( '<img id="' + id + '" src="' + wgImg( img ) + '" style="cursor:pointer" ' +
'title="' + tip + '" alt="' + tip.substr( 0, 3 ) + '" />' )
.appendTo( '#gadget-toolbar' )
.click( func );
}
// Toolbar section for gadgets
if ( mw.user.options.get( 'usebetatoolbar' ) ) {
var gTlbLoc = '#wikiEditor-ui-toolbar';
mw.util.addCSS( '#gadget-toolbar img { padding:2px; }' +
'#gadget-toolbar { height:26px; margin:3px; }' );
$.when(
mw.loader.using( 'ext.wikiEditor.toolbar' ),
$.ready
).then( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'groups': {
'gadgets': {}
}
} );
var $groupGadgets = $( '#wikiEditor-section-main .group-gadgets' ),
$groupFormat = $( '#wikiEditor-section-main .group-format' );
if ( $groupGadgets.length && $groupFormat.length ) {
$groupGadgets.insertBefore( $groupFormat );
}
} );
} else if ( document.getElementById( 'toolbar' ) ) {
var gTlbLoc = '#toolbar';
importMW( 'ToolbarOld' );
} else {
var gTlbLoc = '#editform';
importMW( 'ToolbarNone' );
}
function gToolbar() {
if ( !document.getElementById( 'gadget-toolbar' ) ) {
var $where = $( gTlbLoc );
if ( !$where.length ) {
return; //beta toolbar not ready yet
}
$( '<div id="gadget-toolbar" style="float:left" />' ).prependTo( $where );
}
for ( var id in mwCustomEditButtons ) {
var b = mwCustomEditButtons[id];
if ( !b.length ) {
continue;
}
createFuncBtn( id, b[0], b[1], b[2] );
delete mwCustomEditButtons[id];
}
}
$( function() {
gToolbar();
setTimeout( gToolbar, 2000 );
setTimeout( gToolbar, 6000 );
} );
// Summary buttons
function insertSummary ( txt ) {
if ( typeof txt !== 'string' ) {
txt = this.title;
}
var vv = $( '#wpSummary' ).val();
if ( vv.indexOf( txt ) !== -1 ) {
return;
}
if ( /[^,; \/]$/.test( vv ) ) {
vv += ',';
}
if ( /[^ ]$/.test( vv ) ) {
vv += ' ';
}
$( '#wpSummary' ).val( vv + txt );
}
function addSumButton ( btn, txt ) {
$( '<a title="' + txt + '">' + btn + '</a>' )
.appendTo( '#userSummaryButtonsA' )
.click( insertSummary );
}
$( function() {
var frm = document.getElementById( 'editform' );
if ( !mw.config.get( 'wgArticleId' ) || !frm || $( frm.wpSection ).val() === 'new' ) {
return;
}
mw.util.addCSS( '\
input#wpSummary { margin-bottom: 0 }\
#userSummaryButtonsA a { background:#cef; border:1px solid #adf; padding:0 2px;\
margin:0 2px;cursor:pointer; font-size:86%; color:#666 }\
#userSummaryButtonsA a:hover { background:#bdf; color:black; text-decoration:none }' );
$( '<div id=userSummaryButtonsA />' ).insertAfter( '#wpSummary' );
$.each(
[
'викиф|икация', 'оформл|ение', 'стил|евые правки', 'орфогр|афия',
'пункт|уация', 'ответ', 'комм|ентарий', 'кат|егория', 'шаб|лон',
'к удал|ению', 'иллюстрация', 'источ|ники', 'запр|ос источника',
'доп|олнение', 'уточн|ение', 'обнов|ление данных', 'закр|ыто', 'итог'
],
function ( i, s ) {
addSumButton( s.replace( /\|.*/, '' ), s.replace( /\|/, '' ) );
}
);
} );
// Wikificator
importMW( 'Wikificator' );
// Sig reminder
if ( mw.config.get( 'wgNamespaceNumber' ) % 2 !== 0 ) { // szr
$( function () {
var cp = document.getElementById( 'editpage-copywarn' ),
wpSave = document.getElementById( 'wpSave' );
if ( !cp || !wpSave ) {
return;
}
// FIXME: Use of "insertTags" is deprecated. Use mw.toolbar.insertTags instead.
var ins = ' <a href=\'javascript:insertTags(" ~~\~~","","")\'>~~\~~</a>';
cp.innerHTML += ' Не забудьте добавить к вашему сообщению подпись с помощью' + ins;
// szr if ( $.inArray( 'autoconfirmed', mw.config.get( 'wgUserGroups' ) ) !== -1 && !window.sigWarning ) {
// return;
// }
//unreg/new users only
var warningDone = false;
wpSave.onclick = function() {
try {
if ( warningDone || document.editform.wpTextbox1.value.indexOf( '~~\~~' ) !== -1 ) {
return true;
}
warningDone = true;
cp.innerHTML = 'Пожалуйста, <b>подпишитесь</b>, добавив в конце' +
' своего сообщения' + ins;
cp.style.background = '#FFD080';
cp.style.border = '1px solid orange';
return false;
} catch ( e ) {
return true;
}
};
} );
}
// Hack for Opera 11.6
if ( window.opera && /11\.6[01]/.test( window.opera.version() ) ) {
$( '#wpTextbox1' )
.mousedown( function() {
this.sT = this.scrollTop;
} )
.click( function() {
if ( this.scrollTop === 0 ) {
this.scrollTop = this.sT;
}
} );
}× |
× /* Any JavaScript here will be loaded for all users on every page load. */ |
× mw.loader.load( '//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=raw&ctype=text/javascript' ); |