Jump to content

User:Harsh4101991/EditCount.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Created page with ' mw.loader.using('mediawiki.api', function() { //http://en.wikipedia.org/w/api.php?action=query&list=users&format=json&usprop=editcount&ususers=Harsh4101991 var...'
 
No edit summary
Line 1: Line 1:


mw.loader.using('mediawiki.api', function() {
mw.loader.using('mediawiki.api', function() {
//http://en.wikipedia.org/w/api.php?action=query&list=users&format=json&usprop=editcount&ususers=Harsh4101991
//http://en.wikipedia.org/w/api.php?action=query&list=users&format=json&usprop=editcount&ususers=Harsh4101991
var x=0;
var x=0;
var api = new mw.Api();
var api = new mw.Api();
api.get({
api.get({
action: 'query',
list: 'users',
usprop: 'editcount',
ususers : wgUserName
})
.done( function(data){ // Function definition *only*
console.log( '2' );
console.log( data.query.users[0].editcount);
x = data.query.users[0].editcount;
}); // Means -> Start the API request, and run the code referred to by the name ‘requestSuccess’ when it is done. Don’t wait.
console.log('1');
action: 'query',
// Add a link to the toolbox
//-------------------
// Add a link to the toolbox
list: 'users',
var link = mw.util.addPortletLink(
'p-tb',
'#',
'Edit Count',
't-prettylinkwidget',
'Show Edit Count of User',
null,
'#t-whatlinkshere'
);
$(link).click( function( e ) {
usprop: 'editcount',
// Avoid the browser going to '#'
e.preventDefault();
ususers : wgUserName
//Adding Dialog
mw.loader.using( 'jquery.ui.dialog', function () {
$dialog = $('<div></div>')
}).done( function(data){ // Function definition *only*
.html('Your Edit Count is : '+ x)
.dialog({
console.log( '2' );
console.log( data.query.users[0].editcount);
x = data.query.users[0].editcount;
}); // Means -> Start the API request, and run the code referred to by the name ‘requestSuccess’ when it is done. Don’t wait.
console.log('1');
// Add a link to the toolbox
//-------------------
// Add a link to the toolbox
var link = mw.util.addPortletLink(
'p-tb',
'#',
'Edit Count',
't-prettylinkwidget',
'Show Edit Count of User',
null,
'#t-whatlinkshere'
);
$(link).click( function( e ) {
// Avoid the browser going to '#'
e.preventDefault();
//Adding Dialog
mw.loader.using( 'jquery.ui.dialog', function () {
$dialog = $('<div></div>')
.html('Your Edit Count is : '+ x)
.dialog({
autoOpen: true,
autoOpen: true,
title: 'Thanks For Your Contribution',
title: 'Thanks For Your Contribution',
Line 57: Line 44:
modal: true,
modal: true,
});
});
} );
//END
});
});
//END
});
//---------------------------
//---------------------------
});
});

Revision as of 03:14, 15 March 2015

mw.loader.using('mediawiki.api', function() {
//http://en.wikipedia.org/w/api.php?action=query&list=users&format=json&usprop=editcount&ususers=Harsh4101991
	var x=0;
	var api = new mw.Api();
 
	api.get({
		action: 'query',
		list: 'users',
		usprop: 'editcount',
		ususers : wgUserName
	})
	.done( function(data){ // Function definition *only*
		console.log( '2' );
		console.log( data.query.users[0].editcount);
		x = data.query.users[0].editcount;
	}); // Means -> Start the API request, and run the code referred to by the name ‘requestSuccess’ when it is done. Don’t wait.
 
	console.log('1');
	// Add a link to the toolbox
 	//-------------------
 
	// Add a link to the toolbox
	var link = mw.util.addPortletLink(
		'p-tb',
		'#',
		'Edit Count',
		't-prettylinkwidget',
		'Show Edit Count of User',
		null,
		'#t-whatlinkshere'
	);
 
	$(link).click( function( e ) {
		// Avoid the browser going to '#'
		e.preventDefault();
		//Adding Dialog
		mw.loader.using( 'jquery.ui.dialog', function () {
  			$dialog = $('<div></div>')
			.html('Your Edit Count is : '+ x)
			.dialog({
				autoOpen: true,
				title: 'Thanks For Your Contribution',
				width: '70%',
				modal: true,
			});
		});
		//END
	});
//---------------------------
});