Jump to content

User:Technical 13/Scripts/Gadget-listStyles.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Technical 13 (talk | contribs) at 13:46, 16 September 2013 (Revamp to reduce redundancy and add another page to list.). 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.
var path = $( 'ul' );
var nsNumber = mw.config.get( 'wgNamespaceNumber' );
var pageName = mw.config.get( 'wgPageName' );
var pageAction = mw.config.get( 'wgAction' );
function addPtLink(pID, nextnode, path){
	var listStyle = mw.util.addPortletLink(
		'p-' + pID,
		'#',
		'(list style)',
		'pt-liststyle',
		'Switch list style between bullet and numbered [alt-shift-`]',
		'`',
		'#pt' + nextnode
	);
	$( listStyle ).click( function ( e ) {
		e.preventDefault();
		path.css( 'list-style-image', 'none' );
		path.css( 'list-style-type', function (i, val) {
			return val === "decimal" ? "disc" : "decimal";
		});
	});
}
// [[Special:WhatLinksHere]]
if ( pageName.indexOf( 'Special:WhatLinksHere' ) != -1){
	path = $( 'ul#mw-whatlinkshere-list' );	
	addPtLink('personal', 'userpage', path);
}
// [[Special:Contributions]]
else if ( pageName.indexOf( 'Special:Contributions' ) != -1){
	path = $('a.mw-changeslist-date').parents('ul');
	addPtLink( 'p-personal', 'logout', path );
}
// &action=history
if ( pageAction == "history" ){
	path = $( 'ul#pagehistory' );
	addPtLink( 'personal', 'userpage', path );
}
// [[Category:]]
else if ( nsNumber === 14){
	path = $( 'div.mw-content-ltr' ).children( 'ul' );
	addPtLink( 'personal', 'userpage', path);
}