User:Psl85/common.js

From translatewiki.net

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$(function() {

/*
mw.loader.localLoad = function(url) { return mw.loader.load('/index.php?title='+url+'.js&action=raw&ctype=text/javascript') };
mw.loader.interLoad = function(url, wiki) { return mw.loader.load('//'+wiki+'.gamepedia.com/index.php?title='+url+'.js&action=raw&ctype=text/javascript') };
mw.loader.localLoad('User:ITechieGamer/test');
*/

mw.loader.load('//help.gamepedia.com/index.php?title=User:ITechieGamer/interwiki.js&action=raw&ctype=text/javascript');

});

mw.loader.load('//fr.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js&action=raw&ctype=text/javascript');

mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Majr/goToTop.js&action=raw&ctype=text/javascript' );

/* Welcome script from [[User:ITechieGamer]] */

$(document).ready(function() {
  // Add a new portal before the social profiles in the toolbox
  var $welcomeGroup = $('<div class="portal collapsed" role="navigation" id="p-welcome" aria-labelledby="p-welcome-label"></div>').append($('<h3 id="p-welcome-label">Welcoming users</h3>')),
      $welcomeBody = $('<div class="body"></div>'),
      $goodWelcomeLink = $('<a id="t-goodwelcome" href="#" title="Welcome a user">Good welcome</a>'),
      $badWelcomeLink = $('<a id="t-badwelcome" href="#" title="Welcome a user">Bad welcome</a>'),
      $newUserLink = $('<a id="t-newusers" href="/index.php?title=Special:ListAllUsers&group=&username=&editsOnly=0&creationSort=1" title="List of new users">New users</a>');
  $($welcomeGroup.append($welcomeBody.html($('<ul id="p-welcome-list"></ul>').append($('<li/>').html($goodWelcomeLink)).append($('<li/>').html($badWelcomeLink)).append($('<li/>').html($newUserLink))))).insertBefore('#p-socialProfiles');

  $('#t-goodwelcome').click( function() {
    // Notify the user for the username
    var username = prompt('Who would you like to good welcome?');
    if(username == '' || username == null) return;

    // Welcome the user
    window.open('/index.php?action=edit&section=new&title=User_talk:'+username+'&preload=User:ITechieGamer/welcome/good&preloadtitle=Welcome%21&preloadparams%5b%5d='+username+'&preloadparams%5b%5d=%7e', '_blank');
  });

  $('#t-badwelcome').click( function() {
    // Notify the user for the username
    var username = prompt('Who would you like to bad welcome?');
    if(username == '' || username == null) return;

    // Welcome the user
    window.open('/index.php?action=edit&section=new&title=User_talk:'+username+'&preload=User:ITechieGamer/welcome/bad&preloadtitle=Welcome&preloadparams%5b%5d=%7e', '_blank');
  });
});

/* Add image at the top right corner to blocked users' userpages */

if ( mw.config.get( 'wgRelevantUserName' ) ) {
	$( function() {
		'use strict';
		var title = 'This username/IP number is blocked';
		( new mw.Api() ).get( {
			action: 'query',
			format: 'json',
			list: 'blocks',
			formatversion: 2,
			bkusers: mw.config.get( 'wgRelevantUserName' )
		} ).done( function( data ) {
			if ( data.query.blocks.length ) {
				$( '.mw-indicators' ).prepend(
					'<a href="//commons.wikimedia.org/wiki/File:Blocked_user.svg" class="mw-indicator" id="gadget-blockindicator" title="' + title + '">' +
						'<img src="//upload.wikimedia.org/wikipedia/commons/4/4f/Blocked_user.svg" height="20">' +
					'</a>'
				);
			}
		} );
	} );
}

// Scripts, some imported from Wiki Pedia, and modified to use on this wiki //

// [[File:Perhelion/userstatus.js]]

/* HotCat - fast addition of categories */

mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );

/* Auto-sign posts */

mw.loader.load( '//meta.wikimedia.org/w/index.php?title=user:perhelion/signing.js&action=raw&ctype=text/javascript' );

/* PopUps - article previews and quick links while hower overlins rather than the default "tooltip" */
mw.loader.load('//meta.wikimedia.org/w/index.php?title=Mediawiki:Gadget-popups.js&action=raw&ctype=text/javascript');

mw.loader.load('//terraria.gamepedia.com/index.php?title=MediaWiki:Gadget-PastBlocks.js&action=raw&ctype=text/javascript');

