Gebruiker:Jos1950/vector.js: verschil tussen versies

Uit LinuxMintNL WiKi
Ga naar: navigatie, zoeken
(herstel, geen zichtbaar efect)
(VectorSandBox js)
 
(Een tussenliggende versie door dezelfde gebruiker niet weergegeven)
Regel 1: Regel 1:
// This will add an [edit] link at the top of all pages except preview pages and the main page
+
/**
// by User:Pile0nades - https://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Edit_Top
+
* Add a "My sandbox" link to the personal portlet menu.
// Plaatsen op Gebruiker:Jos1950/vector.js
+
*
 +
* Required modules: mediawiki.util, mediawiki.Title, mediawiki.Uri
 +
*
 +
* @source https://www.mediawiki.org/wiki/Snippets/MySandbox
 +
* @version 2014-07-16
 +
*/
 +
( function ( mw, $ ) {
 +
$( function () {
 +
var conf, title, url;
  
// Add an [edit] link to pages
+
// Customize/Translate this to your needs
addOnloadHook(function () {
+
conf = {
// if this is preview page or generated page, stop
+
subpageName: 'sandbox',
if(
+
portletLabel: 'Sandbox',
document.getElementById("wikiPreview") ||
+
portletTooltip: 'Go to your sandbox',
document.getElementById("histlegend‎") ||
+
editintroPagename: 'Template:User_sandbox',
document.getElementById("difference‎") ||
+
preloadPagename: 'Template:User_sandbox/preload'
document.getElementById("watchdetails") ||
+
};
document.getElementById("ca-viewsource") ||
+
// Don't alter the code below
window.location.href.indexOf("/wiki/Special:") != -1
+
 
) {
+
// Use Special:MyPage (as opposed to mw.user.getName()) so that it
if(window.location.href.indexOf("&action=edit&section=0") != -1) {
+
// works for logged-out users as well.
document.getElementById("wpSummary").value = "/* Intro */ ";
+
title = new mw.Title( 'Special:MyPage/' + conf.subpageName );
}
+
 
return;
+
url = new mw.Uri( title.getUrl() );
};
+
url.extend( {
+
action: 'edit',
// get the page title
+
redlink: 1,
var pageTitle = wgPageName;
+
editintro: new mw.Title( conf.editintroPagename ),
+
preload: new mw.Title( conf.preloadPagename )
// create div and set innerHTML to link
+
} );
var divContainer = document.createElement("div");
+
 
divContainer.innerHTML = '<div class="editsection">[<a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="Edit section: '+pageTitle+'">edit intro</a>]</div>';
+
mw.util.addPortletLink(
+
'p-personal',
// insert divContainer into the DOM below the h1
+
url,
if(window.location.href.indexOf("&action=edit") == -1) {
+
conf.portletLabel,
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
+
'pt-sandbox',
}
+
conf.portletTooltip,
+
null,
});
+
'#pt-preferences'
//
+
);
 +
} );
 +
}( mediaWiki, jQuery ) );

Huidige versie van 11 feb 2017 om 15:12

/**
 * Add a "My sandbox" link to the personal portlet menu.
 *
 * Required modules: mediawiki.util, mediawiki.Title, mediawiki.Uri
 *
 * @source https://www.mediawiki.org/wiki/Snippets/MySandbox
 * @version 2014-07-16
 */
( function ( mw, $ ) {
	$( function () {
		var conf, title, url;

		// Customize/Translate this to your needs
		conf = {
			subpageName: 'sandbox',
			portletLabel: 'Sandbox',
			portletTooltip: 'Go to your sandbox',
			editintroPagename: 'Template:User_sandbox',
			preloadPagename: 'Template:User_sandbox/preload'
		};
		// Don't alter the code below

		// Use Special:MyPage (as opposed to mw.user.getName()) so that it
		// works for logged-out users as well.
		title = new mw.Title( 'Special:MyPage/' + conf.subpageName );

		url = new mw.Uri( title.getUrl() );
		url.extend( {
			action: 'edit',
			redlink: 1,
			editintro: new mw.Title( conf.editintroPagename ),
			preload: new mw.Title( conf.preloadPagename )
		} );

		mw.util.addPortletLink(
			'p-personal',
			url,
			conf.portletLabel,
			'pt-sandbox',
			conf.portletTooltip,
			null,
			'#pt-preferences'
		);
	} );
}( mediaWiki, jQuery ) );