Jump to content

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

From Wikipedia, the free encyclopedia
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' );
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";
		});
	});
}
var pageAction = mw.config.get( 'wgAction' );
if ( pageAction != 'history' ){
	var nsNumber = mw.config.get( 'wgNamespaceNumber' );
	if ( nsNumber === -1 ){
		// Special: pages
		var specialPageName = mw.config.get( 'wgCanonicalSpecialPageName' );
		if ( specialPageName == 'Whatlinkshere' ){
			// [[Special:WhatLinksHere]]
			path = $( 'ul#mw-whatlinkshere-list' );	
			addPtLink('personal', 'userpage', path);
		} 	else if ( specialPageName == 'Contributions' ){
			// [[Special:Contributions]]
			path = $('a.mw-changeslist-date').parents('ul');
			addPtLink( 'personal', 'logout', path );
		}
	} else if ( nsNumber != 14){
//		var pageNameList = mw.config.get( 'wgPageName' );
	} else {
		// [[Category:]]
		path = $( 'div.mw-content-ltr' ).find( 'ul' );
		addPtLink( 'personal', 'userpage', path);
	}
} else {
	// &action=history
	path = $( 'ul#pagehistory' );
	addPtLink( 'personal', 'userpage', path );
}