Jump to content

User:Gryllida/js/TagEditing.js

From Wikinews, the free news source you can write!

Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools⊟Preferences. — More skins

//<nowiki>

var tagediting = {
	tag: function () {
		var api = new mw.Api();
		api.postWithToken("edit", {
				action: 'edit',
				title: mw.config.get ('wgPageName'),
				prependtext: '{{editing}}',
				summary: 'added status tag: {{[[Template:editing|editing]]}} ([[User:Gryllida/js/TagEditing.js|s]])'
			}).done(function (data){
				$('#tagediting').fadeOut();
				jsMsg( 'Template added' );
			});
	},
	init: function () {
		var t = document.getElementById('t-whatlinkshere');
        	if (!t) return;
		var li = document.createElement('li');
		var a = document.createElement('a');
		a.setAttribute('href', 'javascript:tagediting.tag()');
		a.id = 'tagediting';
		a.appendChild(document.createTextNode('tag editing'));
		li.appendChild(a);
		t.parentNode.appendChild(li);
	}
};

mw.loader.using(['mediawiki.api'], function () {
tagediting.init();
});

// </nowiki>