User:Kashmiri/MRollback.js

/* global mw:true, Flash:true */ /** * Mass Rollback Script * * Creates a form to mass rollback edits * * @author Kangaroopower * @credits Ale_jrb (UI) * * From: User:Kangaroopower/Scripts * * To Do : * - From what time * */	var ns = { version: "2.34", active: false, };	ns.init = function { if (mw.config.get('wgCanonicalSpecialPageName') === "Contributions" && $.inArray(mw.config.get('wgUserGroups'), ["rollbacker", "sysop"])) { $("#firstHeading").append(' [ Mass Rollback ] '); $("#mr-link").click(function {				MRollback.open;			}); }	};	/* GUI Module */ ns.open = function { if (!MRollback.active) { MRollback.active = true; var popupHTML = ' Mass Rollback      Summary:   How many:      '; $('body').append(popupHTML); $('.mr-button').css({'width': '100px', 'font-size': '10px', 'margin-bottom': '4px'}); $('#mr-ui').show.draggable; $("#mr-all, #mr-some").click(function (e) {				var bool = e.toElement.id === "mr-all";				MRollback.rollback(bool);			}); }	};	ns.close = function { if (MRollback.active) { MRollback.active = false; $('#mr-ui').hide; }	};	/* API functions */ ns.rollback = function (all) { var mrlimit = all ? 500 : parseInt($('#mr-limit').val, 10), ucuser = encodeURIComponent($('#contentSub a:first').html), rbcontribs = 0;
 * ( function ( window, $, mw ) {

if (isNaN(mrlimit) || /^\d+$/.test($('#mr-limit').val)) return;

Flash('getUserContribs').load({number: mrlimit, user: ucuser}).wait(function (data) {			for(var i in data.query.usercontribs) {				if(data.query.usercontribs[i].top === '') {					var rbsummary = $('#mr-sum').val + ' (MRollback)',						latestcontribs = data.query.usercontribs[i].title;					console.log("Latest Contribs:" + latestcontribs);					Flash('rollback').load({targ: latestcontribs, user: ucuser, summary: rbsummary}).wait(function { rbcontribs++; console.log("rbcontribs:" + rbcontribs); }).run;				}			}			}).run; };	window.MRollback = ns; if (typeof mw.loader.moduleRegistry.Flash === "undefined") { mw.loader.implement('Flash', [mw.util.wikiScript('index') + '?title=User:Kashmiri/Flash.js&action=raw&ctype=text/javascript'], {}, {}); }	mw.loader.using(['Flash'], function {		MRollback.init;	}); }( this, jQuery, mediaWiki ) );