User:Paranomia/checkblocked.js

function get_blocked_json( user ) { document.getElementById( 'contentSub' ).innerHTML += ' Checking if user is blocked.' + '\n' + 'Please wait... ';	gml_xmlhttp = sajax_init_object; if ( !gml_xmlhttp ) {		return; }	var pageurl = wgScriptPath + '/api.php?action=query&list=blocks&bkusers=' + escape( user ) + '&format=json'; gml_xmlhttp.open( "GET", pageurl, true ); gml_xmlhttp.onreadystatechange = alertblocked; gml_xmlhttp.send(null); } function alertblocked { if ( gml_xmlhttp.readyState !== 4 ) {		return; }	json = gml_xmlhttp.responseText; var obj = eval( '(' + json + ')' ); var string = "Not blocked"; if ( obj.query.blocks.length > 0 ){ string = 'User has been blocked by: ' + obj.query.blocks[0].by + '<\/a>; expiring: ' + obj.query.blocks[0].expiry + '; because: ' + obj.query.blocks[0].reason + '.'; }	document.getElementById( 'contentSub' ).innerHTML += ' ' + string + ' '; }