/* IP info */
mw.loader.load('//terraria.gamepedia.com/index.php?title=MediaWiki:Gadget-ipInfo.js&action=raw&ctype=text/javascript');

/* [edit] link for the top section */
mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Gadget-edittop.js&action=raw&ctype=text/javascript');

/* More Watchlist tools */

mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/smartwatchlist.js&action=raw&ctype=text/javascript' );

/* RC options */
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/rc.js&action=raw&ctype=text/javascript' );

/* LiveRC */
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/liverc.js&action=raw&ctype=text/javascript' );

/* Dropdown menus for page tools and options */
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/dropdownmenu.js&action=raw&ctype=text/javascript' );

/* NightMode from the german wiki, might not work */
mw.loader.load( '//minecraft-de.gamepedia.com/index.php?title=MediaWiki:Gadget-nightmode.js&action=raw&ctype=text/javascript' );

/* Warnings */
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/warnings.js&action=raw&ctype=text/javascript' );

// [[User:Ais523/votesymbols.js]]
// Code for adding icons to !votes in AfDs, RfAs, etc.. Doesn't affect the page, just
// shows the icons when this code is installed.
// Please see [[:Image:Votesymbols.js-enhanced_SfD.png]] for copyright info on the images that are added.

/* Wiki+ */
mw.loader.load('https://wikiplus-app.smartgslb.com/Main.js');

function lowerNoPunct(s)
{
  return s.toLowerCase().split('.').join('').split(',').join('').split(':').join('').split(';').join('').split('+').join('');
}

/* ======================================================== *\
**                      igloo frontend manager - main
** 
**      The igloo frontend manager handles the client system,
** displaying information to the user, as well as allowing
** the user to interact with the program.
**
**  ======================================================  **
**      igloo anti-vandalism tool for Wikipedia
**              based off of the script igloo by Alex Barley
**  By: User:Kangaroopower
**
**      For instructions, see [[Wikipedia:Igloo]]
**  ======================================================  **
**
**      You may copy, modify and distribute this software as
** desired, providing that all previous contributors retain
** correct attribution.
**
**  ======================================================  **
**                      tracker: [[Wikipedia:Igloo]]
\* ======================================================== */
window.iglooBranch = 'master';
mw.loader.load("//tools.wmflabs.org/igloo/code/Igloo/gloo.js");
//

$(function() {
  if(mw.config.get('wgNamespaceNumber')===0) return; //avoid article space, generally speaking
  var vs=
  "//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/15px-Symbol_support_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Symbol_keep_vote.svg/15px-Symbol_keep_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/15px-Symbol_oppose_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_delete_vote.svg/15px-Symbol_delete_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_neutral_vote.svg/15px-Symbol_neutral_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Symbol_merge_vote.svg/15px-Symbol_merge_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/50/Symbol_move_vote.svg/15px-Symbol_move_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Symbol_redirect_vote.svg/15px-Symbol_redirect_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Symbol_opinion_vote.svg/15px-Symbol_opinion_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_comment_vote.svg/15px-Symbol_comment_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Symbol_unsupport_vote.svg/15px-Symbol_unsupport_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_question.svg/15px-Symbol_question.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Symbol_divide_vote.svg/15px-Symbol_divide_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/54/Symbol_wait.svg/15px-Symbol_wait.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Face-grin.svg/15px-Face-grin.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Symbol_support2_vote.svg/15px-Symbol_support2_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Symbol_no_support_vote.svg/15px-Symbol_no_support_vote.svg.png";
  var vt=vs.split("#");
  var la=[];
  la['support']=0; la['endorse']=0;
  la['keep']=1; la['allow']=1; la['permit']=1
  la['oppose']=2; la['overturn']=2; la['object']=2; la['disallow']=2
  la['delete']=3;
  la['neutral']=4;
  la['merge']=5; la['upmerge']=5;
  la['move']=6; la['rename']=6; la['userfy']=6; la['transwiki']=6; la['listify']=6; la['convert']=15
  la['redirect']=7; la['retarget']=7;
  la['opinion']=8; la['relist']=8; la['subst']=8; la['salt']=8; la['change']=8; la['list']=8;
  // Note that icon 8 on the list is often used for debate-specific !votes
  la['comment']=9; la['update']=9; la['note']=9;
  la['delist']=10;
  la['question']=11;
  la['split']=12; la['disambiguate']=12; la['set index']=12; la['SIA']=12; la['dab']=12; la['dabify']=12;
  la['wait']=13;
  la['bjaodn']=14;
  la['undelete']=15; la['restore']=15
  la['close']=16;

  var btc=document.body.getElementsByTagName("B");
  i=btc.length;
  while(i--)
  {
    var j,k;
    j=btc[i].innerHTML.split("<").join(" ").split(">").join(" ").split("/").join(" ").split(" ");
    k=0;
    var x="";
    while(k<j.length)
    {
      if(lowerNoPunct(j[k])=="don't"||lowerNoPunct(j[k])=='not'
       ||lowerNoPunct(j[k])=='no'||lowerNoPunct(j[k])=='without') break;
      var l=la[lowerNoPunct(j[k])];
      if(l!==undefined)
      {
        x+='<img src="'+vt[l]+'" alt="" /> '
      }
      k++;
    }
    if(x!=="") btc[i].innerHTML=x+btc[i].innerHTML;
  }
});
//[[Category:Wikipedia scripts]]

