Jump to content

User:Bility/statusupdate.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Bility (talk | contribs) at 21:18, 14 March 2012 (test update). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
if (mw.config.get('wgPageName')=='User:'+mw.config.get('wgUserName') || mw.config.get('wgPageName')=='User_talk:'+mw.config.get('wgUserName') {
$(document).ready(function() {
	if (typeof hideStatus == 'undefined') { hideStatus = false; };
	if ($('#user-status')) {
		if (hideStatus) { $('#user-status').attr('style','visibility = "visible"'); };
		$('#user-status > span').each(function() {
			$(this).attr({
				style: 'cursor="pointer"',
				onClick: 'updateMyStatus'
			});
		});
	};
});
};

function updateMyStatus() {
	var statusText = $(this).html();
	var summ = 'updating status';
	var token;

	$.ajax({
		url: '/w/api.php?action=query&prop=info&intoken=edit&titles=Main_page&format=json',
		success: function(data) { token = data.query.pages[Object.keys(data.query.pages)].edittoken.replace(/\+\\$/g,'%2B%5C'); },
		dataType: 'json',
		async: false
	});

	$.ajax({
		type: 'POST',
		url: '/w/api.php?action=edit&title=User:'+wgUserName+'/Status&summary='+summ+'&minor=1&recreate=1&text='+statusText+'&token='+token,
		async: false
	});
};