Gebruiker:Jos1950/vector.js: verschil tussen versies

Uit LinuxMintNL WiKi
Ga naar: navigatie, zoeken
(controle)
(VectorSandBox js)
 
(5 tussenliggende versies door dezelfde gebruiker niet weergegeven)
Regel 1: Regel 1:
 +
/**
 +
* 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
  
/* User links als in monobook */
+
// Use Special:MyPage (as opposed to mw.user.getName()) so that it
/* Note to self: geen pop-ups, geen hotkeys */
+
// works for logged-out users as well.
+
title = new mw.Title( 'Special:MyPage/' + conf.subpageName );
addOnloadHook(function () {
 
with (document) {
 
  getElementById('pt-mytalk').innerHTML = '<a href="/wiki/User_talk:' + wgUserName + '">overleg</a>';
 
  getElementById('pt-preferences').innerHTML = '<a href="/wiki/Special:Preferences">voorkeuren</a>';
 
  getElementById('pt-watchlist').innerHTML = '<a href="/wiki/Special:Watchlist">volglijst</a>';
 
  getElementById('pt-mycontris').innerHTML = '<a href="/wiki/Special:Contributions/' + wgUserName + '">bijdragen</a>';
 
  getElementById('pt-logout').innerHTML = '<a href="/wiki/Special:UserLogout">afmelden</a>';
 
}
 
})
 
  
// === Unwatchlink per item op volglijst ===
+
url = new mw.Uri( title.getUrl() );
// Geeft op de volglijst een link "niet volgen" bij elk artikel
+
url.extend( {
+
action: 'edit',
addOnloadHook(function () {
+
redlink: 1,
+
editintro: new mw.Title( conf.editintroPagename ),
    // Alleen voor "Volglijst":
+
preload: new mw.Title( conf.preloadPagename )
    if (window.location.href.indexOf("Speciaal:Volglijst") == -1) return;  
+
} );
+
 
    // Niet voor "Volglijst bekijken en bewerken":
+
mw.util.addPortletLink(
    if (window.location.href.indexOf("Speciaal:Volglijst/edit") > 0) return;
+
'p-personal',
+
url,
    // Idem, via link op "Ruwe volglijst bewerken":
+
conf.portletLabel,
    if (window.location.href.indexOf("Special:Watchlist/raw") > 0) return;
+
'pt-sandbox',
+
conf.portletTooltip,
    var query_prefix = "&action=unwatch";
+
null,
    var count = 0;
+
'#pt-preferences'
    var links = document.getElementById('content').getElementsByTagName('a');
+
);
    for (var i = 0; i < links.length; i++) {
+
} );
        if (links[i].href.substring(links[i].href.length-15) != '&action=history')
+
}( mediaWiki, jQuery ) );
            continue;
 
        var unwatch = document.createElement('a');
 
        count++;
 
        if (count>35) {
 
        break;
 
        }
 
        unwatch.href = "/w/index.php?title=" + encodeURIComponent(links[i].title) + query_prefix;
 
        unwatch.title = "Verwijder "+links[i].title+" van je volglijst";
 
        unwatch.appendChild(document.createTextNode("unwatch"));
 
        links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);
 
        // kluge to handle case where "diff" is unlinked:
 
        var delim = links[i].previousSibling;
 
        delim = (delim.nodeType == 3 ? delim.nodeValue : "");
 
        links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch);
 
    }
 
 
});
 

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