/*
 
 Put some functions in the toolbox for the anti-vandal whack-a-mole game.
 Documented at http://en.wikipedia.org/wiki/User:Kbh3rd/Vandal_warning_toolbox
 
 */
 // <pre><nowiki>

/* Note if there is error with javascript on a page */
// This only shows alerts for things after this handler is installed of course.
// Because this is a gadget, error reporting can thus be inconsistent.
var originalErrorHandler = window.onerror || null;
// Column and error args are optional
window.onerror = function ( message, url, line, colomn, error ) {
	var $msg = $( '<p>' );
	if ( url ) {
		$( '<span>' )
			.text( url + ' at line ' + line + ': ' )
			.appendTo( $msg );
	}
	$( '<span>' )
		.text( message )
		.appendTo( $msg );

	mw.notify( $msg, {
		autoHide: true,
		autoHideSeconds: 10,
		tag: null,
		title: 'An error occured:',
		type: 'error'
	} );
	if (originalErrorHandler) {
		return originalErrorHandler.apply(this, arguments);
	}
};
// unbind on leaving the page
$( window )
	.on( 'unload', function () {
		window.onerror = originalErrorHandler;
	} );

/*         Editing improvements         */

/* To clear summary */
$( function() {
	'use strict';
	var lang = mw.config.get( 'wgUserLanguage' );
	var title = 'Clear edit summary ';
	if ( lang === 'sv' ) {
		title = 'Töm sammanfattningsfältet';
	}
	$( '#wpSummary' ).closest( '.oo-ui-fieldLayout-body' ).find( '.oo-ui-fieldLayout-header' ).append( '<button type="button" id="gadget-clearcomment" title="' + title + '">✖</button>' );
	$( '#gadget-clearcomment' ).click( function() {
		$( '#wpSummary' ).val( '' );
	} );
} );

