User:Psl631/common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 8:
 
/* Make so I can choose custom roll back summary instead of de fault */
/**
$( function() {
* Ajax Undo links
$( '.mw-rollback-link > a' ).on( 'click', function(event) {
*
var $rollback = $( '#rollback-summary' );
* Adds an Ajax undo link next to the normal undo link on page histories
* and on diff pages
if ( $( this ).parent().is( $rollback.parent() ) ) {
* Based on [[User:Abelmoschus Esculentus/AjaxRollback.js]]
$rollback.toggle();
*/
} else {
//<nowiki>
$rollback.remove();
//Modified from [[User:BenjaminWillJS/AjaxRollback.js]]
jQuery(document).ready(function ($) {
var name = decodeURIComponent( $( this ).prev().prop( 'href' ).match( /&from=(.+)&token/ )[1].replace( /\+/g, ' ' ) );
function CreateUndoLink(parentObj) {
$rollback = $( '<div id="rollback-summary">' ).append(
var rollbackLink = $( '<a />' ).text( 'Rollback Summary' ).attr( 'href', '#' ).click(function(e) {
$( '<input type="text">' ).addClass( 'mw-ui-input rollback-text' ).prop( { maxlength: 250, spellcheck: true } ).val(
e.preventDefault();
'Revert consecutive edits by [[Special:Contribs/' + name + '|' + name + ']] ([[User talk:' + name + '|talk]])'
var $rblink = $(parentObj);
),
var href = parentObj.href;
$( '<input type="button">' ).addClass( 'mw-ui-button mw-ui-constructive rollback-submit-button' ).val( 'Rollback' )
)console.insertAfterlog( this href);
var summary = prompt("Enter optional summary", "");
}
var if (summary === $text.val(null);
{
// This puts the cursor at the end of the text
return;
var $text = $rollback.find( '.rollback-text' );
}
var summary = $text.val();
var summarystr = "";
$text.focus().val( '' ).val( summary );
if ( e.whichsummary !== 13 "") {
event.preventDefault();
{
} );
summarystr = "&summary=" + summary;
}
$( '#mw-content-text' ).on( 'click', '.rollback-submit-button', function() {
this.innerHTML = '<img src="https://upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif" style="vertical-align: baseline;" height="15" width="15" border="0" alt="Reverting..." />Rolling back edits...';
var $link = $( this ).closest( '.mw-rollback-link' );
$.ajax({
window.location = $link.find( 'a' ).prop( 'href' ) + '&summary=' + encodeURIComponent( $link.find( '.rollback-text' ).val() );
url: href + summarystr,
} );
success: function() {
$rblink.text(function (i, val) {return val + '[✔ success]';});
// Allow rollback to be submitted by pressing enter while focused on the input field
)},
$( '#mw-content-text' ).on( 'keypress', '.rollback-text', function( e ) {
$( error: function() {
if ( e.which !== 13 ) {
$rblink.text(function (i, val) {return val + '[❌] failed';});
return;
}
});
e.preventDefault();
});
$( '.rollback-submit-button' ).click();
return rollbackLink;
} );
}
function SetAjaxRollback() {
// Close rollback if clicked anywhere else
$( window'.mw-rollback-link > a' ).clickeach( function( e () {
$ajaxUndoLink = CreateUndoLink( this );
if ( !$( e.target ).is( '#rollback-summary' ) && !$( '#rollback-summary' ).has( e.target ).length ) {
if ( $( this ).parent().isafter( ' | ', $rollback.parent()ajaxUndoLink ) ) {;
$( '#rollback-summary' ).hide();
} );
} );
mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.Title', 'mediawiki.RegExp'], function() {
} );
SetAjaxRollback();
 
} );
} );
//</nowiki>
$( document ).ready( function() {
"use strict";
215

edits