Użytkownik:Frisk/hydra.js: Różnice pomiędzy wersjami
Przejdź do nawigacji
Przejdź do wyszukiwania
d added padding |
d :> |
||
| (Nie pokazano 2 pośrednich wersji utworzonych przez tego samego użytkownika) | |||
| Linia 20: | Linia 20: | ||
} ); | } ); | ||
}() ); | }() ); | ||
$.when( $.ready, mw.loader.using( 'mediawiki.util' ) ).done( function() { | |||
'use strict'; | |||
/** | |||
* Part 1: Add the deletion reason from the delete template to the delete button | |||
*/ | |||
var $deleteReason = $( '.delete-reason' ); | |||
if ( $deleteReason.length ) { | |||
// A parent node is required for $().replaceWith to work | |||
var $reasonNodes = $( '<i>' ).append( $( '.delete-reason' ).contents().clone() ); | |||
$reasonNodes.find( 'a' ).each( function() { | |||
var $link = $( this ); | |||
// Only allow internal links | |||
var classes = $link.attr( 'class' ); | |||
if ( classes && classes !== 'new' && classes !== 'mw-redirect' ) { | |||
return; | |||
} | |||
var href = $link.attr( 'href' ); | |||
var page = mw.util.getParamValue( 'title', href ) || ( href.match( /\/([^?]+)/ || [] )[1] ); | |||
if ( page ) { | |||
page = decodeURIComponent( page ).replace( /_/g, ' ' ); | |||
var wikiLink = $link.text(); | |||
if ( page !== wikiLink[0].toUpperCase() + wikiLink.slice( 1 ) ) { | |||
wikiLink = page + '|' + wikiLink; | |||
} | |||
$link.replaceWith( '[' + '[' + wikiLink + ']]' ); | |||
} | |||
} ); | |||
var reasonText = $reasonNodes.text(); | |||
if ( reasonText ) { | |||
$( '#ca-delete a' ).prop( 'href', function() { | |||
// Purposly not using wpReason, so the auto-generated reason is still there initially | |||
// so the user can press undo to get it back if they want it instead of this one | |||
return this.href += '&deleteReason=' + encodeURIComponent( reasonText ); | |||
} ); | |||
} | |||
} | |||
/** | |||
* Part 2: Get the previously added reason from the URL, or try to extract it from the "content was" summary. | |||
* Then if it partially matches one of the pre-defined deletion reasons, select that and blank the summary, | |||
* otherwise just replace the summary with it | |||
*/ | |||
if ( mw.config.get( 'wgAction' ) === 'delete' && !mw.util.getParamValue( 'wpReason' ) ) { | |||
var $reason = $( '#wpReason' ), autoReason = $reason.prop( 'value' ); | |||
var deleteReason = mw.util.getParamValue( 'deleteReason' ); | |||
if ( !deleteReason ) { | |||
var contentDeleteReason = autoReason.match( | |||
/\{\{\s*(?:template:\s*)?delete\s*\|\s*([^\}]+?)\s*(?:\|[^\]\}]*)?(?:\}\}|\.\.\.$)/i | |||
); | |||
if ( contentDeleteReason ) { | |||
deleteReason = contentDeleteReason[1]; | |||
} | |||
} | |||
if ( deleteReason ) { | |||
var lcReason = deleteReason.toLowerCase(); | |||
$( '#wpDeleteReasonList option' ).each( function() { | |||
var $option = $( this ); | |||
if ( $option.text().toLowerCase() === lcReason ) { | |||
deleteReason = null; | |||
$option.prop( 'selected', true ); | |||
return false; | |||
} | |||
} ); | |||
if ( deleteReason && deleteReason.length > 255 ) { | |||
deleteReason = deleteReason.slice( 0, 252 ) + '...'; | |||
} | |||
} | |||
$reason.prop( 'value', deleteReason || '' ); | |||
} | |||
} ); | |||
var faces = ["(・`ω´・)", ";;w;;", "owo", "UwU", ">w<", "^w^"]; | |||
function OwoifyText(text){ | |||
v = text | |||
v = v.replace(/(?:r|l)/g, "w"); | |||
v = v.replace(/(?:R|L)/g, "W"); | |||
v = v.replace(/n([aeiou])/g, 'ny$1'); | |||
v = v.replace(/N([aeiou])/g, 'Ny$1'); | |||
v = v.replace(/N([AEIOU])/g, 'Ny$1'); | |||
v = v.replace(/ove/g, "uv"); | |||
v = v.replace(/\!+/g, " " + faces[Math.floor(Math.random() * faces.length)] + " "); | |||
return v | |||
} | |||
function node_sz_to_ss(node) { | |||
if (node.nodeType === 3) { | |||
var text = OwoifyText(node.data); | |||
if (text !== node.data) { | |||
node.data = text; | |||
} | |||
} else if ( node.nodeType === 1 | |||
&& node.id !== 'editform' | |||
&& node.className !== 'Vorlage_Zitat' | |||
) { | |||
for (var i = 0 ; i < node.childNodes.length ; i++) { | |||
node_sz_to_ss(node.childNodes[i]); | |||
} | |||
} | |||
} | |||
//node_sz_to_ss( $( '.mw-body' ).get(0) ); | |||
Aktualna wersja na dzień 21:05, 13 cze 2019
( function() {
'use strict';
var $changeList = $( '.mw-changeslist' );
if ( !$changeList.length ) {
return;
}
mw.loader.using( 'mediawiki.util' ).then( function() {
$changeList.find( '.mw-title' ).each( function() {
var title = $( this ).find( '.mw-changeslist-title' ).attr( 'title' );
if ( title ) {
$( '<a>' ).addClass( 'rc-editlink' ).attr( {
href: mw.util.getUrl( title, { action: 'edit' } ),
title: 'Edit this page',
style: 'padding-left: 3px;padding-right: 3px;'
} ).text( '✎' ).insertAfter( this );
}
} );
} );
}() );
$.when( $.ready, mw.loader.using( 'mediawiki.util' ) ).done( function() {
'use strict';
/**
* Part 1: Add the deletion reason from the delete template to the delete button
*/
var $deleteReason = $( '.delete-reason' );
if ( $deleteReason.length ) {
// A parent node is required for $().replaceWith to work
var $reasonNodes = $( '<i>' ).append( $( '.delete-reason' ).contents().clone() );
$reasonNodes.find( 'a' ).each( function() {
var $link = $( this );
// Only allow internal links
var classes = $link.attr( 'class' );
if ( classes && classes !== 'new' && classes !== 'mw-redirect' ) {
return;
}
var href = $link.attr( 'href' );
var page = mw.util.getParamValue( 'title', href ) || ( href.match( /\/([^?]+)/ || [] )[1] );
if ( page ) {
page = decodeURIComponent( page ).replace( /_/g, ' ' );
var wikiLink = $link.text();
if ( page !== wikiLink[0].toUpperCase() + wikiLink.slice( 1 ) ) {
wikiLink = page + '|' + wikiLink;
}
$link.replaceWith( '[' + '[' + wikiLink + ']]' );
}
} );
var reasonText = $reasonNodes.text();
if ( reasonText ) {
$( '#ca-delete a' ).prop( 'href', function() {
// Purposly not using wpReason, so the auto-generated reason is still there initially
// so the user can press undo to get it back if they want it instead of this one
return this.href += '&deleteReason=' + encodeURIComponent( reasonText );
} );
}
}
/**
* Part 2: Get the previously added reason from the URL, or try to extract it from the "content was" summary.
* Then if it partially matches one of the pre-defined deletion reasons, select that and blank the summary,
* otherwise just replace the summary with it
*/
if ( mw.config.get( 'wgAction' ) === 'delete' && !mw.util.getParamValue( 'wpReason' ) ) {
var $reason = $( '#wpReason' ), autoReason = $reason.prop( 'value' );
var deleteReason = mw.util.getParamValue( 'deleteReason' );
if ( !deleteReason ) {
var contentDeleteReason = autoReason.match(
/\{\{\s*(?:template:\s*)?delete\s*\|\s*([^\}]+?)\s*(?:\|[^\]\}]*)?(?:\}\}|\.\.\.$)/i
);
if ( contentDeleteReason ) {
deleteReason = contentDeleteReason[1];
}
}
if ( deleteReason ) {
var lcReason = deleteReason.toLowerCase();
$( '#wpDeleteReasonList option' ).each( function() {
var $option = $( this );
if ( $option.text().toLowerCase() === lcReason ) {
deleteReason = null;
$option.prop( 'selected', true );
return false;
}
} );
if ( deleteReason && deleteReason.length > 255 ) {
deleteReason = deleteReason.slice( 0, 252 ) + '...';
}
}
$reason.prop( 'value', deleteReason || '' );
}
} );
var faces = ["(・`ω´・)", ";;w;;", "owo", "UwU", ">w<", "^w^"];
function OwoifyText(text){
v = text
v = v.replace(/(?:r|l)/g, "w");
v = v.replace(/(?:R|L)/g, "W");
v = v.replace(/n([aeiou])/g, 'ny$1');
v = v.replace(/N([aeiou])/g, 'Ny$1');
v = v.replace(/N([AEIOU])/g, 'Ny$1');
v = v.replace(/ove/g, "uv");
v = v.replace(/\!+/g, " " + faces[Math.floor(Math.random() * faces.length)] + " ");
return v
}
function node_sz_to_ss(node) {
if (node.nodeType === 3) {
var text = OwoifyText(node.data);
if (text !== node.data) {
node.data = text;
}
} else if ( node.nodeType === 1
&& node.id !== 'editform'
&& node.className !== 'Vorlage_Zitat'
) {
for (var i = 0 ; i < node.childNodes.length ; i++) {
node_sz_to_ss(node.childNodes[i]);
}
}
}
//node_sz_to_ss( $( '.mw-body' ).get(0) );