User:User-100152098/common.js

mw.loader.localLoad = function( url ) { return mw.loader.load( '//minecraft.gamepedia.com/index.php?title=' + url + '&action=raw&ctype=text/javascript' ); };

/** Scripts **/

// User:Majr/Prism.js // Adds JavaScript, CSS and Lua syntax highlighting, see file for license // Requires a theme from http://prismjs.com to be added to usercss mw.loader.localLoad( 'User:Majr/Prism.js' );

// User:Majr/inputCounter.js // Adds a character counter to input fields mw.loader.localLoad( 'User:Majr/inputCounter.js' );

// User:Majr/codeLinks.js mw.loader.localLoad( 'User:Majr/codeLinks.js' );

// User:Majr/renderConsoleOutput.js // Allows the output wikitext of the lua console to be rendered if ( $( '#mw-scribunto-console' ).length ) { mw.loader.localLoad( 'User:Majr/renderConsoleOutput.js' ); }

/** General fixes **/

$( function { 'use strict';

// Replaces the Special:Achievements tab with the Special:MyPage/Sandbox tab $('#pt-achievements a').attr({ href: '/User:' + mw.config.get( 'wgUserName' ) + '/Sandbox' }).text('Sandbox');

// Makes one of the user links my profile, and the other the userwiki $('.netbar-box.right li.user a').attr({ href: '/UserProfile:' + mw.config.get( 'wgUserName' ) }).text( 'Profile' );

// Add a subpages link to pages if ( mw.config.get( 'wgArticleId' ) != 0 ) { mw.util.addPortletLink (		'p-tb',		'/Special:PrefixIndex/' + mw.config.get( 'wgRelevantPageName' ) + '/',		'Subpages',		't-subpages',		'Subpages of the article'	); }

/* View source link */ {	mw.util.addPortletLink (		'p-tb',		'/index.php?title=' + mw.config.get( 'wgRelevantPageName' ) + '&action=raw',		'View source',		't-viewsource',		'View the source code'	); }

/* and also a link to view the system messages */ {	mw.util.addPortletLink (		'p-tb',		'/index.php?title=' + mw.config.get( 'wgRelevantPageName' ) + '&uselang=qqx',		'View system message IDs',		't-messageid',		'View the MediaWiki system message IDs'	); } /** Mostly direct code from User:Majr/hydra.js **/

// Modify the editing toolbar if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) > -1 ) { mw.loader.using( 'ext.wikiEditor.toolbar', function {

// Modify the text added by the signature button. var $button = $( '#wikiEditor-section-main > .group-insert > a[rel="signature"]' ); if ( $button.length ) { var action = $button.data( 'action' ); action.options.pre = ' ' + ' '; $button.data( 'action', action ); }

// Add an option to insert ' } }				}			}		// Add an option to insert template braces } ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'insert', tools: { sign: { label: 'Template', type: 'button', icon: '//hydra-media.cursecdn.com/minecraft.gamepedia.com/6/6d/Button_sig.png', action: { type: 'replace', options: { pre: '' } }				}			}				// Add an option to insert comment text } ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'insert', tools: { sign: { label: 'Comment (not visible while reading)', type: 'button', icon: '//hydra-media.cursecdn.com/minecraft.gamepedia.com/6/6d/Button_sig.png', action: { type: 'replace', options: { pre: '' } }				}			}				// Add an option to insert tags } ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'insert', tools: { sign: { label: 'Span-tags', type: 'button', icon: '//hydra-media.cursecdn.com/minecraft.gamepedia.com/6/6d/Button_tag.png', action: { type: 'replace', options: { pre: ' ', post: ' ' } }				}			}		// Add characters to the symbols insert page } ).on( 'wikiEditor-toolbar-buildSection-characters', function (event, section) { section.pages.symbols.characters.push( '¦', '²{', '}²' ); } );	} ); }

// Add 0th section edit button to first infobox which is in the 0th section var $firstInfobox = $( '.notaninfobox' ).first; if ( !$firstInfobox.prevAll( 'h1, h2, h3, h4, h5, h6' ).length ) { $firstInfobox.children( '.infobox-title' ).css( 'padding-left', 50 ).prepend(		$( ' ' ).addClass( 'mw-editsection' ).css( { float: 'right', lineHeight: 'inherit' } ).append( '[',			$( '' ).prop( 'href', '/' + mw.config.get( 'wgPageName' ) + '?action=edit&section=0' ).text( 'edit' ), ']'		)	); }

} );

