MediaWiki:Common.js: Difference between revisions

From Ekatra Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
$( function(){
$( function(){
var sidebarCategory = $("#p-Categories > .vector-menu-content");
var sidebarCategory = $("#p-Categories > .vector-menu-content");
var sidebarAuthor = $("#p-Authors > .vector-menu-content");
sidebarCategory.empty();
sidebarCategory.empty();
sidebarAuthor.empty();


mw.loader.using( [ 'mediawiki.api' ], function(){
mw.loader.using( [ 'mediawiki.api' ], function(){
var sel = $('<select>').css( 'width', '100%').appendTo( sidebarCategory );
var sel1 = $('<select>').css( 'width', '100%').appendTo( sidebarCategory );
sel.append( $("<option>").attr('disabled', true).attr('selected', true).text( "-- Select an option --" ) );
var sel2 = $('<select>').css( 'width', '100%').appendTo( sidebarAuthor );
sel1.append( $("<option>").attr('disabled', true).attr('selected', true).text( "-- Select an option --" ) );
sel2.append( $("<option>").attr('disabled', true).attr('selected', true).text( "-- Select an option --" ) );


catMemberParam = {
// For category Categories
catMemberParam1 = {
"action": "query",
"action": "query",
"format": "json",
"format": "json",
Line 34: Line 39:
"cmlimit": "500"
"cmlimit": "500"
};
};
(new mw.Api()).get( catMemberParam, { async: false }  ).done(function ( resData ){
(new mw.Api()).get( catMemberParam1, { async: false }  ).done(function ( resData ){
var catOptions = [];
var catOptions = [];
var members = resData.query.categorymembers;
var members = resData.query.categorymembers;
Line 41: Line 46:
members.forEach( function(it){
members.forEach( function(it){
var ct = it.title.replace("Category:", "");
var ct = it.title.replace("Category:", "");
sel.append( $("<option>").attr('value', ct).text(ct) );
sel1.append( $("<option>").attr('value', ct).text(ct) );
});
});
sel.on('change', function (e) {
sel1.on('change', function (e) {
    var valueSelected = this.value;
    window.location = "https://wiki.ekatrafoundation.org/wiki/Category:" + valueSelected;
});
});
// For category Author
catMemberParam2 = {
"action": "query",
"format": "json",
"list": "categorymembers",
"cmtitle": "Category:Authors on EkatraWiki",
"cmprop": "title",
"cmtype": "subcat",
"cmlimit": "500"
};
(new mw.Api()).get( catMemberParam2, { async: false }  ).done(function ( resData ){
var catOptions = [];
var members = resData.query.categorymembers;
// Creating MenuItems array from Category Members
members.forEach( function(it){
var ct = it.title.replace("Category:", "");
sel2.append( $("<option>").attr('value', ct).text(ct) );
});
sel2.on('change', function (e) {
    var valueSelected = this.value;
    var valueSelected = this.value;
    window.location = "https://wiki.ekatrafoundation.org/wiki/Category:" + valueSelected;
    window.location = "https://wiki.ekatrafoundation.org/wiki/Category:" + valueSelected;

Revision as of 02:23, 8 June 2021

$( function(){
	
	if( mw.config.get('wgIsMainPage') ){
		$('#firstHeading').remove();
	}
	if( mw.config.get('wgUserName') === null  ){
		$('body').bind('cut copy', function(e) {
			e.preventDefault();
		});
	} else {
		$("#content").removeAttr("onmousedown");
		$("#content").removeAttr("onselectstart");
	}

	mw.loader.load( '/index.php?title=MediaWiki:Numerakri.js&action=raw&ctype=text/javascript' );
	mw.loader.load( '/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript');
});

$( function(){
	var sidebarCategory = $("#p-Categories > .vector-menu-content");
	var sidebarAuthor = $("#p-Authors > .vector-menu-content");
	sidebarCategory.empty();
	sidebarAuthor.empty();

	mw.loader.using( [ 'mediawiki.api' ], function(){
		var sel1 = $('<select>').css( 'width', '100%').appendTo( sidebarCategory );
		var sel2 = $('<select>').css( 'width', '100%').appendTo( sidebarAuthor );
		sel1.append( $("<option>").attr('disabled', true).attr('selected', true).text( "-- Select an option --" ) );
		sel2.append( $("<option>").attr('disabled', true).attr('selected', true).text( "-- Select an option --" ) );

		// For category Categories
		catMemberParam1 = {
			"action": "query",
			"format": "json",
			"list": "categorymembers",
			"cmtitle": "Category:Categories on EkatraWiki",
			"cmprop": "title",
			"cmtype": "subcat",
			"cmlimit": "500"
		};
		(new mw.Api()).get( catMemberParam1, { async: false }  ).done(function ( resData ){
			var catOptions = [];
			var members = resData.query.categorymembers;
	
			// Creating MenuItems array from Category Members
			members.forEach( function(it){
				var ct = it.title.replace("Category:", "");
				sel1.append( $("<option>").attr('value', ct).text(ct) );
			});
			
			sel1.on('change', function (e) {
			    var valueSelected = this.value;
			    window.location = "https://wiki.ekatrafoundation.org/wiki/Category:" + valueSelected;
			});
		});
		
		// For category Author
		catMemberParam2 = {
			"action": "query",
			"format": "json",
			"list": "categorymembers",
			"cmtitle": "Category:Authors on EkatraWiki",
			"cmprop": "title",
			"cmtype": "subcat",
			"cmlimit": "500"
		};
		(new mw.Api()).get( catMemberParam2, { async: false }  ).done(function ( resData ){
			var catOptions = [];
			var members = resData.query.categorymembers;
	
			// Creating MenuItems array from Category Members
			members.forEach( function(it){
				var ct = it.title.replace("Category:", "");
				sel2.append( $("<option>").attr('value', ct).text(ct) );
			});
			
			sel2.on('change', function (e) {
			    var valueSelected = this.value;
			    window.location = "https://wiki.ekatrafoundation.org/wiki/Category:" + valueSelected;
			});
		});
	} );
	
	
});

$( function(){
	var poemElement = $(".Poem2-Ekatra");
	
	if( poemElement.length ){
		var poemText = poemElement.html();
		var poemArray = poemText.split("\n");
		
		poemElement.text("");
	
		poemArray.forEach( function(i) {
			poemElement.append( '<p style="text-indent: 3em;">' + i + '</p>' );
		});		
	}
});