Jump to content

User:Kaniivel/RefConsolidate start.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Kaniivel (talk | contribs) at 00:55, 6 February 2017 (add edit summary separator variable). 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.
/**
 * References Consolidator (RefCon) is a Wikipedia gadget that converts all references in an article to list-defined format.
 * It supports multiple reference templates and reference group names.
 * 
 * Copyright 2016–2017 Cumbril
 *
 * Parts of RefCon are derived from Wikipedia gadget ProveIt:
 * Copyright 2008-2011 Georgia Tech Research Corporation, Atlanta, GA 30332-0415, ALL RIGHTS RESERVED
 * Copyright 2011- Matthew Flaschen
 * Rewritten, internationalized, enhanced and maintained by Felipe Schenone since 2014
 *
 * RefCon is available under the GNU Free Documentation License (http://www.gnu.org/copyleft/fdl.html),
 * the Creative Commons Attribution/Share-Alike License 3.0 (http://creativecommons.org/licenses/by-sa/3.0/),
 * and the GNU General Public License 2 (http://www.gnu.org/licenses/gpl-2.0.html)
 */

// Make sure the document is ready and dependencies are loaded
$.when (
	$.ready,
	mw.loader.using(['mediawiki.util'])
	).done(function () {
		// Only load on appropriate namespaces
		var namespace = mw.config.get( 'wgNamespaceNumber' );
		if ( namespace === 0 || namespace === 2 ) {
			// Only load when editing wikitext (and not in common.js or common.css, for example)
			var contentModel = mw.config.get( 'wgPageContentModel' );
			if ( contentModel === 'wikitext' ) {
				// Configure the gadget for this particular wiki
				mw.config.set({
					'refcon-summary': 'Converted references to list-defined format with [[User:Cumbril/References Consolidator|References Consolidator]]', // Edit summary automatically added by RefCon
					'refcon-summaryseparator': ' + ', // Edit summary separator if summary is added to existing summary
					'refcon-linkname': 'Consolidate refs', //Portlet link name
					'refcon-linkhover': 'Consolidate references', //Text that is displayed when hovering above the link; link title
					'refcon-reftemplatenames': [ //List template {{reflist}} name and aliases that are used in wiki. Put main first
						'reflist'
					],
					'refcon-reftemplategroupnames': [ //List template {{reflist}} 'group' parameter aliases that are used in wiki. Put main first
						'group'
					],
					'refcon-reftemplaterefsnames': [ //List template {{reflist}} 'refs' parameter aliases that are used in wiki. Put main first
						'refs'
					]
				});
				mw.loader.load( '/w/index.php?title=User:Cumbril/RefConsolidate.js&action=raw&ctype=text/javascript', 'text/javascript' );
			}
		}
	}
);