Jump to content

User:Jonpatterns/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jonpatterns (talk | contribs) at 12:49, 24 June 2016 (c). 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.
//Qwikify
//Add Wikify option to wikipedia - the option adds the {{wikify}} template to the top of the page
//Issue - requires user to be editing article, does not put anything in edit summary, {{wikify}} template is depreciated.
$(document).ready( function () {
	
	// Make sure the utilities module is loaded (will only load if not already)
	mw.loader.using( 'mediawiki.util', function () {
	
	    // Wait for the page to be parsed
	    $(document).ready( function () { 
	
	   //see below "Portlets" subsection
	        var link = mw.util.addPortletLink( 'p-cactions', '#', 'Wikify', 'ca-wikify', 'Mark for wikification'); 
	        $( link ).click( function ( event ) {
	            event.preventDefault();
	            doQwikify();
	
	        } );
	    } );
	} );
} );

function doQwikify() {
    document.editform.wpTextbox1.value = "{" + "{wikify}}\n\n" + document.editform.wpTextbox1.value;
    document.editform.submit();
}