/* A link to make minor edit */ {	mw.util.addPortletLink (		'p-tb',		'/index.php?title=' + mw.config.get( 'wgRelevantPageName' ) + '&action=edit&minor=yes&summary=Minor+edit:',		'Minor edit',		't-minoredit',		'Make a minor edit (example: to fix a typo or fix a red link). Use the dropdown menu "Common minor edit summaries" to easily choose summary after the minor edit.'	); } mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Majr/goToTop.js&action=raw&ctype=text/javascript' );

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

if ( mw.config.get( 'wgRelevantUserName' ) ) { $( function {		'use strict';		var title = 'This username/IP is blocked from editing';		( 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(					'' +						'' +					''				); }		} );	} ); }

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

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

/* Popups while hower over links instead of the default tooltip */

window.popupStructure = 'menus'; window.popupRevertSummaryPrompt = true; window.popupMinorReverts = true; mw.loader.load('//meta.wikimedia.org/w/index.php?title=Mediawiki:Gadget-popups.js&action=raw&ctype=text/javascript'); /* [edit] link at the top section */ mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Gadget-edittop.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'); /* Auto-sign posts */

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Enterprisey/reply-link.js&action=raw&ctype=text/javascript');

mw.loader.load( '//meta.wikimedia.org/w/index.php?title=user:perhelion/signing.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');

/* Drop down menus to choose edit summary */ mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/editsummaries.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.

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

