Jump to content

User:Jackmcbarn/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jackmcbarn (talk | contribs) at 03:30, 4 July 2014 (missed one). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$('span.mw-rollback-link a').click(function(){return confirm("Rollback: Are you sure?")}); // Require confirmation for rollback
importScript('User:Jackmcbarn/advancedtemplatesandbox.js'); // Linkback: [[User:Jackmcbarn/advancedtemplatesandbox.js]]

// If you want this next script, you probably want to remove -unstable from it
importScript('User:Jackmcbarn/editProtectedHelper-unstable.js'); // Linkback: [[User:Jackmcbarn/editProtectedHelper.js]]

if(!document.getElementById('mw-scribunto-console')) {
	$('.templatesUsed').before('<div id="mw-scribunto-console"></div>');
	mw.loader.load('ext.scribunto.edit');
}

if(/^User:.*\/(CSD|PROD)_log$/.test(mw.config.get('wgPageName'))) {
	$('#mw-content-text').prepend($('<button>Show/hide redlinked pages</button>').click(function(){
		$('ol>li>a.new:first-child').parent().toggle();
	}));
}

importScript('User:Dr pda/prosesize.js');
importScript('User:Mr.Z-man/closeAFD.js');
importScript('User:Anomie/previewtemplatelastmod.js'); // Linkback: [[User:Anomie/previewtemplatelastmod.js]]
window.LinkClassifierOnDemand = true; // not really, but we want to make our own onLoad hook
$(importScript('User:Anomie/linkclassifier.js')) // Linkback: [[User:Anomie/linkclassifier.js]]
	.load(function() {
		$(document).ready(function() {
			window.LinkClassifierOnDemand = false;
			LinkClassifier.cats['soft-redirect'] = ['Category:Wikipedia soft redirects', 'Category:Protected soft redirects', 'Category:Redirects to Wiktionary'].sort();
			LinkClassifier.onLoad();
		});
	});
importStylesheet('User:Jackmcbarn/linkclassifier.css');
importScript('User:Anomie/talklink.js'); // Linkback: [[User:Anomie/talklink.js]]
importStylesheet('User:Jackmcbarn/talklink.css'); // Linkback: [[User:Jackmcbarn/talklink.css]]
importScript('User:Jackmcbarn/parsoidview.js'); // Linkback: [[User:Jackmcbarn/parsoidview.js]]

if( mw.config.get('wgNamespaceNumber') === 10 && mw.config.get('wgAction') === 'edit' &&  $( '.template-documentation' ).length !== -1){
	$( '.template-documentation,.template-documentation+*' ).css( 'display', 'none');
	var tnd = mw.util.addPortletLink(
		'p-tb',
		'#',
		'View doc',
		'pt-temp-doc',
		'View template documentation',
		null,
		null
	);
	$( tnd ).click( function ( e ) {
		e.preventDefault();
		/* Toggle documentation display */
		$( '.template-documentation,.template-documentation+*' ).css( 'display', function (i, val) {
			return val === 'none' ? '' : 'none';
		});
		/* Toggle the link */
		$( 'li#pt-temp-doc a' ).html( function (i, val) {
			return val === 'View doc' ? 'Hide doc' : 'View doc';
		});
		/* Toggle the description */
		$( 'li#pt-temp-doc a' ).attr( 'title', function (i, val) {
			return val === 'View template documentation' ? 'Hide template documentation' : 'View template documentation';
		});
	});
} else {
	/*               Do nothing               */
}