/* To make a custom edit summary dropdown */
$( function() {
	'use strict';
	var text = 'Comments';
	var title = 'View and edit user-defined edit comments';
	var label = 'Enter your edit comments here (separate with newline)';
	var close = 'Close';
	var closetitle = 'Close the dialog window without inserting any edit comment';
	var key = 'gadget-userdefinedcomments-key';
	function getComments() {
		var commentsoutput = localStorage.getItem( key );
		if ( commentsoutput ) {
			commentsoutput = commentsoutput.trim();
			if ( commentsoutput ) {
				return commentsoutput.split( '\n' );
			}
		}
		return [];
	}
	if ( mw.config.get( 'wgUserLanguage' ) === 'sv' ) {
		text = 'Kommentarer';
		title = 'Visa och redigera användardefinierade redigeringskommentarer';
		label = 'Lägg in dina redigeringskommentarer här (separara med radbrytning)';
		close = 'Stäng';
		closetitle = 'Stäng dialogrutan utan att infoga någon redigeringskommentar';
	}
	$( '#wpSummary' ).after( '<button id="gadget-userdefinedcomments" title="' + title + '" type="button">' + text + '</button>' );
	$( '#gadget-userdefinedcomments' ).click( function( ev ) {
		ev.preventDefault();
		// Creating and opening a simple dialog window.

		// Subclass Dialog class. Note that the OOjs inheritClass() method extends the parent constructor's prototype and static methods and properties to the child constructor.

		function MyDialog( config ) {
			MyDialog.super.call( this, config );
		}

		// Declare early for use in MyDialog.prototype methods
		var myDialog;
		var windowManager;

		OO.inheritClass( MyDialog, OO.ui.Dialog );

		// Specify a title statically (or, alternatively, with data passed to the opening() method).
		MyDialog.static.name = 'gadgetuserdefinedcommentsdialog';
		MyDialog.static.title = 'Simple dialog';

		// Customize the initialize() function: This is where to add content to the dialog body and set up event handlers.
		MyDialog.prototype.initialize = function () {
			// Call the parent method
			MyDialog.super.prototype.initialize.call( this );
			// Create and append a layout and some content.
			this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
			var comments = getComments();
			var str = '';
			comments.forEach( function( comment ) {
				str += '<button class="gadget-userdefinedcomments-comment">' + mw.html.escape( comment ) + '</button>';
			} );
			str += '<label for="gadget-userdefinedcomments-textarea">' + label + '</label>';
			str += '<textarea id="gadget-userdefinedcomments-textarea"></textarea>';
			str += '<button id="gadget-userdefinedcomments-close" title="' + closetitle + '">' + close + '</button>';
			this.content.$element.append( str );
			this.$body.append( this.content.$element );
			$( '.gadget-userdefinedcomments-comment' ).click( function( ev ) {
				$( '#wpSummary' ).val( function( i, v ) {
					return v + $( ev.currentTarget ).text();
				} );
				myDialog.close();
			} );
			$( '#gadget-userdefinedcomments-textarea' ).change( function( ev ) {
				var commentsinput = $( ev.currentTarget ).val().trim();
				if ( commentsinput ) {
					localStorage.setItem( key, commentsinput );
				} else {
					localStorage.removeItem( key );
				}
			} );
			$( '#gadget-userdefinedcomments-textarea' ).val( comments.join( '\n' ) );
			$( '#gadget-userdefinedcomments-close' ).click( function() {
				myDialog.close();
			} );
		};

		// Use the getTeardownProcess() method to perform actions whenever the dialog is closed.
		// This method provides access to data passed into the window's close() method
		// or the window manager's closeWindow() method.
		MyDialog.prototype.getTeardownProcess = function ( data ) {
			return MyDialog.super.prototype.getTeardownProcess.call( this, data )
			.first( function () {
				// Perform any cleanup as needed
				$( '.oo-ui-windowManager' ).remove();
			}, this );
		};

		// Make the window.
		myDialog = new MyDialog();

		// Create and append a window manager, which will open and close the window.
		windowManager = new OO.ui.WindowManager();
		$( 'body' ).append( windowManager.$element );

		// Add the window to the window manager using the addWindows() method.
		windowManager.addWindows( [ myDialog ] );

		// Open the window!
		windowManager.openWindow( myDialog );
	} );
} );