$(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 ' }     k++; }   if(x!=="") btc[i].innerHTML=x+btc[i].innerHTML; } }); //

/* 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 */ //  // **************** //  Google Lookup // **************** function whackGoogleLookup { var q = "" + (window.getSelection ? window.getSelection                                     : document.getSelection ? document.getSelection                                                              : document.selection.createRange.text); if (!q) q = prompt("You didn't select any text. Enter a search phrase:", ""); if (q!=null) // location="http://www.google.com/search?q=" + escape(q).replace(/ /g, "+"); window.open("http://www.google.com/search?q=" + escape(q).replace(/ /g, "+") ,'new-tab') ; } /* some scripts imported from home account */ mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/smartwatchlist.js&action=raw&ctype=text/javascript' );

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

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

$( function {    var tab, tablink;

tab = document.getElementById('ca-addsection'); if ( !tab ) { return; }

tablink = tab.getElementsByTagName('a')[0]; if ( !tablink ) { return; }

tablink.firstChild.nodeValue = '+'; if ( mw.config.get( 'skin' ) === 'monobook' ) { tablink.style.paddingLeft = ".4em"; tablink.style.paddingRight = ".4em"; } });

// 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 = $( ' ' ); if ( url ) { $( ' ' )			.text( url + ' at line ' + line + ': ' ) .appendTo( $msg ); }	$( ' ' )		.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;	} );

/* Notice while getting new talk page messages */

( function( $, mw ) { $alert = ' '; $alert += '  '; $alert += ' you havenew unread messages on your discussion page. (diff) '; $alert += ' '; $(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 ); //

$( '#ca-user a' ).text( 'User' ); $( '#ca-talk a' ).text( 'Talk page' ); $( '#ca-move a' ).text( 'Re Name' ); $( '#pt-preferences a' ).text( 'Options' ); $( '#pt-logout a' ).text( 'Sign Out' ); $( '#pt-mytalk a' ).text( 'My chat board' ); $( '#ca-view a' ).text( 'Read' ); $( '#ca-nstab-main a' ).text( 'Article' ); $( '#ca-edit a' ).text( 'Edit' ); $( '.mw-editsection a' ).text( 'edit' ); $( '.mw-editsection-visualeditor' ).text( 'edit' ); // keep this line after the previous line

$('#t-specialpages').before(   $('').html( $('Delete pages (?)').attr({           style: 'cursor:pointer', title: 'Click to query pending deletions'        }) ) ); $('#t-pendingdeletion').click(function pdclicked {   $.ajax({ type: "GET", url: mw.util.wikiScript('api'), data: { format: 'json', action: 'query', list: 'categorymembers', cmtitle: 'Category:Pending deletion', cmlimit: 'max' },       async: true, success: function pdresponse(catResponse) { var taggedPages = 0; for (var page in catResponse.query.categorymembers) { taggedPages += 1; }           if (taggedPages > 0) { $('#t-pendingdeletion').html(                   $('DELETE PAGES (' + taggedPages + ')').attr({ href: 'http://www.minecraftwiki.net/Category:Pending_deletion', style: 'font-weight:bold', title: 'Go to Category:Pending deletion' })               );            } else { $('#t-pendingdeletion').html(               $('Delete pages (0)</a>').attr({ style: 'cursor:pointer', title: 'Click to query pending deletions' })           );            }        }    }); });

/* Change the tab text to "Minecraft Wiki" because I do not like the default text, code obtained from User:Majr */ document.title = 'Minecraft Wiki';

/* Editing improvements */ /*        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 + '">✖ ' );	$( '#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 + ' ' ); $( '#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 ) + ' ';			} ); str += '<label for="gadget-userdefinedcomments-textarea">' + label + ' '; str += '<textarea id="gadget-userdefinedcomments-textarea"> '; str += '<button id="gadget-userdefinedcomments-close" title="' + closetitle + '">' + close + ' '; 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 = ' '; str += '<textarea id="gadget-autosave-textarea" readonly> '; str += '<button id="gadget-autosave-select" title="' + selecttitle + '">' + selecttext + ' '; str += '<button id="gadget-autosave-settings" title="' + settingstitle + '">' + settingstext + ' '; str += '<button id="gadget-autosave-close" title="' + closetitle + '">' + closetext + ' '; str += ' '; // 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( ' ' + typeofoptions + ' ' + '<button id="gadget-autosave-settings-length" title="' + lengthbuttontitle + '">' + lengthbuttontext + ' ' + '<button id="gadget-autosave-settings-time" title="' + timebuttontitle + '">' + timebuttontext + ' ' );					$( '#gadget-autosave-settings-length' ).click( function { dialog.html(							' ' + settingsdescriptionlength + ' ' +							' ' +							'<button id="gadget-autosave-settings-length-save" title="' + savetitle + '">' + savetext + ' ' +							'<button id="gadget-autosave-close" title="' + closetitle + '">' + closetext + ' '						); $( '#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(							' ' + settingsdescriptiontime + ' ' +							' ' +							'<button id="gadget-autosave-settings-time-save" title="' + savetitle + '">' + savetext + ' ' +							'<button id="gadget-autosave-close" title="' + closetitle + '">' + closetext + ' '						); $( '#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 + ' ' );						$( '#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 + ' ' );						$( '#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 + ' ' );						$( '#gadget-autosave-removesavedtime' ).click( function { localStorage.removeItem( 'gadget-autosave-time' ); myDialog.close; } );					}					dialog.append( '<button id="gadget-autosave-close" title="' + closetitle + '">' + closetext + ' ' );				} ); 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 + ' ' ); $( '#gadget-rcexcludeuser-button' ).click( function {				var settingsstr = ' ';				settingsstr += ' <label for="gadget-rcexcludeuser-textarea">' + label + ' ';				settingsstr += '<textarea id="gadget-rcexcludeuser-textarea"> ';				settingsstr += ' ';

// 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;		}	} ); } );

$( function {   mw.loader.using( [ "mediawiki.util", "mediawiki.api.edit" ] ).then( function  { var link = mw.util.addPortletLink(           "p-cactions",            "#",            "Undo last edit",            "ca-undo",            "Using the API, undo the last edit made to this page."            ); link.addEventListener( "click", function {            var api = new mw.Api;            api.get( { prop: 'revisions', rvprop: 'content', rvlimit: 2, titles: mw.config.get( "wgPageName" ) } ).done( function ( data ) { if ( !data.query || !data.query.pages ) return; var pageid = Object.getOwnPropertyNames( data.query.pages )[0], text = data.query.pages[pageid].revisions[1]["*"]; api.postWithToken( "csrf", {                   action: "edit",                    title: mw.config.get( "wgPageName" ),                    summary: "Undoing last edit (undo-last-edit)",                    minor: "yes",                    text: text                } ).done ( function ( data ) {                    if ( data && data.edit && data.edit.result && data.edit.result == 'Success' ) {                        mw.notify( "Undid last edit successfully! Reloading..." );                       document.location.reload( true );                    }                } ); } );       } );    } ); } );

/** * 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 Undo' ).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( 'Error: Unknown result from API.' ); }					},					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, ')' );	} } );