// UWAGA! Z tego gadżetu korzystają także inne projekty
// Style CSS → ] ↓
// ID #userSummaryButtons
// Autor: ]
window.blockGadget = {
version: 4,
init: function() {
var that = this;
if ( mw.config.get( "wgCanonicalSpecialPageName" ) != 'Blockip' && mw.config.get( "wgCanonicalSpecialPageName" ) != 'Block' ) {
return;
}
jQuery( "#wpAllowUsertalk" ).attr( 'checked', false );
jQuery( "#mw-input-wpDisableUTEdit" ).attr( 'checked', true );
var wpBlockExpiry = document.querySelector( '' );
var wpBlockOther = document.querySelector( '' );
if ( !wpBlockExpiry ) {
return;
}
var td = document.getElementById( 'mw-htmlform-expiry' ).parentNode;
var expContainer = document.createElement('div');
expContainer.style.padding = '3px';
expContainer.className = 'userSummaryButtons';
td.appendChild( expContainer );
for ( var caption in bk$times ) {
var newButton = document.createElement('a');
// atrybuty
newButton.title = bk$times;
newButton.onclick = function() { that.selectItem( wpBlockExpiry, wpBlockOther, this.title ); };
newButton.appendChild( document.createTextNode( caption ) );
// dodanie przycisku
expContainer.appendChild( newButton );
}
var wpBlockReasonList = document.querySelector( '' );
var wpBlockOtherReason = document.querySelector( '' );
td = document.getElementById( 'mw-htmlform-reason' ).parentNode;
var summContainer = document.createElement('div');
summContainer.style.padding = '3px';
summContainer.className = 'userSummaryButtons';
td.appendChild( summContainer );
for ( var i in bk$reasons ) {
var item = bk$reasons;
var newButton = document.createElement( 'a' );
// atrybuty
newButton.item = item;
newButton.title = item.reason;
newButton.onclick = function() {
that.selectItem( wpBlockReasonList, wpBlockOtherReason, this.title );
if ( this.item.callback ) {
this.item.callback( item );
}
};
newButton.appendChild( document.createTextNode( item.caption ) );
// dodanie przycisku
summContainer.appendChild( newButton );
}
},
selectItem: function( wpBlockExpiry, wpBlockOther, value ) {
var listed = false;
for ( var i = 0; i < wpBlockExpiry.options.length; i++ ) {
if ( wpBlockExpiry.options.value == value ) {
listed = true;
}
}
if ( listed ) {
wpBlockExpiry.value = value;
$( wpBlockExpiry ).change();
}
else {
wpBlockExpiry.value = 'other';
$( wpBlockExpiry ).change();
wpBlockOther.value = value;
}
}
};
jQuery(document).ready(function() {
blockGadget.init();
});