/* To save wiki text to use later */
if ( window.Storage ) {
	$( function() {
		'use strict';
		var text = 'Saved wikitext';
		var tooltip = 'View and copy saved wikitext on your computer';
		var selecttext = 'Select the wikitext';
		var selecttitle = 'Select the wikitext for easy copying';
		var settingstext = 'Settings';
		var settingstitle = 'Settings for auto save';
		var closetext = 'Close';
		var closetitle = 'Close the dialog window';
		var typeofoptions = 'Choose type of options';
		var lengthbuttontext = 'Minimum length';
		var lengthbuttontitle = 'Set the minimum length to be saved';
		var timebuttontext = 'Time interval';
		var timebuttontitle = 'Set the time interval between the saves';
		var settingsdescriptionlength = 'Set the minimum length (in number of characters) to be saved';
		var settingsdescriptiontime = 'Set the time interval (in number of milliseconds) between the saves';
		var savetext = 'Save';
		var savetitle = 'Save the input and close the dialog';
		var removelocalstoragetext = 'Remove saved wikitext';
		var removelocalstoragetitle = 'Remove wikitext saved on the computer';
		var removesavedlengthtext = 'Reset minimum length';
		var removesavedlengthtitle = 'Remove saved custom minimum length to save';
		var removesavedtimetext = 'Reset time interval';
		var removesavedtimetitle = 'Remove saved custom time interval between the saves';
		if ( mw.config.get('wgUserLanguage') === 'sv' ) {
			text = 'Sparad wikitext';
			tooltip = 'Visa och kopiera sparad wikitext som finns på din dator';
			selecttext = 'Markera wikitexten';
			selecttitle = 'Markera wikitexten för att enkelt kunna kopiera den';
			settingstext = 'Inställningar';
			settingstitle = 'Inställningar för autospar';
			closetext = 'Stäng';
			closetitle = 'Stäng dialogrutan';
			typeofoptions = 'Välj typ av inställningar';
			lengthbuttontext = 'Minimilängd';
			lengthbuttontitle = 'Bestäm hur lång texten måste vara för att få sparas';
			timebuttontext = 'Tidsintervall';
			timebuttontitle = 'Bestäm tidsintervallet mellan sparningarna';
			settingsdescriptionlength = 'Bestäm hur lång texten måste vara (i antal tecken) för att få sparas';
			settingsdescriptiontime = 'Bestäm tidsintervallet (i antal millisekunder) mellan sparningarna';
			savetext = 'Spara';
			savetitle = 'Spara inställningar och stäng dialogrutan';
			removelocalstoragetext = 'Ta bort sparad wikitext';
			removelocalstoragetitle = 'Ta bort sparad wikitext från datorn';
			removesavedlengthtext = 'Återställ minimilängd';
			removesavedlengthtitle = 'Ta bort sparad anpassad minimilängd som får sparas';
			removesavedtimetext = 'Återställ tidsintervall';
			removesavedtimetitle = 'Ta bort sparat anpassat tidsintervall för sparningarna';
		}
		function getMinimumLength() {
			if ( localStorage.getItem( 'gadget-autosave-length' ) ) {
				return localStorage.getItem( 'gadget-autosave-length' );
			} else {
				return 10;
			}
		}
		function getTimeInterval() {
			if ( localStorage.getItem( 'gadget-autosave-time' ) ) {
				return localStorage.getItem( 'gadget-autosave-time' );
			} else {
				return 1000 * 60;
			}
		}
		if ( $( '#wpTextbox1' ).length ) {
			setInterval( function() {
				if ( $( '#wpTextbox1' ).val().length >= Number( getMinimumLength() ) ) {
					localStorage.setItem( 'svwikigadgetautosave', $( '#wpTextbox1' ).val() );
				}
			}, Number( getTimeInterval() ) );
		}
		mw.util.addPortletLink(
			'p-tb',
			'#',
			text,
			'gadget-autosave',
			tooltip
		);
		$( '#gadget-autosave' ).find( 'a' ).click( function( e ) {
			e.preventDefault();
			var dialog;
			// Creating and opening a simple dialog window.

			// Subclass Dialog class. Note that the OOjs inheritClass() method extends the parent constructor's prototype and static methods and properties to the child constructor.

			function MyDialog( config ) {
				MyDialog.super.call( this, config );
			}
			if ( $( '.oo-ui-window-active' ).length === 0 ) {
				OO.inheritClass( MyDialog, OO.ui.Dialog );

				// Specify a title statically (or, alternatively, with data passed to the opening() method).
				MyDialog.static.name = 'gadgetautosavedialog';
				MyDialog.static.title = 'Simple dialog';

				// Customize the initialize() function: This is where to add content to the dialog body and set up event handlers.
				MyDialog.prototype.initialize = function () {
					var str = '<div id="gadget-autosave-dialog">';
					str += '<textarea id="gadget-autosave-textarea" readonly></textarea>';
					str += '<button id="gadget-autosave-select" title="' + selecttitle + '">' + selecttext + '</button>';
					str += '<button id="gadget-autosave-settings" title="' + settingstitle + '">' + settingstext + '</button>';
					str += '<button id="gadget-autosave-close" title="' + closetitle + '">' + closetext + '</button>';
					str += '</div>';
					// Call the parent method
					MyDialog.super.prototype.initialize.call( this );
					// Create and append a layout and some content.
					this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
					this.content.$element.append( str );
					this.$body.append( this.content.$element );
					dialog = $( '#gadget-autosave-dialog' );
					$( '#gadget-autosave-dialog' ).on( 'keyup', 'input', function( e ) {
						if ( e.which === 13 ) {
							$( '#gadget-autosave-dialog button' ).click();
						}
					} );
					$( '#gadget-autosave-textarea' ).val( localStorage.getItem( 'svwikigadgetautosave' ) );
				};

				// Use the getTeardownProcess() method to perform actions whenever the dialog is closed.
				// This method provides access to data passed into the window's close() method
				// or the window manager's closeWindow() method.
				MyDialog.prototype.getTeardownProcess = function ( data ) {
					return MyDialog.super.prototype.getTeardownProcess.call( this, data )
					.first( function () {
						// Perform any cleanup as needed
						$( '.oo-ui-windowManager' ).remove();
					}, this );
				};

				// Make the window.
				var myDialog = new MyDialog();

				// Create and append a window manager, which will open and close the window.
				var windowManager = new OO.ui.WindowManager();
				$( 'body' ).append( windowManager.$element );

				// Add the window to the window manager using the addWindows() method.
				windowManager.addWindows( [ myDialog ] );

				// Open the window!
				windowManager.openWindow( myDialog );
				$( '#gadget-autosave-select' ).click( function() {
					$( '#gadget-autosave-textarea' ).select();
				} );
				$( '#gadget-autosave-settings' ).click( function( e ) {
					$( e.currentTarget ).closest( '.oo-ui-window-content' ).focus();
					dialog.html(
						'<p>' + typeofoptions + '</p>' +
						'<button id="gadget-autosave-settings-length" title="' + lengthbuttontitle + '">' + lengthbuttontext + '</button>' +
						'<button id="gadget-autosave-settings-time" title="' + timebuttontitle + '">' + timebuttontext + '</button>'
					);
					$( '#gadget-autosave-settings-length' ).click( function() {
						dialog.html(
							'<p>' + settingsdescriptionlength + '</p>' +
							'<input type="number">' +
							'<button id="gadget-autosave-settings-length-save" title="' + savetitle + '">' + savetext + '</button>' +
							'<button id="gadget-autosave-close" title="' + closetitle + '">' + closetext + '</button>'
						);
						$( '#gadget-autosave-dialog input' ).attr( 'value', String( getMinimumLength() ) );
						$( '#gadget-autosave-dialog input' ).focus();
						$( '#gadget-autosave-settings-length-save' ).click( function() {
							var input = $( '#gadget-autosave-dialog input' ).val();
							if ( /\d/.test( input ) ) {
								localStorage.setItem( 'gadget-autosave-length', input );
								myDialog.close();
							}
						} );
					} );
					$( '#gadget-autosave-settings-time' ).click( function() {
						dialog.html(
							'<p>' + settingsdescriptiontime + '</p>' +
							'<input type="number">' +
							'<button id="gadget-autosave-settings-time-save" title="' + savetitle + '">' + savetext + '</button>' +
							'<button id="gadget-autosave-close" title="' + closetitle + '">' + closetext + '</button>'
						);
						$( '#gadget-autosave-dialog input' ).attr( 'value', String( getTimeInterval() ) );
						$( '#gadget-autosave-dialog input' ).focus();
						$( '#gadget-autosave-settings-time-save' ).click( function() {
							var input = $( '#gadget-autosave-dialog input' ).val();
							if ( /\d/.test( input ) ) {
								localStorage.setItem( 'gadget-autosave-time', input );
								myDialog.close();
							}
						} );
					} );
					if ( localStorage.getItem( 'svwikigadgetautosave' ) ) {
						dialog.append(
							'<button id="gadget-autosave-removelocalstorage" title="' + removelocalstoragetitle + '">' + removelocalstoragetext + '</button>'
						);
						$( '#gadget-autosave-removelocalstorage' ).click( function() {
							localStorage.removeItem( 'svwikigadgetautosave' );
							myDialog.close();
						} );
					}
					if ( localStorage.getItem( 'gadget-autosave-length' ) ) {
						dialog.append(
							'<button id="gadget-autosave-removesavedlength" title="' + removesavedlengthtitle + '">' + removesavedlengthtext + '</button>'
						);
						$( '#gadget-autosave-removesavedlength' ).click( function() {
							localStorage.removeItem( 'gadget-autosave-length' );
							myDialog.close();
						} );
					}
					if ( localStorage.getItem( 'gadget-autosave-time' ) ) {
						dialog.append(
							'<button id="gadget-autosave-removesavedtime" title="' + removesavedtimetitle + '">' + removesavedtimetext + '</button>'
						);
						$( '#gadget-autosave-removesavedtime' ).click( function() {
							localStorage.removeItem( 'gadget-autosave-time' );
							myDialog.close();
						} );
					}
					dialog.append( '<button id="gadget-autosave-close" title="' + closetitle + '">' + closetext + '</button>' );
				} );
				dialog.on( 'click', '#gadget-autosave-close', function() {
					myDialog.close();
				} );
			}
		} );
	} );
}

