User:Hairr/test.js

/*****************************************/ /* This script was taken from Joeytje50 */ /* User:Joeytje50/ChatBans.js for   */ /* the orignal script. This script    */ /* is only a modified version for the   */ /* chat bans archive. ~Hairrazerrr    */ /*****************************************/ //

//Finds usergroup whether or not to show and the title of the page if ((wgUserGroups.indexOf('sysop')!=-1||wgUserGroups.indexOf('chatmoderator')!=-1)&&wgTitle=='Chat/Bans/Archive_1') {

var d = new Date var monthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"]; $('#ChatBanArchive').html(' Add new banned user See Template:Bans for documentation and shorthand inputs. Banned user:  Banning moderator:   Date of the ban:    Ban expiry:   Ban reason:   Other notes (optional):   Submit ')

//The button if "today" was clicked

$('#btoday').click(function {	if ($(this).is(':checked')) {		$('#bdate #bother').attr('disabled','disabled')	} else {		$('#bdate #bother').removeAttr('disabled')	} })

function callAPI(data, method, callback) { data['format'] = 'json'; $.ajax({		data: data,		dataType: 'json',		url: wgScriptPath + '/api.php',		type: method,		cache: false,		success: function(response) {			if (response.error)				alert('API error: ' + response.error.info);			else 				callback(response);		},		error: function(xhr, error) { alert('AJAX error: ' + error) }	}); }

$('#bsubmit').click(function { $(this).attr('disabled','disabled').html('Loading...') var bandate = $('#bdate input[disabled]').length!=0?$('#bdate input:not([disabled])').val: var template =  callAPI({ 'action': 'query', 'prop': 'info|revisions', 'intoken': 'edit', 'titles': wgPageName, 'rvprop': 'content', 'rvlimit': '1', 'indexpageids': 'true', }, 'GET', function(response) { var page = response.query.pages[response.query.pageids[0]]; var content = page.revisions[0]['*']; content = content+'\n'+template; callAPI({		'minor': 'yes',		'summary': 'Adding to the bans archive.',		'action': 'edit',		'title': wgPageName,		'basetimestamp': page.revisions[0].timestamp,		'startimestamp': page.starttimestamp,		'token': page.edittoken,		'text': content	}, 'POST', function(response) {		alert('Your edit has been submitted. The page will now be reloaded.')		document.location.href = wgArticlePath.replace('$1', wgPageName)+'?action=purge'	}); }); }) }