User:Psl85/common.js

mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Majr/goToTop.js&action=raw&ctype=text/javascript' ); $( function {	'use strict';	var restrictions = mw.config.get( 'wgRestrictionEdit' );	if ( restrictions ) {		if ( restrictions.indexOf( 'sysop' ) !== -1 ) {			$( '.mw-indicators' ).prepend( '' );		} else if ( restrictions.indexOf( 'autoconfirmed' ) !== -1 ) {			$( '.mw-indicators' ).prepend( '' );		}	} } );

if ( mw.config.get( 'wgRelevantUserName' ) ) { $( function {		'use strict';		var title = 'This user or IP address 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(					'' +						'' +					''				); }		} );	} ); }

/** * @source mediawiki.org/wiki/Snippets/Open_external_links_in_new_window * @version 4 */ mw.hook('wikipage.content').add(function($content) {       $content.find('a.external').each(function  { // Can't use wgServer because it can be protocol relative // Use this.href property instead of this.getAttribute('href') because the propery // is converted to a full URL (including protocol) if (this.href.indexOf(location.protocol + '//' + location.hostname) !== 0) { this.target = '_blank'; }       }); });

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

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

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

/** * charinsert loader */

if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) { mw.loader.load( 'ext.gadget.charinsert-core' ); }

$( 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: 'JavaScript Error',		type: 'error'	} ); if (originalErrorHandler) { return originalErrorHandler.apply(this, arguments); } }; // unbind on leaving the page $( window ) .on( 'unload', function {		window.onerror = originalErrorHandler;	} ); $( function {	'use strict';	var v = mw.config.get;	var username = v.wgRelevantUserName;	var text = 'This user is ';	var autopatrolled = 'autopatrolled.';	var grasp = 'a GRASP member.';	var bot = 'a bot (with a bot flag).';	var sysop = 'a sysop.';	var bureaucrat = 'a bureaucrat.';	var checkuser = 'a checkuser.';	var oversight = 'an oversighter.';	var globalrollbacker = 'a global rollbacker.';	var globalbot = 'a global bot (with global bot status).';	var globalsysop = 'a global sysop.';	var wikiguardian = 'a wiki guardian.';	var height = 20;	var dfw = 200;	var dfh = 200;	var classes = 'mw-indicator gadget-groupindicator';	var id = 'mw-indicator-group-';	var indicators = $( '#content' ).children( '.mw-indicators' );	var local;	var global;	if ( username ) {		indicators.prepend( '  ' );		local = $( '.gadget-groupindicator-local' );		global = $( '.gadget-groupindicator-global' );		$.getJSON( '/w/api.php?action=query&list=users&usprop=groups&ususers=' + username + '&format=json', function ( data ) { var q = data.query; var groups; if ( q ) { groups = q.users[ 0 ].groups; if ( groups ) { if ( groups.indexOf( 'autopatrolled' ) !== -1 ) { local.append( '' ); }						if ( groups.indexOf( 'grasp' ) !== -1 ) { local.append( '' ); }						if ( groups.indexOf( 'bot' ) !== -1 ) { local.append( '' ); }						if ( groups.indexOf( 'sysop' ) !== -1 ) { local.append( '</a>' ); }						if ( groups.indexOf( 'bureaucrat' ) !== -1 ) { local.append( '<img src="//upload.wikimedia.org/wikipedia/commons/9/95/Wikipedia_bureaucrat.svg" height="' + height + '" title="' + text + bureaucrat + '"></a>' ); }						if ( groups.indexOf( 'checkuser' ) !== -1 ) { local.append( '<img src="//upload.wikimedia.org/wikipedia/commons/b/b5/Wikipedia_Checkuser.svg" height="' + height + '" title="' + text + checkuser + '"></a>' ); }						if ( groups.indexOf( 'oversight' ) !== -1 ) { local.append( '<img src="//upload.wikimedia.org/wikipedia/commons/0/06/Oversight_logo.png" height="' + height + '" title="' + text + oversight + '"></a>' ); }					}				}			}		);		$.getJSON( '/w/api.php?action=query&meta=globaluserinfo&guiprop=groups&guiuser=' + username + '&format=json', function ( data ) { var q = data.query; var groups; if ( q ) { groups = q.globaluserinfo.groups; if ( groups ) { if ( groups.indexOf( 'global-rollbacker' ) !== -1 ) { global.append( '<img src="//upload.wikimedia.org/wikipedia/commons/a/a1/Meta-Wiki_Global_rollback-2000px.png" height="' + height + '" title="' + text + globalrollbacker + '"></a>' ); }						if ( groups.indexOf( 'global-bot' ) !== -1 ) { local.append( '<img src="//upload.wikimedia.org/wikipedia/commons/0/05/Robot_icon.svg" height="' + height + '" title="' + text + globalbot + '"></a>' ); }						if ( groups.indexOf( 'global-sysop' ) !== -1 ) { global.append( '<img src="//upload.wikimedia.org/wikipedia/commons/5/57/Meta-Wiki_Global_sysop-2000px.png" height="' + height + '" title="' + text + globalsysop + '"></a>' ); }						if ( groups.indexOf( 'wikiguardian' ) !== -1 ) { global.append( '<img src="//upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg" height="' + height + '" title="' + text + steward + '"></a>' ); }					}				}			}		);	} } );

/* Vandal Warner, version [0.2.0]

Created and maintained by User:Huji, modified by User:Hoo man Based on Whackamole, a script written by User:Pilotguy */

var WarnVandalList, WarnVandalSig; var WarnVandalItems = []; var WarnVandalCustomItems = [];

WarnVandalItems.push( ['uw-test', 1, 'Test edit', 'Testedit'] ); WarnVandalItems.push( ['uw-vandalism', 1, 'Vandalism', 'Vandalism'] ); WarnVandalItems.push( ['uw-delete', 1, 'Removing of contents', 'remove'] ); WarnVandalItems.push( ['uw-wrong', 1, 'Wrong info', 'wrong1'] ); WarnVandalItems.push( ['user warning1', 1, 'Vandalism notice', 'uw1'] ); WarnVandalItems.push( ['user warning2', 1, 'Vandalism caution', 'uw2'] ); WarnVandalItems.push( ['user warning3', 1, 'Vandalism warning', 'uw3'] ); WarnVandalItems.push( ['user warning4', 1, 'Final vandalism warning', 'uw4'] ); WarnVandalItems.push( ['blocked', 2, 'Blocked', 'Blocked'] ); WarnVandalItems.push( ['Welcome', 0, 'Welcome to Minecraft Wiki', 'Welcome 1'] ); WarnVandalItems.push( ['Welcome-anon', 0, 'Welcome to Minecraft Wiki (Anon)', 'Welcome 2'] ); WarnVandalItems.push( ['Welcome-vanda', 0, 'Welcome to Minecraft Wiki', 'Welcome vandal'] );

function WarnVandal (message, param, summary) { var tbox = document.getElementById('wpTextbox1'); var a = "" + (window.getSelection ? window.getSelection    : document.getSelection ? document.getSelection        : document.selection.createRange.text); if (param != "") { a = prompt ("Article name?\n(Empty+OK for a generic message.)\n(Cancel now aborts.)", a); if (a == null) return; if (a != null && a != "") { message = message.replace(/\|/,"|"+a); summary += " in " + a + ""; } else { message = param; }  }   if (WarnVandalSig == undefined) { WarnVandalSig = " " + "\n"; }  document.getElementById('wpTextbox1').value += message + WarnVandalSig; document.getElementById('wpSummary').value = summary; document.getElementById('wpMinoredit').checked=false; document.getElementById('wpWatchthis').checked=false; document.getElementById('wpTextbox1').focus; if (document.getElementById('wpTextbox1').scrollTop || true) { document.getElementById('wpTextbox1').scrollTop = document.getElementById('wpTextbox1').scrollHeight; } } window.WarnVandal_addlilink=function(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); WarnVandalList.appendChild(li); if(id) { if(key && title) ta[id] = [key, title]; else if(key)    ta[id] = [key]; else if(title)  ta[id] = ['', title]; }  return li; } window.WarnVandal_addToolboxLink=function(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; WarnVandal_addlilink(tb, url, name, id); } $(document).ready( function {  if ((mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') && mw.config.get('wgCanonicalNamespace') === 'User_talk') {    var link_div = document.createElement('div');	if(mw.config.get('skin') === 'vector') {		link_div.className = 'body';	}else{	    link_div.className = 'pBody';	}	WarnVandalList = document.createElement('ul');    link_div.appendChild(WarnVandalList);    var div = document.createElement('div');    div.setAttribute('id', 'p-vandalwarner');    var heading = document.createElement('h5');    heading.appendChild(document.createTextNode('Vandal Warner'));    div.appendChild(heading);    div.appendChild(link_div);

if (WarnVandalCustomItems.length > 0){ for (i=0; i<WarnVandalCustomItems.length; i++) { itm = WarnVandalCustomItems[i]; WarnVandal_addToolboxLink('javascript:WarnVandal ("{'+'{subst:'+itm[0]+'|}}", ' + (itm[1] ? '"{'+'{subst:'+itm[0]+'}}"' : '""') + ', ' + '"'+itm[2]+'"); void(0);', itm[3], ''); }   } else { for (i=0; i<WarnVandalItems.length; i++) { itm = WarnVandalItems[i]; WarnVandal_addToolboxLink('javascript:WarnVandal ("{'+'{subst:'+itm[0]+'|}}", ' + (itm[1] ? '"{'+'{subst:'+itm[0]+'}}"' : '""') + ', ' + '"'+itm[2]+'"); void(0);', itm[3], ''); }   }	if(mw.config.get('skin') === 'vector') { document.getElementById('mw-panel').insertBefore(div, document.getElementById('p-tb')); div.className = 'portal'; }else{ div.className = 'portlet'; var side_col = document.getElementById('column-one'); var node = document.getElementById('p-tb'); side_col.insertBefore(div, node); } } });

// ********************************************************************** // **                ***WARNING GLOBAL GADGET FILE***                 ** // **            changes to this file affect many users. ** // **          please discuss on the talk page before editing         ** // **                                                                 ** // ********************************************************************** // Imported from User:Alex Smotrov/edittop.js, version as of: 2007-06-19T04:28:52 // Updated from User:TheDJ/Gadget-edittop.js, version as of: 2009-04-28T11:54:22

if ($.inArray( mw.config.get('wgAction'), [ 'view', 'purge' ]) !== -1 && mw.config.get( 'wgNamespaceNumber' ) >=0) { $(function edittop_hook {    var localtitles = {      bg: 'Редактиране на началото',      bn: 'সূচনা অনুচ্ছেদ সম্পাদনা করুন',      cs: 'Editovat úvodní sekci',      da: 'Rediger hoveddelen af artikeln'      en: 'Edit the intro section,      fa: 'ویرایش بخش آغازین',      fr: 'Modifier le résumé introductif',      id: 'Sunting bagian atas',      it: 'Modifica della sezione iniziale',      ja: '導入部を編集',      kk: 'Кіріспе бөлімді өңдеу',      min: 'Suntiang bagian ateh',      ko: '도입부를 편집',      no: 'Rediger artikkelns hovedseksjon'      pa: 'ਸੋਧ',      pt: 'Editar a seção superior',      'pt-br': 'Editar a seção superior',      sr: 'Уреди уводни део',      sv: 'Redigera artikelns intro',      vi: 'Sửa phần mở đầu'    };

var our_content = $("#content, #mw_content").first; var span1 = our_content.find("span.mw-editsection:not(.plainlinks)").first; if (!span1.length) { return; }   var span0 = span1.clone;

$("#mw_header h1, #content h1").first.append(span0); span0.find("a").each(function (idx) {     var a = $(this);      a.attr("title", localtitles[mw.config.get( 'wgUserLanguage' )] || localtitles.en);      if ( !/&(ve|)section=T/.test( a.attr( "href" ) ) ) { // not transcluded        a.attr( "href", a.attr( "href" ).replace( /&(ve|)section=\d+/, "&$1section=0&summary=/*%20top%20*/%20" ) );      } else if ( /&vesection=/.test( a.attr( "href" ) ) ) { // transcluded, VE        a.attr( "href", mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + "?veaction=edit&vesection=0&summary=/*%20top%20*/%20" );      } else { // transcluded, not VE        a.attr( "href", mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + "?action=edit&section=0&summary=/*%20top%20*/%20" );      }    }); }); }

/** * charinsert loader */

if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) { mw.loader.load( 'ext.gadget.charinsert-core' ); }