Gebruiker:Rots61/common.js: verschil tussen versies

Uit Wikikids
Naar navigatie springen Naar zoeken springen
Regel 18: Regel 18:
 
}
 
}
   
mw.loader.using(['site']).done(function() {
+
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(function() {
 
if(document.getElementById("wpTextbox2")) {
 
if(document.getElementById("wpTextbox2")) {
 
var myTextBox = document.getElementById('wpTextbox2');
 
var myTextBox = document.getElementById('wpTextbox2');
 
var myText = myTextBox.value;
 
var myText = myTextBox.value;
 
 
var apI = new mw.Api();
+
var apIx = new mw.Api();
 
 
 
var ns = mw.config.get("wgCanonicalNamespace");
 
var ns = mw.config.get("wgCanonicalNamespace");
Regel 35: Regel 35:
 
 
 
var backupLocation = "User:" + currentUser + "/Editconflict/" + fulltitle;
 
var backupLocation = "User:" + currentUser + "/Editconflict/" + fulltitle;
apI.get({
+
apIx.get({
 
action: 'query',
 
action: 'query',
 
prop: 'info',
 
prop: 'info',
Regel 44: Regel 44:
 
edit_token = data.query.pages['-1'].edittoken;
 
edit_token = data.query.pages['-1'].edittoken;
 
}).done(function (data) {
 
}).done(function (data) {
api.post({
+
apIx.post({
 
'action': 'edit',
 
'action': 'edit',
 
'title': backupLocation,
 
'title': backupLocation,

Versie van 21 okt 2023 15:51

mw.loader.using('mediawiki.util', function() {
	mw.util.addPortletLink('p-tb', 
		'https://nl.wikipedia.org/wiki/' + encodeURIComponent(mw.config.get('wgPageName')), 
		'Wikipedia ', '#wikipedialink', mw.config.get('wgPageName') + " op Wikipedia ");
});

mw.loader.using('mediawiki.util', function() {
	mw.util.addPortletLink('p-tb', 
		'https://www.google.nl/search?q=' + encodeURIComponent(mw.config.get('wgPageName')), 
		'Google ', '#googlelink', mw.config.get('wgPageName') + " op Google ");
});


if (document.getElementById('beginnetje')) { //oranje: FF5733 //'blauw': #23819C 
	var beg = '<center><span style="color:gray">(Dit artikel is een beginnetje)</span></center>';
	document.getElementById('beginnetje').style.display = "none";
	$('#footer-info').before(beg);
}

$.when($.ready, mw.loader.using(['mediawiki.util'])).done(function() {
	if(document.getElementById("wpTextbox2")) {
		var myTextBox = document.getElementById('wpTextbox2');
		var myText = myTextBox.value;
		
		var apIx = new mw.Api();
		
		var ns = mw.config.get("wgCanonicalNamespace");
		if (ns !== "") {
			ns = ns + ":";
		}
		var title = mw.config.get("wgTitle");
		var fulltitle = ns + title;
		
		var currentUser = mw.config.get('wgUserName');
		
		var backupLocation = "User:" + currentUser + "/Editconflict/" + fulltitle;
	    apIx.get({
	        action: 'query',
	        prop: 'info',
	        intoken: 'edit',
	        titles: 'kaslv', //Pagina moet niet bestaan. 
	    }).done(
	        function (data) {
	            edit_token = data.query.pages['-1'].edittoken;
	        }).done(function (data) {
	            apIx.post({
	                'action': 'edit',
	                'title': backupLocation,
	                'text': myText,
	                'summary': "Automatische backup vanwege een edit conflict.",
	                'token': edit_token,
	            }).done(
	                function (data) {
	                    if (data.edit.result == "Success") {
	                    	window.location.href = "/" + backupLocation;
	                    }
	        	}); 
	        });
	}
});


mw.loader.load('//wikikids.nl/index.php?title=Gebruiker:Rots61/Script-AddSpecial.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikikids.nl/index.php?title=Gebruiker:Rots61/GevraagdePaginas.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikikids.nl/index.php?title=Gebruiker:Rots61/JS-DisamAssist.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikikids.nl/index.php?title=Gebruiker:Rots61/Gadget-LogTheCounter.js&action=raw&ctype=text/javascript');

if (document.getElementsByClassName('patrollink')[0]) {
    var rcid = document.getElementsByClassName('patrollink')[0].getElementsByTagName('a')[0].href.split("rcid=").pop();
	mw.util.addPortletLink('p-namespaces', 
		'javascript:patrolR61(' + rcid + ')', 
		'Patrol ', 'ca-patrollinkr61', " Controleer " + mw.config.get('wgPageName'), 'a');
}

function patrolR61(rcid){
    api.get({
        action: 'query',
        meta: 'tokens',
        type: 'patrol',
    }).done(
        function (data) {
            console.log(data);
            edit_token = data.query.tokens.patroltoken;
        }).done(function (data) {
        api.post({
            'action': 'patrol',
            'rcid': rcid,
            'token': edit_token,
        }).done(
            function (data) {
                console.log(data);
                mw.notify('Gecontroleerd');
                document.getElementById('ca-patrollinkr61').innerHTML = '';
            });
    });
}
Afkomstig van Wikikids , de interactieve Nederlandstalige Internet-encyclopedie voor en door kinderen. "https://wikikids.nl/index.php?title=Gebruiker:Rots61/common.js&oldid=821982"