Gebruiker:Jos1950/vector.js: verschil tussen versies

Uit LinuxMintNL WiKi
Ga naar: navigatie, zoeken
(proef)
(VectorSandBox js)
 
(2 tussenliggende versies 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.
   
+
*
// Add an [edit] link to pages
+
* Required modules: mediawiki.util, mediawiki.Title, mediawiki.Uri
addOnloadHook(function () {
+
*
// if this is preview page or generated page, stop
+
* @source https://www.mediawiki.org/wiki/Snippets/MySandbox
if(
+
  * @version 2014-07-16
document.getElementById("wikiPreview") ||
+
*/
document.getElementById("histlegend‎") ||
+
( function ( mw, $ ) {
document.getElementById("difference‎") ||
+
$( function () {
document.getElementById("watchdetails") ||
+
var conf, title, url;
document.getElementById("ca-viewsource") ||
+
 
window.location.href.indexOf("/wiki/Special:") != -1
+
// Customize/Translate this to your needs
) {
+
conf = {
if(window.location.href.indexOf("&action=edit&section=0") != -1) {
+
subpageName: 'sandbox',
document.getElementById("wpSummary").value = "/* Intro */ ";
+
portletLabel: 'Sandbox',
}
+
portletTooltip: 'Go to your sandbox',
return;
+
editintroPagename: 'Template:User_sandbox',
};
+
preloadPagename: 'Template:User_sandbox/preload'
+
};
// get the page title
+
// Don't alter the code below
var pageTitle = wgPageName;
+
 
+
// Use Special:MyPage (as opposed to mw.user.getName()) so that it
// create div and set innerHTML to link
+
// works for logged-out users as well.
var divContainer = document.createElement("div");
+
title = new mw.Title( 'Special:MyPage/' + conf.subpageName );
divContainer.innerHTML = '<div class="editsection">[<a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="Edit section: '+pageTitle+'">edit intro</a>]</div>';
+
 
+
url = new mw.Uri( title.getUrl() );
// insert divContainer into the DOM below the h1
+
url.extend( {
if(window.location.href.indexOf("&action=edit") == -1) {
+
action: 'edit',
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[1]);
+
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 ) );

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 ) );