Utente:Daimona Eaytoy/ipv6.js
Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.
Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.
( function( mw, $ ) {
'use strict';
function expandContribs() {
var urlMatch = /Speciale:Contributi\/(.+?)(&|$)/.exec( window.location.href );
if ( !urlMatch ) {
return;
}
var target = urlMatch[1],
button;
if ( mw.util.isIPv6Address( target ) ) {
button = new OO.ui.ButtonWidget( {
label: 'Vai ai contributi del /64',
flags: [ 'primary', 'progressive' ]
} );
button.on( 'click', function() {
window.location.href = window.location.href.replace( target, target + '/64' );
} );
$( '.mw-contributions-user-tools' ).after( button.$element );
}
}
function adjustBlock() {
var $targetField = $( 'input[name=wpTarget]' ),
target = $targetField.val(),
button;
if ( mw.util.isIPv6Address( target ) ) {
button = new OO.ui.ButtonWidget( {
label: 'Inserisci il /64',
flags: [ 'primary', 'progressive' ]
} );
button.on( 'click', function() {
$targetField.val( target + '/64' );
} );
$( '#mw-htmlform-target' ).append( button.$element );
}
}
$( function () {
var cb;
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Block' ) {
cb = adjustBlock;
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Contributions' ) {
cb = expandContribs;
}
if ( cb ) {
mw.loader.using( 'mediawiki.util' )
.done( cb )
.fail( function() { console.error( 'Impossibile avviare script IPv6' ); } );
}
} );
}( mediaWiki, jQuery ) );