/* RC: Hide user */
( function() {
	'use strict';
	var key = 'gadget-rcexcludeuser-excludedusers';
	var v = mw.config.get();
	var hideClass = 'gadget-rcexcludeuser-hidden';
	function removeUnsafeCharacters( str ) {
		var unsafeCharacters = /[\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
		return str.replace( unsafeCharacters, '' );
	}
	function getExcludedUsers() {
		var output = localStorage.getItem( key );
		if ( output ) {
			output = output.trim();
			if ( output ) {
				output = removeUnsafeCharacters( output );
				return output.split( '\n' );
			}
		}
		return [];
	}
	function hideExcludedUsers() {
		var excludedusers = getExcludedUsers();
		$( '.mw-changeslist' ).children( '.special' ).children( 'li' ).each( function( i, e ) {
			$( e ).removeClass( hideClass );
			var user = $( e ).find( '.mw-userlink' ).first().text();
			if ( excludedusers.includes( user ) ) {
				$( e ).addClass( hideClass );
			}
		} );
	}
	$( function() {
		var buttontitle = 'Hide actions from users you trust';
		var buttontext = 'Hide users';
		var label = 'Exclude users (separate with newline)';
		if ( v.wgUserLanguage === 'sv' ) {
			buttontitle = 'Dölj handlingar från användare du litar på';
			buttontext = 'Dölj användare';
			label = 'Exkludera användare (separera med radbrytning)';
		}
		if ( $( '.mw-changeslist' ).length ) {
			$( '#firstHeading' ).append( '<button type="button" title="' + buttontitle + '" id="gadget-rcexcludeuser-button">' + buttontext + '</button>' );
			$( '#gadget-rcexcludeuser-button' ).click( function() {
				var settingsstr = '<div>';
				settingsstr += '<p><label for="gadget-rcexcludeuser-textarea">' + label + '</label></p>';
				settingsstr += '<textarea id="gadget-rcexcludeuser-textarea"></textarea>';
				settingsstr += '</div>';

				// Creating and opening a simple dialog window.

				// Subclass Dialog class. Note that the OOjs inheritClass() method extends the parent constructor's prototype and static methods and properties to the child constructor.

				function MyDialog( config ) {
					MyDialog.super.call( this, config );
				}
				var myDialog;
				var windowManager;
				if ( $( '.oo-ui-window-active' ).length === 0 ) {
					OO.inheritClass( MyDialog, OO.ui.Dialog );

					// Specify a title statically (or, alternatively, with data passed to the opening() method).
					MyDialog.static.name = 'gadgetrcexcludeuserdialog';
					MyDialog.static.title = 'Simple dialog';

					// Customize the initialize() function: This is where to add content to the dialog body and set up event handlers.
					MyDialog.prototype.initialize = function () {
						// Call the parent method
						MyDialog.super.prototype.initialize.call( this );
						// Create and append a layout and some content.
						this.content = new OO.ui.PanelLayout( {
							padded: true,
							expanded: false
						} );
						this.content.$element.append( settingsstr );
						this.$body.append( this.content.$element );
						$( '#gadget-rcexcludeuser-textarea' ).val( ( getExcludedUsers() ).join( '\n' ) );
						$( '#gadget-rcexcludeuser-textarea' ).on( 'input', function( e ) {
							var input = $( e.currentTarget ).val().trim();
							if ( input ) {
								input = removeUnsafeCharacters( input );
								localStorage.setItem( key, input );
							} else {
								localStorage.removeItem( key );
							}
						} );
						$( '.oo-ui-windowManager' ).click( function( e ) {
							if ( !$( e.target ).parents().filter( '.oo-ui-window' ).length ) {
								myDialog.close();
							}
						} );
					};

					// Set up the ready mode of the window. 
					MyDialog.prototype.getReadyProcess = function ( data ) {
						return MyDialog.super.prototype.getReadyProcess.call( this, data )
						.next( function () {
							$( '#gadget-rcexcludeuser-textarea' ).focus();
						}, this );
					};

					// Use the getTeardownProcess() method to perform actions whenever the dialog is closed.
					// This method provides access to data passed into the window's close() method
					// or the window manager's closeWindow() method.
					MyDialog.prototype.getTeardownProcess = function ( data ) {
						return MyDialog.super.prototype.getTeardownProcess.call( this, data )
						.first( function () {
							// Perform any cleanup as needed
							$( '.oo-ui-windowManager' ).remove();
							hideExcludedUsers();
						}, this );
					};

					// Make the window.
					myDialog = new MyDialog( {
						classes: [
							'gadget-rcexcludeuser-dialog'
						]
					} );

					// Create and append a window manager, which will open and close the window.
					windowManager = new OO.ui.WindowManager();
					$( 'body' ).append( windowManager.$element );

					// Add the window to the window manager using the addWindows() method.
					windowManager.addWindows( [ myDialog ] );

					// Open the window!
					windowManager.openWindow( myDialog );
				}
			} );
			hideExcludedUsers();
		}
	} );
	mw.hook( 'wikipage.content' ).add( function( elements ) {
		if ( elements.hasClass( 'mw-changeslist' ) ) {
			hideExcludedUsers();
		}
	} );
}() );
/* Add a floating JavaScript alert when my talk page gets edited */
( function( $, mw ) {
$alert = '<div id="mw-echo-sliding-alert">';
$alert += '<div id="mw-echo-close-box"><img style="display: block;" src="//upload.wikimedia.org/wikipedia/commons/3/36/CloseWindow.svg"/></div>';
$alert += '<div id="mw-echo-alert-text">you have<a href="#" id="mw-echo-talk-link">new unread messages</a> on your discussion page. (<a href="#" id="mw-echo-talk-diff-link">diff</a>)</div>';
$alert += '</div>';
$(document).ready(function() {
	var newMsgRevisionId = mw.config.get( 'wgUserNewMsgRevisionId' );
	if ( newMsgRevisionId ) {
		var userName = mw.config.get( 'wgUserName' );
		var talkLink = '/User_talk:' + userName + '?redirect=no';
		var diffLink = '/index.php?title=User_talk:' + userName + '&oldid=' + newMsgRevisionId + '&diff=cur';
		$( 'body' ).append( $alert );
		$( '#mw-echo-close-box' ).click( function( e ) {
			$( '#mw-echo-sliding-alert' ).hide();
			e.preventDefault();
		} );
		$( 'a#mw-echo-talk-link' ).attr( 'href', talkLink );
		$( 'a#mw-echo-talk-diff-link' ).attr( 'href', diffLink );
		mw.config.set( 'echoNewMsgAlertDisplayed', true );
	}
} );
} )( jQuery, mediaWiki );
//[[Category:Wikipedia scripts]]

/**
 * Ajax Undo links
 *
 * Adds an Ajax undo link next to the normal undo link on page histories
 * and on diff pages
 */
 
jQuery(document).ready( function ( $ ) {
	"use strict";
 
	function createUndoLink( diffUndoUrl ) {
		var $ajaxUndoLink = $( '<a />' ).text( 'AJAX-ångra' ).attr( 'href', '#' ).click( function () {
			var	$ajaxUndoLinkob = $( this ),
				undoIdRegex = /&undo=([^&]*)/,
				undoId = undoIdRegex.exec( diffUndoUrl )[1],
				editToken,
				etUrl = wgServer + wgScriptPath + '/api.php?action=query&prop=info|revisions&intoken=edit&titles=' + encodeURIComponent( wgPageName ) + '&format=json';
			$ajaxUndoLinkob.html( ' <img src="http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif" style="vertical-align: baseline;" border="0" alt="Undoing..." />' );
			$.getJSON( etUrl, function ( data ) {
				editToken = data.query.pages[wgArticleId].edittoken;
				$.ajax( {
					url: wgScriptPath + '/api.php?',
					data: 'action=edit&format=json&title=' + encodeURIComponent( wgPageName ) + '&undo=' + encodeURIComponent( undoId ) + '&minor=yes&token=' + encodeURIComponent( editToken ),
					dataType: 'json',
					type: 'POST',
					success: function ( data ) {
						if ( data.edit && data.edit.result === 'Success' ) {
							$ajaxUndoLinkob.text( '(undone)' );
						} else if ( data.error && data.error.code === 'undofailure' ) {
							$ajaxUndoLinkob.text( '(error)' );
							alert( data.error.info );
						} else {
							$ajaxUndoLinkob.text( '(error)' );
							alert( 'Tyvärr: ett fel intrffade: fel på API:t. Försök igen. ' );
						}
					},
					error: function () {
						$ajaxUndoLinkob.text( '(error)' );
					}
				} );
			} );
		} );
		return $ajaxUndoLink;
	}
 
	if ( $( '.mw-history-undo > a' ).length && wgAction === 'history' ) {
		$( '.mw-history-undo > a' ).each( function () {
			var	diffUndoUrl = $( this ).attr( 'href' ),
				$ajaxUndoLink = createUndoLink( diffUndoUrl );
			$( this ).parent().after( ' | ', $ajaxUndoLink );
		} );
	} else if ( $( 'table.diff' ).length && typeof $.getUrlVar( 'diff' ) !== 'undefined' ) {
		var	$diffUndoLink = $( 'table.diff' ).find( '.diff-ntitle > #mw-diff-ntitle1 a:last' ),
			diffUndoUrl = $diffUndoLink.attr( 'href' ),
			$ajaxDiffUndoLink = createUndoLink( diffUndoUrl );
		$diffUndoLink.parent().append( ' (', $ajaxDiffUndoLink, ')' );
	}
} );